How to use the devilry.simplified.FilterSpec function in devilry

To help you get started, we’ve selected a few devilry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github devilry / devilry-django / devilry / coreutils / simplified / metabases / assignment_group.py View on Github external
'candidates__identifier',
                             'candidates__full_name',
                             'candidates__email',
                             # assignment
                             'parentnode__long_name',
                             'parentnode__short_name',
                             # period
                             'parentnode__parentnode__long_name',
                             'parentnode__parentnode__short_name',
                             # subject
                             'parentnode__parentnode__parentnode__long_name',
                             'parentnode__parentnode__parentnode__short_name',
                             )
    filters = FilterSpecs(FilterSpec('id'),
                          FilterSpec('parentnode'),
                          FilterSpec('is_open', type_converter=boolConverter),
                          FilterSpec('latest_deadline_deadline', type_converter=dateTimeConverter),
                          FilterSpec('number_of_deliveries', type_converter=intConverter),

                          # Feedback
                          FilterSpec('feedback', type_converter=intOrNoneConverter),
                          FilterSpec('feedback__points', type_converter=intConverter),
                          FilterSpec('feedback__is_passing_grade', type_converter=boolConverter),
                          FilterSpec('feedback__grade'),

                          FilterSpec('candidates__identifier', type_converter=noCandidateIdConverter),

                          # Latest delivery
                          FilterSpec('feedback__delivery__number', type_converter=intConverter),
                          FilterSpec('feedback__delivery__time_of_delivery', type_converter=dateTimeConverter),
                          FilterSpec('feedback__delivery__delivery_type', type_converter=intConverter),
github devilry / devilry-django / devilry / coreutils / simplified / metabases / deadline.py View on Github external
searchfields = FieldSpec(
        'assignment_group__candidates__identifier',
        'assignment_group__parentnode__short_name',  # Name of assignment
        'assignment_group__parentnode__long_name',  # Name of assignment
        'assignment_group__parentnode__parentnode__short_name',  # Name of period
        'assignment_group__parentnode__parentnode__long_name',  # Name of period
        'assignment_group__parentnode__parentnode__parentnode__short_name',  # Name of subject
        'assignment_group__parentnode__parentnode__parentnode__long_name'  # Name of subject
        )
    filters = FilterSpecs(FilterSpec('id'),
                          FilterSpec('deadline'),
                          FilterSpec('assignment_group'),
                          FilterSpec('number_of_deliveries'),
                          ForeignFilterSpec('assignment_group',  # Assignment
                                            FilterSpec('is_open'),
                                            FilterSpec('name')),
                          ForeignFilterSpec('assignment_group__parentnode',  # Assignment
                                            FilterSpec('delivery_types'),
                                            FilterSpec('parentnode'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')),
                          ForeignFilterSpec('assignment_group__parentnode__parentnode',  # Period
                                            FilterSpec('parentnode'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')),
                          ForeignFilterSpec('assignment_group__parentnode__parentnode__parentnode',  # Subject
                                            FilterSpec('parentnode'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')))
github devilry / devilry-django / src / devilry / devilry / coreutils / simplified / metabases / delivery.py View on Github external
# period
                             'deadline__assignment_group__parentnode__parentnode__short_name',
                             'deadline__assignment_group__parentnode__parentnode__long_name',
                             # subject
                             'deadline__assignment_group__parentnode__parentnode__parentnode__short_name',
                             'deadline__assignment_group__parentnode__parentnode__parentnode__long_name')
    filters = FilterSpecs(FilterSpec('id'),
                          FilterSpec('deadline'),
                          FilterSpec('delivery_type'),
                          FilterSpec('time_of_delivery'),
                          ForeignFilterSpec('deadline',
                                            FilterSpec('deadline'),
                                            FilterSpec('assignment_group')),
                          ForeignFilterSpec('deadline__assignment_group',  # AssignmentGroup
                                            FilterSpec('parentnode'),
                                            FilterSpec('name')),
                          ForeignFilterSpec('deadline__assignment_group__parentnode',  # Assignment
                                            FilterSpec('parentnode'),
                                            FilterSpec('delivery_types'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')),
                          ForeignFilterSpec('deadline__assignment_group__parentnode__parentnode',  # Period
                                            FilterSpec('parentnode'),
                                            FilterSpec('start_time'),
                                            FilterSpec('end_time'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')),
                          ForeignFilterSpec('deadline__assignment_group__parentnode__parentnode__parentnode',  # Subject
                                            FilterSpec('parentnode'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')))
github devilry / devilry-django / devilry / coreutils / simplified / metabases / abstract_applicationkeyvalue.py View on Github external
from devilry.simplified import (FieldSpec, FilterSpec, FilterSpecs)


class SimplifiedAbstractApplicationKeyValueMixin(object):
    resultfields = FieldSpec('id', 'application', 'key', 'value')
    searchfields = FieldSpec('application', 'key', 'value')
    editablefields = ('application', 'key', 'value')
    filters = FilterSpecs(FilterSpec('id', supported_comp=('exact',)),
                          FilterSpec('application', supported_comp=('exact',)),
                          FilterSpec('key', supported_comp=('exact',)))
github devilry / devilry-django / devilry / coreutils / simplified / metabases / delivery.py View on Github external
'deadline__assignment_group__parentnode__parentnode__parentnode__long_name'])
    searchfields = FieldSpec('number',
                             # assignmentgroup
                             'deadline__assignment_group__name',
                             'deadline__assignment_group__examiners__username',
                             'deadline__assignment_group__candidates__identifier',
                             # assignment
                             'deadline__assignment_group__parentnode__short_name',
                             'deadline__assignment_group__parentnode__long_name',
                             # period
                             'deadline__assignment_group__parentnode__parentnode__short_name',
                             'deadline__assignment_group__parentnode__parentnode__long_name',
                             # subject
                             'deadline__assignment_group__parentnode__parentnode__parentnode__short_name',
                             'deadline__assignment_group__parentnode__parentnode__parentnode__long_name')
    filters = FilterSpecs(FilterSpec('id'),
                          FilterSpec('deadline'),
                          FilterSpec('time_of_delivery'),
                          ForeignFilterSpec('deadline',
                                            FilterSpec('deadline'),
                                            FilterSpec('assignment_group')),
                          ForeignFilterSpec('deadline__assignment_group',  # AssignmentGroup
                                            FilterSpec('parentnode'),
                                            FilterSpec('name')),
                          ForeignFilterSpec('deadline__assignment_group__parentnode',  # Assignment
                                            FilterSpec('parentnode'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')),
                          ForeignFilterSpec('deadline__assignment_group__parentnode__parentnode',  # Period
                                            FilterSpec('parentnode'),
                                            FilterSpec('start_time'),
                                            FilterSpec('end_time'),
github devilry / devilry-django / devilry / coreutils / simplified / metabases / assignment.py View on Github external
'parentnode__long_name',
                             'parentnode__parentnode__short_name',
                             'parentnode__parentnode__long_name')
    filters = FilterSpecs(FilterSpec('parentnode'),
                          FilterSpec('short_name'),
                          FilterSpec('long_name'),
                          # Period
                          ForeignFilterSpec('parentnode',
                                            FilterSpec('parentnode'),
                                            FilterSpec('start_time'),
                                            FilterSpec('end_time'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')),
                          # Subject
                          ForeignFilterSpec('parentnode__parentnode',
                                            FilterSpec('parentnode'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')))
github devilry / devilry-django / devilry / apps / gradeeditors / simplified / examiner.py View on Github external
    @classmethod
    def read_authorize(cls, user, obj):
        try:
            Assignment.objects.get(Assignment.q_is_examiner(user) & Q(id=obj.id))
        except Assignment.DoesNotExist:
            raise PermissionDenied()


@simplified_modelapi
class SimplifiedFeedbackDraft(SimplifiedModelApi):
    class Meta:
        model = FeedbackDraft
        resultfields = FieldSpec('id', 'delivery', 'saved_by', 'save_timestamp', 'draft', 'published', 'staticfeedback')
        searchfields = FieldSpec()
        filters = FilterSpecs(FilterSpec('delivery'))
        methods = ('create', 'read', 'search')
        editablefields = ('delivery', 'draft', 'published')

    @classmethod
    def create_searchqryset(self, user):
        return self._meta.model.objects.filter(saved_by=user)

    @classmethod
    def read_authorize(cls, user, obj):
        if not obj.saved_by == user:
            raise PermissionDenied()

    @classmethod
    def write_authorize(cls, user, obj):
        if not obj.delivery.deadline.assignment_group.is_examiner(user):
            raise PermissionDenied()
github devilry / devilry-django / src / devilry / apps / administrator / simplified / simplifiedassignmentgrouptag.py View on Github external
@simplified_modelapi
class SimplifiedAssignmentGroupTag(CanSaveBase):
    """ Simplified wrapper for :class:`devilry.apps.core.models.AssignmentGroupTag`. """
    class Meta(HasAdminsMixin.MetaMixin):
        """ Defines what methods an Administrator can use on an AssignmentGroupTag object using the Simplified API """
        model = AssignmentGroupTag
        methods = ('create', 'read', 'update', 'delete', 'search')
        editablefields = ('tag', 'assignment_group')
        resultfields = FieldSpec('id', 'assignment_group', 'tag')
        searchfields = FieldSpec()
        filters = FilterSpecs(FilterSpec('id'),
                              FilterSpec('tag'),
                              FilterSpec('assignment_group'),
                              FilterSpec('assignment_group__parentnode'), # Assignment
                              FilterSpec('assignment_group__parentnode__parentnode'), # Period
                              FilterSpec('assignment_group__parentnode__parentnode__parentnode') # Subject
                             )

    @classmethod
    def is_empty(cls, obj):
        return True
github devilry / devilry-django / devilry / coreutils / simplified / metabases / assignment_group.py View on Github external
# Latest delivery
                          FilterSpec('feedback__delivery__number', type_converter=intConverter),
                          FilterSpec('feedback__delivery__time_of_delivery', type_converter=dateTimeConverter),
                          FilterSpec('feedback__delivery__delivery_type', type_converter=intConverter),

                          ForeignFilterSpec('parentnode',  # Assignment
                                            FilterSpec('delivery_types'),
                                            FilterSpec('parentnode'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')),
                          ForeignFilterSpec('parentnode__parentnode',  # Period
                                            FilterSpec('parentnode'),
                                            FilterSpec('start_time'),
                                            FilterSpec('end_time'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')),
                          ForeignFilterSpec('parentnode__parentnode__parentnode',  # Subject
                                            FilterSpec('parentnode'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')))
github devilry / devilry-django / src / devilry / devilry / coreutils / simplified / metabases / delivery.py View on Github external
searchfields = FieldSpec('number',
                             # assignmentgroup
                             'deadline__assignment_group__name',
                             # assignment
                             'deadline__assignment_group__parentnode__short_name',
                             'deadline__assignment_group__parentnode__long_name',
                             # period
                             'deadline__assignment_group__parentnode__parentnode__short_name',
                             'deadline__assignment_group__parentnode__parentnode__long_name',
                             # subject
                             'deadline__assignment_group__parentnode__parentnode__parentnode__short_name',
                             'deadline__assignment_group__parentnode__parentnode__parentnode__long_name')
    filters = FilterSpecs(FilterSpec('id'),
                          FilterSpec('deadline'),
                          FilterSpec('delivery_type'),
                          FilterSpec('time_of_delivery'),
                          ForeignFilterSpec('deadline',
                                            FilterSpec('deadline'),
                                            FilterSpec('assignment_group')),
                          ForeignFilterSpec('deadline__assignment_group',  # AssignmentGroup
                                            FilterSpec('parentnode'),
                                            FilterSpec('name')),
                          ForeignFilterSpec('deadline__assignment_group__parentnode',  # Assignment
                                            FilterSpec('parentnode'),
                                            FilterSpec('delivery_types'),
                                            FilterSpec('short_name'),
                                            FilterSpec('long_name')),
                          ForeignFilterSpec('deadline__assignment_group__parentnode__parentnode',  # Period
                                            FilterSpec('parentnode'),
                                            FilterSpec('start_time'),
                                            FilterSpec('end_time'),
                                            FilterSpec('short_name'),