<commit_before>from ...simplified import simplified_modelapi, PermissionDenied, FieldSpec
from ..core import models


class PublishedWhereIsCandidateMixin(object):

    @classmethod
    def create_searchqryset(cls, user, **kwargs):
        return cls._meta.model.published_where_is_candidate(user)

    @classmethod
    def read_authorize(cls, user, obj):
        if not cls._meta.model.published_where_is_candidate(user).filter(id=obj.id):
            raise PermissionDenied()


@simplified_modelapi
class SimplifiedFeedback(PublishedWhereIsCandidateMixin):

    class Meta:

        _subject_long     = 'delivery__assignment_group__parentnode__parentnode__parentnode__long_name'
        _subject_short    = 'delivery__assignment_group__parentnode__parentnode__parentnode__short_name'
        _subject_id       = 'delivery__assignment_group__parentnode__parentnode__parentnode__id'

        _period_long      = 'delivery__assignment_group__parentnode__parentnode__long_name'
        _period_short     = 'delivery__assignment_group__parentnode__parentnode__short_name'
        _period_id        = 'delivery__assignment_group__parentnode__parentnode__id'

        _assignment_long  = 'delivery__assignment_group__parentnode__long_name'
        _assignment_short = 'delivery__assignment_group__parentnode__short_name'
        _assignment_id    = 'delivery__assignment_group__parentnode__id'

        _delivery_time    = 'delivery__time_of_delivery'
        _delivery_number  = 'delivery__number'
        _delivery_success = 'delivery__successful'

        model = models.StaticFeedback
        resultfields = FieldSpec('id', 'format', 'text',
                                 period=[_period_short, _period_long, _period_id],
                                 subject=[_subject_long, _subject_short, _subject_id],
                                 assignment=[_assignment_short, _assignment_long, _assignment_id],
                                 delivery=[_delivery_time, _delivery_number, _delivery_success])
        searchfields = FieldSpec(_subject_short,
                                 _subject_long,
                                 _period_short,
                                 _period_long,
                                 _assignment_long,
                                 _assignment_short,
                                 _delivery_success,
                                 _delivery_number)
        methods = ['search', 'read']


@simplified_modelapi<commit_msg>apps.student.simplified: Changed resultfields of SimplifiedFeedback to reflect changes made in core.StaticFeedback<commit_after>from ...simplified import simplified_modelapi, PermissionDenied, FieldSpec
from ..core import models


class PublishedWhereIsCandidateMixin(object):

    @classmethod
    def create_searchqryset(cls, user, **kwargs):
        return cls._meta.model.published_where_is_candidate(user)

    @classmethod
    def read_authorize(cls, user, obj):
        if not cls._meta.model.published_where_is_candidate(user).filter(id=obj.id):
            raise PermissionDenied()


@simplified_modelapi
class SimplifiedFeedback(PublishedWhereIsCandidateMixin):

    class Meta:

        _subject_long     = 'delivery__assignment_group__parentnode__parentnode__parentnode__long_name'
        _subject_short    = 'delivery__assignment_group__parentnode__parentnode__parentnode__short_name'
        _subject_id       = 'delivery__assignment_group__parentnode__parentnode__parentnode__id'

        _period_long      = 'delivery__assignment_group__parentnode__parentnode__long_name'
        _period_short     = 'delivery__assignment_group__parentnode__parentnode__short_name'
        _period_id        = 'delivery__assignment_group__parentnode__parentnode__id'

        _assignment_long  = 'delivery__assignment_group__parentnode__long_name'
        _assignment_short = 'delivery__assignment_group__parentnode__short_name'
        _assignment_id    = 'delivery__assignment_group__parentnode__id'

        _delivery_time    = 'delivery__time_of_delivery'
        _delivery_number  = 'delivery__number'
        _delivery_success = 'delivery__successful'

        model = models.StaticFeedback
        resultfields = FieldSpec('id', 'grade', 'points', 'is_passing_grade',
                                 period=[_period_short, _period_long, _period_id],
                                 subject=[_subject_long, _subject_short, _subject_id],
                                 assignment=[_assignment_short, _assignment_long, _assignment_id],
                                 delivery=[_delivery_time, _delivery_number, _delivery_success])
        searchfields = FieldSpec(_subject_short,
                                 _subject_long,
                                 _period_short,
                                 _period_long,
                                 _assignment_long,
                                 _assignment_short,
                                 _delivery_success,
                                 _delivery_number)
        methods = ['search', 'read']


@simplified_modelapi
{'fraction_non_alphanumeric': 0.057351202207331496, 'fraction_numerical': 0.0, 'mean_word_length': 2.546470999301188, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1537712', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1360, 'n_words': 188}