class SimplifiedFileMetaMetaMixin(object): """ Defines the django model to be used, resultfields returned by search and which fields can be used to search for a FileMeta object using the Simplified API """ model = models.FileMeta resultfields = FieldSpec('filename', 'size', 'id', 'delivery', subject=['delivery__deadline__assignment_group__parentnode__parentnode__parentnode__id', 'delivery__deadline__assignment_group__parentnode__parentnode__parentnode__short_name', 'delivery__deadline__assignment_group__parentnode__parentnode__parentnode__long_name'], period=['delivery__deadline__assignment_group__parentnode__parentnode__id', 'delivery__deadline__assignment_group__parentnode__parentnode__short_name', 'delivery__deadline__assignment_group__parentnode__parentnode__long_name'], assignment=['delivery__deadline__assignment_group__parentnode__id', 'delivery__deadline__assignment_group__parentnode__short_name', 'delivery__deadline__assignment_group__parentnode__long_name']) searchfields = FieldSpec( 'delivery__deadline__assignment_group__candidates__identifier', # student in assignment_group 'delivery__deadline__assignment_group__parentnode__parentnode__parentnode__short_name', # subject 'delivery__deadline__assignment_group__parentnode__parentnode__parentnode__long_name', # subject 'delivery__deadline__assignment_group__parentnode__parentnode__short_name', # period 'delivery__deadline__assignment_group__parentnode__parentnode__long_name', # period 'delivery__deadline__assignment_group__parentnode__short_name', # assignment 'delivery__deadline__assignment_group__parentnode__long_name', # assignment ) filters = FilterSpecs(FilterSpec('id'), FilterSpec('filename'), FilterSpec('size'), FilterSpec('delivery'))
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', )))
class SimplifiedStaticFeedbackMetaMixin(object): """ Defines the django model to be used, resultfields returned by search and which fields can be used to search for a StaticFeedback object using the Simplified API """ model = models.StaticFeedback resultfields = FieldSpec( 'id', 'grade', 'is_passing_grade', 'saved_by', 'save_timestamp', 'delivery', 'rendered_view', candidates=[ 'delivery__deadline__assignment_group__candidates__identifier' ], period=[ 'delivery__deadline__assignment_group__parentnode__parentnode__id', 'delivery__deadline__assignment_group__parentnode__parentnode__short_name', 'delivery__deadline__assignment_group__parentnode__parentnode__long_name' ], subject=[ 'delivery__deadline__assignment_group__parentnode__parentnode__parentnode__id', 'delivery__deadline__assignment_group__parentnode__parentnode__parentnode__short_name', 'delivery__deadline__assignment_group__parentnode__parentnode__parentnode__long_name' ], assignment=[ 'delivery__deadline__assignment_group__parentnode__id', 'delivery__deadline__assignment_group__parentnode__short_name', 'delivery__deadline__assignment_group__parentnode__long_name' ], assignment_group=[ 'delivery__deadline__assignment_group', 'delivery__deadline__assignment_group__name' ], delivery=[ 'delivery__time_of_delivery', 'delivery__number', 'delivery__delivered_by' ]) searchfields = FieldSpec( 'delivery__deadline__assignment_group__parentnode__parentnode__parentnode__short_name', 'delivery__deadline__assignment_group__parentnode__parentnode__parentnode__long_name', 'delivery__deadline__assignment_group__parentnode__parentnode__short_name', 'delivery__deadline__assignment_group__parentnode__parentnode__long_name', 'delivery__deadline__assignment_group__parentnode__short_name', 'delivery__deadline__assignment_group__parentnode__long_name', 'delivery__number') filters = FilterSpecs( FilterSpec('id'), FilterSpec('delivery'), ForeignFilterSpec( 'delivery__deadline__assignment_group__parentnode__parentnode', # Period FilterSpec('start_time'), FilterSpec('end_time')), )
class RelatedUsersMetaBase: methods = ['create', 'read', 'update', 'delete', 'search'] resultfields = FieldSpec('id', 'period', 'user', 'tags', 'user__username', 'user__devilryuserprofile__full_name', 'user__email') searchfields = FieldSpec('user__username', 'user__devilryuserprofile__full_name') editablefields = ('period', 'user') filters = FilterSpecs(FilterSpec('id', supported_comp=('exact', )), FilterSpec('period', supported_comp=('exact', )), FilterSpec('user', supported_comp=('exact', )))
class Meta(SimplifiedAbstractApplicationKeyValueMixin): model = models.PeriodApplicationKeyValue methods = ['create', 'read', 'update', 'delete', 'search'] resultfields = FieldSpec( 'period') + SimplifiedAbstractApplicationKeyValueMixin.resultfields editablefields = ( 'period', ) + SimplifiedAbstractApplicationKeyValueMixin.editablefields filters = FilterSpecs( FilterSpec('period', supported_comp=('exact', )), FilterSpec('period__start_time'), FilterSpec('period__end_time'), FilterSpec('period__parentnode', supported_comp=('exact', )), FilterSpec('period__parentnode__parentnode', supported_comp=('exact', )) ) + SimplifiedAbstractApplicationKeyValueMixin.filters
class SimplifiedExaminerMetaMixin(object): """ Defines the django model to be used, resultfields returned by search and which fields can be used to search for a Examiner object using the Simplified API """ model = models.Examiner resultfields = FieldSpec('id', 'assignmentgroup') searchfields = FieldSpec() filters = FilterSpecs( FilterSpec('id'), FilterSpec('assignmentgroup'), FilterSpec('assignmentgroup__parentnode'), # Assignment FilterSpec('assignmentgroup__parentnode__parentnode'), # Period FilterSpec( 'assignmentgroup__parentnode__parentnode__parentnode') # Subject )
class SimplifiedCandidateMetaMixin(object): """ Defines the django model to be used, resultfields returned by search and which fields can be used to search for a Candidate object using the Simplified API """ model = models.Candidate resultfields = FieldSpec('id', 'identifier', 'full_name', 'email', 'assignment_group') searchfields = FieldSpec('identifier') filters = FilterSpecs( FilterSpec('id'), FilterSpec('assignment_group'), FilterSpec('assignment_group__parentnode'), # Assignment FilterSpec('assignment_group__parentnode__parentnode'), # Period FilterSpec( 'assignment_group__parentnode__parentnode__parentnode') # Subject )
class Meta(): model = models.Node resultfields = FieldSpec('id', 'parentnode', 'short_name', 'long_name', admins=['admins__username']) searchfields = FieldSpec('short_name', 'long_name') filters = FilterSpecs(FilterSpec('parentnode'), FilterSpec('short_name'), FilterSpec('long_name'), PatternFilterSpec('^(parentnode__)+short_name$'), PatternFilterSpec('^(parentnode__)+long_name$'), PatternFilterSpec('^(parentnode__)+id$')) methods = ['create', 'read', 'update', 'delete', 'search']
class Meta(RelatedUsersMetaBase): """ Defines what methods an Administrator can use on a RelatedStudent object using the Simplified API """ model = models.RelatedStudent resultfields = RelatedUsersMetaBase.resultfields + FieldSpec('candidate_id') searchfields = RelatedUsersMetaBase.searchfields + FieldSpec('candidate_id') editablefields = RelatedUsersMetaBase.editablefields + ('candidate_id',) filters = RelatedUsersMetaBase.filters + FilterSpecs(FilterSpec('candidate_id'))
class Meta(SimplifiedAssignmentGroupMetaMixin): """ Defines what methods an Administrator can use on an AssignmentGroup object using the Simplified API """ editablefields = ('id', 'name', 'is_open', 'parentnode') fake_editablefields = ('fake_examiners', 'fake_candidates', 'fake_tags') methods = ['create', 'read', 'update', 'delete', 'search'] resultfields = \ FieldSpec(users=['candidates__student__username', 'candidates__identifier', 'examiners__user__username'], students_full_name=['candidates__student__devilryuserprofile__full_name'], tags=['tags__tag']) + \ SimplifiedAssignmentGroupMetaMixin.resultfields searchfields = FieldSpec('tags__tag', 'candidates__student__username', 'examiners__user__username', 'candidates__student__devilryuserprofile__full_name') + SimplifiedAssignmentGroupMetaMixin.searchfields filters = SimplifiedAssignmentGroupMetaMixin.filters + \ FilterSpecs(FilterSpec('candidates__student__username', type_converter=stringOrNoneConverter), FilterSpec('examiners__user__username', type_converter=stringOrNoneConverter), FilterSpec('tags__tag', type_converter=stringOrNoneConverter))
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')
class Meta(SimplifiedPeriodMetaMixin): model = Period methods = ['create', 'read', 'update', 'delete', 'search'] resultfields = FieldSpec( 'id', 'parentnode', 'short_name', 'long_name', 'start_time', 'end_time', 'group', 'period_ptr', subject=['parentnode__short_name', 'parentnode__long_name']) searchfields = FieldSpec('short_name', 'long_name', 'parentnode__short_name', 'parentnode__long_name') filters = FilterSpecs( FilterSpec('short_name'), FilterSpec('group', type_converter=intOrNoneConverter))
class Meta(object): model = PeriodExercise resultfields = FieldSpec('id', 'period', 'exercise', 'points', 'starred', 'number', exercise=['exercise__short_name', 'exercise__long_name', 'exercise__topics__name'], period=['period__long_name', 'period__short_name'] ) searchfields = FieldSpec('period__short_name', 'period__long_name', 'exercise__short_name', 'exercise__long_name', 'exercise__topics__name') filters = FilterSpecs(FilterSpec('exercise'), FilterSpec('period')) methods = ['create', 'read', 'update', 'delete', 'search']
class Meta(HasAdminsMixin.MetaMixin): """ Defines the CRUD+S methods, the django model to be used, resultfields returned by search and which fields can be used to search for a Node object using the Simplified API """ fake_editablefields = ('fake_admins', ) methods = ['create', 'read', 'update', 'delete', 'search'] model = models.Node resultfields = FieldSpec('id', 'parentnode', 'short_name', 'long_name', admins=['admins__username']) searchfields = FieldSpec('short_name', 'long_name') filters = FilterSpecs(FilterSpec('parentnode'), FilterSpec('short_name'), FilterSpec('long_name'), PatternFilterSpec('^(parentnode__)+short_name$'), PatternFilterSpec('^(parentnode__)+long_name$'), PatternFilterSpec('^(parentnode__)+id$'))
class Meta(object): model = Exercise searchfields = FieldSpec('short_name', 'long_name', 'topics__name') resultfields = FieldSpec('id', 'short_name', 'long_name', 'text', 'points', 'topics__id', 'prerequisites__id', topics=['topics__name'], prerequisites=['prerequisites__name']) # editablefields = ('id', 'short_name', 'long_name', 'text', 'points') fake_editablefields = ('fake_topics', 'fake_prerequisites') fake_real_map = {'fake_topics': ('topics', Topic, 'pk', 'name'), 'fake_prerequisites': ('prerequisites', Topic, 'pk', 'name')} filters = FilterSpecs(FilterSpec('topics__id')) methods = ['create', 'read', 'update', 'delete', 'search']
class Meta(object): model = PeriodGroup methods = ['create', 'read', 'update', 'delete', 'search'] searchfields = FieldSpec('long_name', 'subject__long_name', 'periods__long_name') resultfields = FieldSpec( 'id', 'long_name', 'subject', 'subject__long_name', 'periods__id', periods=['periods__short_name', 'periods__long_name']) fake_editablefields = ('fake_periods', 'fake_followers', 'fake_students') fake_real_map = {'fake_periods': ('periods', Period)} filters = FilterSpecs(FilterSpec('followers__id'))
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 )
class SimplifiedSubjectMetaMixin(object): """ Defines the django model to be used, resultfields returned by search and which fields can be used to search for a Subject object using the Simplified API """ model = models.Subject resultfields = FieldSpec( 'id', 'parentnode', 'short_name', 'long_name', ) searchfields = FieldSpec('short_name', 'long_name') filters = FilterSpecs( FilterSpec('parentnode'), FilterSpec('short_name'), FilterSpec('long_name'), ForeignFilterSpec( 'parentnode', # Node FilterSpec('parentnode'), FilterSpec('short_name'), FilterSpec('long_name')))
class SimplifiedDeadlineMetaMixin(object): """ Defines the django model to be used, resultfields returned by search and which fields can be used to search for a Deadline object using the Simplified API """ model = models.Deadline annotated_fields = ('number_of_deliveries',) resultfields = FieldSpec('id', 'text', 'deadline', 'assignment_group', 'number_of_deliveries', 'feedbacks_published', subject=['assignment_group__parentnode__parentnode__parentnode__id', 'assignment_group__parentnode__parentnode__parentnode__short_name', 'assignment_group__parentnode__parentnode__parentnode__long_name'], period=['assignment_group__parentnode__parentnode__id', 'assignment_group__parentnode__parentnode__short_name', 'assignment_group__parentnode__parentnode__long_name'], assignment=['assignment_group__parentnode__id', 'assignment_group__parentnode__delivery_types', 'assignment_group__parentnode__short_name', 'assignment_group__parentnode__long_name'], assignment_group=['assignment_group__name', 'assignment_group__is_open'], assignment_group_users=['assignment_group__candidates__identifier'] ) 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')))
class SimplifiedDeliveryMetaMixin(object): """ Defines the django model to be used, resultfields returned by search and which fields can be used to search for a Delivery object using the Simplified API """ model = models.Delivery editablefields = ('deadline', 'successful') resultfields = FieldSpec( 'id', 'number', 'time_of_delivery', 'deadline', 'successful', 'delivery_type', 'alias_delivery', delivered_by=['delivered_by__identifier'], candidates=['deadline__assignment_group__candidates__identifier'], deadline=['deadline__deadline'], assignment_group=[ 'deadline__assignment_group', 'deadline__assignment_group__name' ], assignment_group_users=[ 'deadline__assignment_group__candidates__identifier' ], assignment=[ 'deadline__assignment_group__parentnode', 'deadline__assignment_group__parentnode__delivery_types', 'deadline__assignment_group__parentnode__short_name', 'deadline__assignment_group__parentnode__long_name' ], period=[ 'deadline__assignment_group__parentnode__parentnode', 'deadline__assignment_group__parentnode__parentnode__start_time', 'deadline__assignment_group__parentnode__parentnode__end_time', 'deadline__assignment_group__parentnode__parentnode__short_name', 'deadline__assignment_group__parentnode__parentnode__long_name' ], subject=[ 'deadline__assignment_group__parentnode__parentnode__parentnode', 'deadline__assignment_group__parentnode__parentnode__parentnode__short_name', 'deadline__assignment_group__parentnode__parentnode__parentnode__long_name' ]) searchfields = FieldSpec( 'number', # assignmentgroup 'deadline__assignment_group__name', '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('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')))
class SimplifiedAssignmentGroupMetaMixin(object): """ Defines the django model to be used, resultfields returned by search and which fields can be used to search for an AssignmentGroup object using the Simplified API """ model = models.AssignmentGroup annotated_fields = ('latest_delivery_id', 'number_of_deliveries', 'latest_deadline_deadline', 'latest_deadline_id') resultfields = FieldSpec('id', 'name', 'is_open', 'parentnode', 'feedback', 'latest_delivery_id', 'latest_deadline_id', 'latest_deadline_deadline', 'number_of_deliveries', candidates=[OneToMany('candidates', fields=['identifier', 'full_name', 'email'])], feedback=['feedback__points', 'feedback__grade', 'feedback__is_passing_grade'], feedback_rendered_view=['feedback__rendered_view'], feedbackdelivery=['feedback__delivery__number', 'feedback__delivery__time_of_delivery', 'feedback__delivery__delivery_type', 'feedback__delivery__deadline'], assignment=['parentnode__long_name', 'parentnode__short_name', 'parentnode__anonymous', 'parentnode__delivery_types', 'parentnode__publishing_time'], period=['parentnode__parentnode', 'parentnode__parentnode__long_name', 'parentnode__parentnode__short_name'], subject=['parentnode__parentnode__parentnode', 'parentnode__parentnode__parentnode__long_name', 'parentnode__parentnode__parentnode__short_name'] ) orderbyfields = ['candidates__identifier', 'candidates__full_name', 'candidates__email'] searchfields = FieldSpec('name', '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), 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')))
class SimplifiedAssignmentMetaMixin(object): """ Defines the django model to be used, resultfields returned by search and which fields can be used to search for an Assignment object using the Simplified API """ model = models.Assignment resultfields = FieldSpec('id', 'parentnode', 'short_name', 'long_name', 'publishing_time', 'delivery_types', 'anonymous', 'scale_points_percent', period=[ 'parentnode__short_name', 'parentnode__long_name', 'parentnode__start_time', 'parentnode__end_time', 'parentnode__parentnode' ], subject=[ 'parentnode__parentnode__short_name', 'parentnode__parentnode__long_name' ]) searchfields = FieldSpec('short_name', 'long_name', 'parentnode__short_name', 'parentnode__long_name', 'parentnode__parentnode__short_name', 'parentnode__parentnode__long_name') filters = FilterSpecs( FilterSpec('parentnode'), FilterSpec('short_name'), FilterSpec('long_name'), FilterSpec('delivery_types'), FilterSpec('anonymous'), # 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')))
class Meta: model = models.RelatedStudentKeyValue methods = ['read', 'search'] resultfields = FieldSpec('relatedstudent', 'relatedstudent__period') + SimplifiedAbstractApplicationKeyValueMixin.resultfields searchfields = SimplifiedAbstractApplicationKeyValueMixin.searchfields filters = FilterSpecs(FilterSpec('relatedstudent__period', supported_comp=('exact',))) + SimplifiedAbstractApplicationKeyValueMixin.filters