devilry.apps.student.simplified — Simplifed API for students

The student simplified API. This API is a simplified wrapper of devilry.apps.core.models — Devilry core datastructure for students. Every action requires the given user to be student on the object being manipulated.

Simplified API

Subject

class devilry.apps.student.simplified.SimplifiedSubject[source]

Bases: devilry.apps.student.simplified.PublishedWhereIsCandidateMixin

Simplified wrapper for devilry.apps.core.models.Subject.

class Meta[source]

Bases: devilry.coreutils.simplified.metabases.subject.SimplifiedSubjectMetaMixin

Defines what methods a Student can use on a Subject object using the Simplified API

model

alias of Subject

classmethod SimplifiedSubject.create_searchqryset(user, **kwargs)

Returns all objects of this type that matches arguments given in \*\*kwargs where user is a student.

Parameters:
  • user – A django user object.
  • **kwargs – A dict containing search-parameters.
Return type:

a django queryset

classmethod SimplifiedSubject.createmany(user, *list_of_field_values)

Create many.

This does the same as calling create() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see create()).
Returns:List of the primary keys of the created objects.
classmethod SimplifiedSubject.deletemany(user, *list_of_pks)

Delete many.

This does the same as calling delete() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_pks List of primary-keys/ids of the objects to delete.
Returns:List of the primary keys of the deleted objects.
classmethod SimplifiedSubject.handle_fieldgroups(user, result_fieldgroups, search_fieldgroups, filters)

Can be overridden to change fieldgroups before they are sent into the QryResultWrapper. For example, if certain fieldgroups contain senstive data for anonymous assignments, we can add those fieldgroups if a filter for a specific assignment is provided in filters and that assignment is not anonymous.

Returns:(result_fieldgroups, search_fieldgroups)
classmethod SimplifiedSubject.is_empty(obj)

Check if the given obj is empty. Defaults to returning False.

Can be implemented in subclasses to enable superadmins to recursively delete() the obj.

classmethod SimplifiedSubject.post_save(user, obj)

Invoked after the obj has been saved.

Override this to set custom/generated values on obj after it has been validated and saved. The default does nothing.

classmethod SimplifiedSubject.pre_full_clean(user, obj)

Invoked after the user has been authorize by write_authorize() and before obj.full_clean() in create() and update().

Override this to set custom/generated values on obj before it is validated and saved. The default does nothing.

classmethod SimplifiedSubject.read(user, pk, result_fieldgroups=[])

Read the requested item and return a dict with the fields specified in Meta.resultfields and additional fields specified in result_fieldgroups.

Parameters:
  • user – Django user object.
  • pk – Id of object or kwargs to the get method of the configured model.
  • result_fieldgroups – Fieldgroups from the additional_fieldgroups specified in result_fieldgroups.
Throws PermissionDenied:
 

If the given user does not have permission to view this object, or if the object does not exist.

classmethod SimplifiedSubject.read_authorize(user, obj)

Checks if the given user is an student in the given obj, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – An object of the type this method is used in.
Throws PermissionDenied:
 
classmethod SimplifiedSubject.search(user, query='', start=0, limit=50, orderby=None, result_fieldgroups=None, search_fieldgroups=None, filters={}, exact_number_of_results=None)

Search for objects.

Parameters:
  • query – A string to search for within the model specified in Meta.model. The fields to search for is specified in Meta.search_fieldgroups.
  • start – Return results from this index in the results from the given query. Defaults to 0.
  • limit – Limit results to this number of items. Defaults to 50.
  • orderby – List of fieldnames. Fieldnames can be prefixed by '-' for descending ordering. Order the result by these fields. For example, if Meta.resultfields contains the short_name and long_name fields, we can order our results by ascending short_name and descending long_name as this: orderby=('short_name', '-long_name'). This defaults to cls._meta.ordering (see devilry.simplified.simplified_modelapi()).
  • result_fieldgroups – Adds additional fields to the result. Available values are the fieldgroups in Meta.resultfields.additional_fieldgroups.
  • search_fieldgroups – Adds additional fields which are searched for the query string. Available values are the fieldgroups in Meta.searchfields.additional_fieldgroups.
  • filters – List of filters that can be parsed by devilry.simplified.FilterSpec.parse().
  • exact_number_of_results – Expect this exact number of results. If unspecified (None), this check is not performed. If the check fails, devilry.simplified.InvalidNumberOfResults is raised.
Returns:

The result of the search.

Return type:

QryResultWrapper

classmethod SimplifiedSubject.updatemany(user, *list_of_field_values)

Update many.

This does the same as calling update() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see update()). Each dict _must_ have a _pk_ key that maps to the primary-key/id value.
Returns:List of the primary keys of the updated objects.
classmethod SimplifiedSubject.write_authorize(user, obj)

Check if the given user has write (update/create) permission on the given obj.

Defaults to raising :exc:NotImplementedError

Raises PermissionDenied:
 If the given user do not have write permission on the given obj.

Period

class devilry.apps.student.simplified.SimplifiedPeriod[source]

Bases: devilry.apps.student.simplified.isrelatedstudentbase.IsRelatedStudentBase

Simplified wrapper for devilry.apps.core.models.Period.

class Meta[source]

Bases: devilry.coreutils.simplified.metabases.period.SimplifiedPeriodMetaMixin

Defines what methods a Student can use on a Period object using the Simplified API

model

alias of Period

classmethod SimplifiedPeriod.create_searchqryset(user, **kwargs)

Returns all objects of this type that matches arguments given in \*\*kwargs where user is a related student.

Parameters:
  • user – A django user object.
  • **kwargs – A dict containing search-parameters.
Return type:

a django queryset

classmethod SimplifiedPeriod.createmany(user, *list_of_field_values)

Create many.

This does the same as calling create() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see create()).
Returns:List of the primary keys of the created objects.
classmethod SimplifiedPeriod.deletemany(user, *list_of_pks)

Delete many.

This does the same as calling delete() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_pks List of primary-keys/ids of the objects to delete.
Returns:List of the primary keys of the deleted objects.
classmethod SimplifiedPeriod.handle_fieldgroups(user, result_fieldgroups, search_fieldgroups, filters)

Can be overridden to change fieldgroups before they are sent into the QryResultWrapper. For example, if certain fieldgroups contain senstive data for anonymous assignments, we can add those fieldgroups if a filter for a specific assignment is provided in filters and that assignment is not anonymous.

Returns:(result_fieldgroups, search_fieldgroups)
classmethod SimplifiedPeriod.is_empty(obj)

Check if the given obj is empty. Defaults to returning False.

Can be implemented in subclasses to enable superadmins to recursively delete() the obj.

classmethod SimplifiedPeriod.post_save(user, obj)

Invoked after the obj has been saved.

Override this to set custom/generated values on obj after it has been validated and saved. The default does nothing.

classmethod SimplifiedPeriod.pre_full_clean(user, obj)

Invoked after the user has been authorize by write_authorize() and before obj.full_clean() in create() and update().

Override this to set custom/generated values on obj before it is validated and saved. The default does nothing.

classmethod SimplifiedPeriod.read(user, pk, result_fieldgroups=[])

Read the requested item and return a dict with the fields specified in Meta.resultfields and additional fields specified in result_fieldgroups.

Parameters:
  • user – Django user object.
  • pk – Id of object or kwargs to the get method of the configured model.
  • result_fieldgroups – Fieldgroups from the additional_fieldgroups specified in result_fieldgroups.
Throws PermissionDenied:
 

If the given user does not have permission to view this object, or if the object does not exist.

classmethod SimplifiedPeriod.read_authorize(user, obj)

Checks if the given user is an student in the given obj, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – An object of the type this method is used in.
Throws PermissionDenied:
 
classmethod SimplifiedPeriod.search(user, query='', start=0, limit=50, orderby=None, result_fieldgroups=None, search_fieldgroups=None, filters={}, exact_number_of_results=None)

Search for objects.

Parameters:
  • query – A string to search for within the model specified in Meta.model. The fields to search for is specified in Meta.search_fieldgroups.
  • start – Return results from this index in the results from the given query. Defaults to 0.
  • limit – Limit results to this number of items. Defaults to 50.
  • orderby – List of fieldnames. Fieldnames can be prefixed by '-' for descending ordering. Order the result by these fields. For example, if Meta.resultfields contains the short_name and long_name fields, we can order our results by ascending short_name and descending long_name as this: orderby=('short_name', '-long_name'). This defaults to cls._meta.ordering (see devilry.simplified.simplified_modelapi()).
  • result_fieldgroups – Adds additional fields to the result. Available values are the fieldgroups in Meta.resultfields.additional_fieldgroups.
  • search_fieldgroups – Adds additional fields which are searched for the query string. Available values are the fieldgroups in Meta.searchfields.additional_fieldgroups.
  • filters – List of filters that can be parsed by devilry.simplified.FilterSpec.parse().
  • exact_number_of_results – Expect this exact number of results. If unspecified (None), this check is not performed. If the check fails, devilry.simplified.InvalidNumberOfResults is raised.
Returns:

The result of the search.

Return type:

QryResultWrapper

classmethod SimplifiedPeriod.updatemany(user, *list_of_field_values)

Update many.

This does the same as calling update() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see update()). Each dict _must_ have a _pk_ key that maps to the primary-key/id value.
Returns:List of the primary keys of the updated objects.
classmethod SimplifiedPeriod.write_authorize(user, obj)

Check if the given user has write (update/create) permission on the given obj.

Defaults to raising :exc:NotImplementedError

Raises PermissionDenied:
 If the given user do not have write permission on the given obj.

Assignment

class devilry.apps.student.simplified.SimplifiedAssignment[source]

Bases: devilry.apps.student.simplified.PublishedWhereIsCandidateMixin

Simplified wrapper for devilry.apps.core.models.Assignment.

class Meta[source]

Bases: devilry.coreutils.simplified.metabases.assignment.SimplifiedAssignmentMetaMixin

Defines what methods a Student can use on an Assignment object using the Simplified API

model

alias of Assignment

classmethod SimplifiedAssignment.create_searchqryset(user, **kwargs)

Returns all objects of this type that matches arguments given in \*\*kwargs where user is a student.

Parameters:
  • user – A django user object.
  • **kwargs – A dict containing search-parameters.
Return type:

a django queryset

classmethod SimplifiedAssignment.createmany(user, *list_of_field_values)

Create many.

This does the same as calling create() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see create()).
Returns:List of the primary keys of the created objects.
classmethod SimplifiedAssignment.deletemany(user, *list_of_pks)

Delete many.

This does the same as calling delete() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_pks List of primary-keys/ids of the objects to delete.
Returns:List of the primary keys of the deleted objects.
classmethod SimplifiedAssignment.handle_fieldgroups(user, result_fieldgroups, search_fieldgroups, filters)

Can be overridden to change fieldgroups before they are sent into the QryResultWrapper. For example, if certain fieldgroups contain senstive data for anonymous assignments, we can add those fieldgroups if a filter for a specific assignment is provided in filters and that assignment is not anonymous.

Returns:(result_fieldgroups, search_fieldgroups)
classmethod SimplifiedAssignment.is_empty(obj)

Check if the given obj is empty. Defaults to returning False.

Can be implemented in subclasses to enable superadmins to recursively delete() the obj.

classmethod SimplifiedAssignment.post_save(user, obj)

Invoked after the obj has been saved.

Override this to set custom/generated values on obj after it has been validated and saved. The default does nothing.

classmethod SimplifiedAssignment.pre_full_clean(user, obj)

Invoked after the user has been authorize by write_authorize() and before obj.full_clean() in create() and update().

Override this to set custom/generated values on obj before it is validated and saved. The default does nothing.

classmethod SimplifiedAssignment.read(user, pk, result_fieldgroups=[])

Read the requested item and return a dict with the fields specified in Meta.resultfields and additional fields specified in result_fieldgroups.

Parameters:
  • user – Django user object.
  • pk – Id of object or kwargs to the get method of the configured model.
  • result_fieldgroups – Fieldgroups from the additional_fieldgroups specified in result_fieldgroups.
Throws PermissionDenied:
 

If the given user does not have permission to view this object, or if the object does not exist.

classmethod SimplifiedAssignment.read_authorize(user, obj)

Checks if the given user is an student in the given obj, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – An object of the type this method is used in.
Throws PermissionDenied:
 
classmethod SimplifiedAssignment.search(user, query='', start=0, limit=50, orderby=None, result_fieldgroups=None, search_fieldgroups=None, filters={}, exact_number_of_results=None)

Search for objects.

Parameters:
  • query – A string to search for within the model specified in Meta.model. The fields to search for is specified in Meta.search_fieldgroups.
  • start – Return results from this index in the results from the given query. Defaults to 0.
  • limit – Limit results to this number of items. Defaults to 50.
  • orderby – List of fieldnames. Fieldnames can be prefixed by '-' for descending ordering. Order the result by these fields. For example, if Meta.resultfields contains the short_name and long_name fields, we can order our results by ascending short_name and descending long_name as this: orderby=('short_name', '-long_name'). This defaults to cls._meta.ordering (see devilry.simplified.simplified_modelapi()).
  • result_fieldgroups – Adds additional fields to the result. Available values are the fieldgroups in Meta.resultfields.additional_fieldgroups.
  • search_fieldgroups – Adds additional fields which are searched for the query string. Available values are the fieldgroups in Meta.searchfields.additional_fieldgroups.
  • filters – List of filters that can be parsed by devilry.simplified.FilterSpec.parse().
  • exact_number_of_results – Expect this exact number of results. If unspecified (None), this check is not performed. If the check fails, devilry.simplified.InvalidNumberOfResults is raised.
Returns:

The result of the search.

Return type:

QryResultWrapper

classmethod SimplifiedAssignment.updatemany(user, *list_of_field_values)

Update many.

This does the same as calling update() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see update()). Each dict _must_ have a _pk_ key that maps to the primary-key/id value.
Returns:List of the primary keys of the updated objects.
classmethod SimplifiedAssignment.write_authorize(user, obj)

Check if the given user has write (update/create) permission on the given obj.

Defaults to raising :exc:NotImplementedError

Raises PermissionDenied:
 If the given user do not have write permission on the given obj.

AssignmentGroup

class devilry.apps.student.simplified.SimplifiedAssignmentGroup[source]

Bases: devilry.apps.student.simplified.PublishedWhereIsCandidateMixin

Simplified wrapper for devilry.apps.core.models.AssignmentGroup.

class Meta[source]

Bases: devilry.coreutils.simplified.metabases.assignment_group.SimplifiedAssignmentGroupMetaMixin

Defines what methods a Student can use on an AssignmentGroup object using the Simplified API

model

alias of AssignmentGroup

classmethod SimplifiedAssignmentGroup.create_searchqryset(user)[source]

Returns all AssignmentGroup-objects where given user is candidate.

Parameters:user – A django user object.
Return type:a django queryset
classmethod SimplifiedAssignmentGroup.createmany(user, *list_of_field_values)

Create many.

This does the same as calling create() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see create()).
Returns:List of the primary keys of the created objects.
classmethod SimplifiedAssignmentGroup.deletemany(user, *list_of_pks)

Delete many.

This does the same as calling delete() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_pks List of primary-keys/ids of the objects to delete.
Returns:List of the primary keys of the deleted objects.
classmethod SimplifiedAssignmentGroup.handle_fieldgroups(user, result_fieldgroups, search_fieldgroups, filters)

Can be overridden to change fieldgroups before they are sent into the QryResultWrapper. For example, if certain fieldgroups contain senstive data for anonymous assignments, we can add those fieldgroups if a filter for a specific assignment is provided in filters and that assignment is not anonymous.

Returns:(result_fieldgroups, search_fieldgroups)
classmethod SimplifiedAssignmentGroup.is_empty(obj)

Check if the given obj is empty. Defaults to returning False.

Can be implemented in subclasses to enable superadmins to recursively delete() the obj.

classmethod SimplifiedAssignmentGroup.post_save(user, obj)

Invoked after the obj has been saved.

Override this to set custom/generated values on obj after it has been validated and saved. The default does nothing.

classmethod SimplifiedAssignmentGroup.pre_full_clean(user, obj)

Invoked after the user has been authorize by write_authorize() and before obj.full_clean() in create() and update().

Override this to set custom/generated values on obj before it is validated and saved. The default does nothing.

classmethod SimplifiedAssignmentGroup.read(user, pk, result_fieldgroups=[])

Read the requested item and return a dict with the fields specified in Meta.resultfields and additional fields specified in result_fieldgroups.

Parameters:
  • user – Django user object.
  • pk – Id of object or kwargs to the get method of the configured model.
  • result_fieldgroups – Fieldgroups from the additional_fieldgroups specified in result_fieldgroups.
Throws PermissionDenied:
 

If the given user does not have permission to view this object, or if the object does not exist.

classmethod SimplifiedAssignmentGroup.read_authorize(user, obj)

Checks if the given user is an student in the given obj, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – An object of the type this method is used in.
Throws PermissionDenied:
 
classmethod SimplifiedAssignmentGroup.search(user, query='', start=0, limit=50, orderby=None, result_fieldgroups=None, search_fieldgroups=None, filters={}, exact_number_of_results=None)

Search for objects.

Parameters:
  • query – A string to search for within the model specified in Meta.model. The fields to search for is specified in Meta.search_fieldgroups.
  • start – Return results from this index in the results from the given query. Defaults to 0.
  • limit – Limit results to this number of items. Defaults to 50.
  • orderby – List of fieldnames. Fieldnames can be prefixed by '-' for descending ordering. Order the result by these fields. For example, if Meta.resultfields contains the short_name and long_name fields, we can order our results by ascending short_name and descending long_name as this: orderby=('short_name', '-long_name'). This defaults to cls._meta.ordering (see devilry.simplified.simplified_modelapi()).
  • result_fieldgroups – Adds additional fields to the result. Available values are the fieldgroups in Meta.resultfields.additional_fieldgroups.
  • search_fieldgroups – Adds additional fields which are searched for the query string. Available values are the fieldgroups in Meta.searchfields.additional_fieldgroups.
  • filters – List of filters that can be parsed by devilry.simplified.FilterSpec.parse().
  • exact_number_of_results – Expect this exact number of results. If unspecified (None), this check is not performed. If the check fails, devilry.simplified.InvalidNumberOfResults is raised.
Returns:

The result of the search.

Return type:

QryResultWrapper

classmethod SimplifiedAssignmentGroup.updatemany(user, *list_of_field_values)

Update many.

This does the same as calling update() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see update()). Each dict _must_ have a _pk_ key that maps to the primary-key/id value.
Returns:List of the primary keys of the updated objects.
classmethod SimplifiedAssignmentGroup.write_authorize(user, obj)

Check if the given user has write (update/create) permission on the given obj.

Defaults to raising :exc:NotImplementedError

Raises PermissionDenied:
 If the given user do not have write permission on the given obj.

Deadline

class devilry.apps.student.simplified.SimplifiedDeadline[source]

Bases: devilry.apps.student.simplified.PublishedWhereIsCandidateMixin

Simplified wrapper for devilry.apps.core.models.Deadline.

class Meta[source]

Bases: devilry.coreutils.simplified.metabases.deadline.SimplifiedDeadlineMetaMixin

Defines what methods a Student can use on a Deadline object using the Simplified API

model

alias of Deadline

classmethod SimplifiedDeadline.createmany(user, *list_of_field_values)

Create many.

This does the same as calling create() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see create()).
Returns:List of the primary keys of the created objects.
classmethod SimplifiedDeadline.deletemany(user, *list_of_pks)

Delete many.

This does the same as calling delete() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_pks List of primary-keys/ids of the objects to delete.
Returns:List of the primary keys of the deleted objects.
classmethod SimplifiedDeadline.handle_fieldgroups(user, result_fieldgroups, search_fieldgroups, filters)

Can be overridden to change fieldgroups before they are sent into the QryResultWrapper. For example, if certain fieldgroups contain senstive data for anonymous assignments, we can add those fieldgroups if a filter for a specific assignment is provided in filters and that assignment is not anonymous.

Returns:(result_fieldgroups, search_fieldgroups)
classmethod SimplifiedDeadline.is_empty(obj)

Check if the given obj is empty. Defaults to returning False.

Can be implemented in subclasses to enable superadmins to recursively delete() the obj.

classmethod SimplifiedDeadline.post_save(user, obj)

Invoked after the obj has been saved.

Override this to set custom/generated values on obj after it has been validated and saved. The default does nothing.

classmethod SimplifiedDeadline.pre_full_clean(user, obj)

Invoked after the user has been authorize by write_authorize() and before obj.full_clean() in create() and update().

Override this to set custom/generated values on obj before it is validated and saved. The default does nothing.

classmethod SimplifiedDeadline.read(user, pk, result_fieldgroups=[])

Read the requested item and return a dict with the fields specified in Meta.resultfields and additional fields specified in result_fieldgroups.

Parameters:
  • user – Django user object.
  • pk – Id of object or kwargs to the get method of the configured model.
  • result_fieldgroups – Fieldgroups from the additional_fieldgroups specified in result_fieldgroups.
Throws PermissionDenied:
 

If the given user does not have permission to view this object, or if the object does not exist.

classmethod SimplifiedDeadline.read_authorize(user, obj)

Checks if the given user is an student in the given obj, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – An object of the type this method is used in.
Throws PermissionDenied:
 
classmethod SimplifiedDeadline.search(user, query='', start=0, limit=50, orderby=None, result_fieldgroups=None, search_fieldgroups=None, filters={}, exact_number_of_results=None)

Search for objects.

Parameters:
  • query – A string to search for within the model specified in Meta.model. The fields to search for is specified in Meta.search_fieldgroups.
  • start – Return results from this index in the results from the given query. Defaults to 0.
  • limit – Limit results to this number of items. Defaults to 50.
  • orderby – List of fieldnames. Fieldnames can be prefixed by '-' for descending ordering. Order the result by these fields. For example, if Meta.resultfields contains the short_name and long_name fields, we can order our results by ascending short_name and descending long_name as this: orderby=('short_name', '-long_name'). This defaults to cls._meta.ordering (see devilry.simplified.simplified_modelapi()).
  • result_fieldgroups – Adds additional fields to the result. Available values are the fieldgroups in Meta.resultfields.additional_fieldgroups.
  • search_fieldgroups – Adds additional fields which are searched for the query string. Available values are the fieldgroups in Meta.searchfields.additional_fieldgroups.
  • filters – List of filters that can be parsed by devilry.simplified.FilterSpec.parse().
  • exact_number_of_results – Expect this exact number of results. If unspecified (None), this check is not performed. If the check fails, devilry.simplified.InvalidNumberOfResults is raised.
Returns:

The result of the search.

Return type:

QryResultWrapper

classmethod SimplifiedDeadline.updatemany(user, *list_of_field_values)

Update many.

This does the same as calling update() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see update()). Each dict _must_ have a _pk_ key that maps to the primary-key/id value.
Returns:List of the primary keys of the updated objects.
classmethod SimplifiedDeadline.write_authorize(user, obj)

Check if the given user has write (update/create) permission on the given obj.

Defaults to raising :exc:NotImplementedError

Raises PermissionDenied:
 If the given user do not have write permission on the given obj.

Delivery

class devilry.apps.student.simplified.SimplifiedDelivery[source]

Bases: devilry.apps.student.simplified.PublishedWhereIsCandidateMixin

Simplified wrapper for devilry.apps.core.models.Delivery.

class Meta[source]

Bases: devilry.coreutils.simplified.metabases.delivery.SimplifiedDeliveryMetaMixin

Defines what methods a Student can use on a Delivery object using the Simplified API

model

alias of Delivery

classmethod SimplifiedDelivery.write_authorize(user, obj)[source]

Checks if the given user is an student in the given obj, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – An object of the type this method is used in.
Throws PermissionDenied:
 
classmethod SimplifiedDelivery.create(user, **field_values)

Create the given object.

Parameters:user – Django user object.
Field_values :The values to set on the given object.
Returns:The primary key of the newly created object.
Throws PermissionDenied:
 If the given user does not have permission to edit this object, if the object does not exist, or if any of the field_values is not in cls._meta.editablefields.
classmethod SimplifiedDelivery.create_searchqryset(user, **kwargs)

Returns all objects of this type that matches arguments given in \*\*kwargs where user is a student.

Parameters:
  • user – A django user object.
  • **kwargs – A dict containing search-parameters.
Return type:

a django queryset

classmethod SimplifiedDelivery.createmany(user, *list_of_field_values)

Create many.

This does the same as calling create() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see create()).
Returns:List of the primary keys of the created objects.
classmethod SimplifiedDelivery.deletemany(user, *list_of_pks)

Delete many.

This does the same as calling delete() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_pks List of primary-keys/ids of the objects to delete.
Returns:List of the primary keys of the deleted objects.
classmethod SimplifiedDelivery.handle_fieldgroups(user, result_fieldgroups, search_fieldgroups, filters)

Can be overridden to change fieldgroups before they are sent into the QryResultWrapper. For example, if certain fieldgroups contain senstive data for anonymous assignments, we can add those fieldgroups if a filter for a specific assignment is provided in filters and that assignment is not anonymous.

Returns:(result_fieldgroups, search_fieldgroups)
classmethod SimplifiedDelivery.is_empty(obj)

Check if the given obj is empty. Defaults to returning False.

Can be implemented in subclasses to enable superadmins to recursively delete() the obj.

classmethod SimplifiedDelivery.read(user, pk, result_fieldgroups=[])

Read the requested item and return a dict with the fields specified in Meta.resultfields and additional fields specified in result_fieldgroups.

Parameters:
  • user – Django user object.
  • pk – Id of object or kwargs to the get method of the configured model.
  • result_fieldgroups – Fieldgroups from the additional_fieldgroups specified in result_fieldgroups.
Throws PermissionDenied:
 

If the given user does not have permission to view this object, or if the object does not exist.

classmethod SimplifiedDelivery.read_authorize(user, obj)

Checks if the given user is an student in the given obj, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – An object of the type this method is used in.
Throws PermissionDenied:
 
classmethod SimplifiedDelivery.search(user, query='', start=0, limit=50, orderby=None, result_fieldgroups=None, search_fieldgroups=None, filters={}, exact_number_of_results=None)

Search for objects.

Parameters:
  • query – A string to search for within the model specified in Meta.model. The fields to search for is specified in Meta.search_fieldgroups.
  • start – Return results from this index in the results from the given query. Defaults to 0.
  • limit – Limit results to this number of items. Defaults to 50.
  • orderby – List of fieldnames. Fieldnames can be prefixed by '-' for descending ordering. Order the result by these fields. For example, if Meta.resultfields contains the short_name and long_name fields, we can order our results by ascending short_name and descending long_name as this: orderby=('short_name', '-long_name'). This defaults to cls._meta.ordering (see devilry.simplified.simplified_modelapi()).
  • result_fieldgroups – Adds additional fields to the result. Available values are the fieldgroups in Meta.resultfields.additional_fieldgroups.
  • search_fieldgroups – Adds additional fields which are searched for the query string. Available values are the fieldgroups in Meta.searchfields.additional_fieldgroups.
  • filters – List of filters that can be parsed by devilry.simplified.FilterSpec.parse().
  • exact_number_of_results – Expect this exact number of results. If unspecified (None), this check is not performed. If the check fails, devilry.simplified.InvalidNumberOfResults is raised.
Returns:

The result of the search.

Return type:

QryResultWrapper

classmethod SimplifiedDelivery.update(user, pk, **field_values)

Update the given object.

Parameters:
  • user – Django user object.
  • pk – Id of object or kwargs to the get method of the configured model.
Param :

field_values: The values to set on the given object.

Returns:

The primary key of the updated object.

Throws PermissionDenied:
 

If the given user does not have permission to edit this object, if the object does not exist, or if any of the field_values is not in cls._meta.editablefields.

classmethod SimplifiedDelivery.updatemany(user, *list_of_field_values)

Update many.

This does the same as calling update() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see update()). Each dict _must_ have a _pk_ key that maps to the primary-key/id value.
Returns:List of the primary keys of the updated objects.

StaticFeedback

class devilry.apps.student.simplified.SimplifiedStaticFeedback[source]

Bases: devilry.apps.student.simplified.PublishedWhereIsCandidateMixin

Simplified wrapper for devilry.apps.core.models.StaticFeedback.

class Meta[source]

Bases: devilry.coreutils.simplified.metabases.staticfeedback.SimplifiedStaticFeedbackMetaMixin

Defines what methods a Student can use on a StaticFeedback object using the Simplified API

model

alias of StaticFeedback

classmethod SimplifiedStaticFeedback.create_searchqryset(user, **kwargs)

Returns all objects of this type that matches arguments given in \*\*kwargs where user is a student.

Parameters:
  • user – A django user object.
  • **kwargs – A dict containing search-parameters.
Return type:

a django queryset

classmethod SimplifiedStaticFeedback.createmany(user, *list_of_field_values)

Create many.

This does the same as calling create() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see create()).
Returns:List of the primary keys of the created objects.
classmethod SimplifiedStaticFeedback.deletemany(user, *list_of_pks)

Delete many.

This does the same as calling delete() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_pks List of primary-keys/ids of the objects to delete.
Returns:List of the primary keys of the deleted objects.
classmethod SimplifiedStaticFeedback.handle_fieldgroups(user, result_fieldgroups, search_fieldgroups, filters)

Can be overridden to change fieldgroups before they are sent into the QryResultWrapper. For example, if certain fieldgroups contain senstive data for anonymous assignments, we can add those fieldgroups if a filter for a specific assignment is provided in filters and that assignment is not anonymous.

Returns:(result_fieldgroups, search_fieldgroups)
classmethod SimplifiedStaticFeedback.is_empty(obj)

Check if the given obj is empty. Defaults to returning False.

Can be implemented in subclasses to enable superadmins to recursively delete() the obj.

classmethod SimplifiedStaticFeedback.post_save(user, obj)

Invoked after the obj has been saved.

Override this to set custom/generated values on obj after it has been validated and saved. The default does nothing.

classmethod SimplifiedStaticFeedback.pre_full_clean(user, obj)

Invoked after the user has been authorize by write_authorize() and before obj.full_clean() in create() and update().

Override this to set custom/generated values on obj before it is validated and saved. The default does nothing.

classmethod SimplifiedStaticFeedback.read(user, pk, result_fieldgroups=[])

Read the requested item and return a dict with the fields specified in Meta.resultfields and additional fields specified in result_fieldgroups.

Parameters:
  • user – Django user object.
  • pk – Id of object or kwargs to the get method of the configured model.
  • result_fieldgroups – Fieldgroups from the additional_fieldgroups specified in result_fieldgroups.
Throws PermissionDenied:
 

If the given user does not have permission to view this object, or if the object does not exist.

classmethod SimplifiedStaticFeedback.read_authorize(user, obj)

Checks if the given user is an student in the given obj, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – An object of the type this method is used in.
Throws PermissionDenied:
 
classmethod SimplifiedStaticFeedback.search(user, query='', start=0, limit=50, orderby=None, result_fieldgroups=None, search_fieldgroups=None, filters={}, exact_number_of_results=None)

Search for objects.

Parameters:
  • query – A string to search for within the model specified in Meta.model. The fields to search for is specified in Meta.search_fieldgroups.
  • start – Return results from this index in the results from the given query. Defaults to 0.
  • limit – Limit results to this number of items. Defaults to 50.
  • orderby – List of fieldnames. Fieldnames can be prefixed by '-' for descending ordering. Order the result by these fields. For example, if Meta.resultfields contains the short_name and long_name fields, we can order our results by ascending short_name and descending long_name as this: orderby=('short_name', '-long_name'). This defaults to cls._meta.ordering (see devilry.simplified.simplified_modelapi()).
  • result_fieldgroups – Adds additional fields to the result. Available values are the fieldgroups in Meta.resultfields.additional_fieldgroups.
  • search_fieldgroups – Adds additional fields which are searched for the query string. Available values are the fieldgroups in Meta.searchfields.additional_fieldgroups.
  • filters – List of filters that can be parsed by devilry.simplified.FilterSpec.parse().
  • exact_number_of_results – Expect this exact number of results. If unspecified (None), this check is not performed. If the check fails, devilry.simplified.InvalidNumberOfResults is raised.
Returns:

The result of the search.

Return type:

QryResultWrapper

classmethod SimplifiedStaticFeedback.updatemany(user, *list_of_field_values)

Update many.

This does the same as calling update() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see update()). Each dict _must_ have a _pk_ key that maps to the primary-key/id value.
Returns:List of the primary keys of the updated objects.
classmethod SimplifiedStaticFeedback.write_authorize(user, obj)

Check if the given user has write (update/create) permission on the given obj.

Defaults to raising :exc:NotImplementedError

Raises PermissionDenied:
 If the given user do not have write permission on the given obj.

FileMeta

class devilry.apps.student.simplified.SimplifiedFileMeta[source]

Bases: devilry.apps.student.simplified.PublishedWhereIsCandidateMixin

Simplified wrapper for devilry.apps.core.models.FileMeta.

class Meta[source]

Bases: devilry.coreutils.simplified.metabases.filemeta.SimplifiedFileMetaMetaMixin

Defines what methods a Student can use on a FileMeta object using the Simplified API

model

alias of FileMeta

classmethod SimplifiedFileMeta.create(user, **field_values)

Create the given object.

Parameters:user – Django user object.
Field_values :The values to set on the given object.
Returns:The primary key of the newly created object.
Throws PermissionDenied:
 If the given user does not have permission to edit this object, if the object does not exist, or if any of the field_values is not in cls._meta.editablefields.
classmethod SimplifiedFileMeta.create_searchqryset(user, **kwargs)

Returns all objects of this type that matches arguments given in \*\*kwargs where user is a student.

Parameters:
  • user – A django user object.
  • **kwargs – A dict containing search-parameters.
Return type:

a django queryset

classmethod SimplifiedFileMeta.createmany(user, *list_of_field_values)

Create many.

This does the same as calling create() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see create()).
Returns:List of the primary keys of the created objects.
classmethod SimplifiedFileMeta.deletemany(user, *list_of_pks)

Delete many.

This does the same as calling delete() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_pks List of primary-keys/ids of the objects to delete.
Returns:List of the primary keys of the deleted objects.
classmethod SimplifiedFileMeta.handle_fieldgroups(user, result_fieldgroups, search_fieldgroups, filters)

Can be overridden to change fieldgroups before they are sent into the QryResultWrapper. For example, if certain fieldgroups contain senstive data for anonymous assignments, we can add those fieldgroups if a filter for a specific assignment is provided in filters and that assignment is not anonymous.

Returns:(result_fieldgroups, search_fieldgroups)
classmethod SimplifiedFileMeta.is_empty(obj)

Check if the given obj is empty. Defaults to returning False.

Can be implemented in subclasses to enable superadmins to recursively delete() the obj.

classmethod SimplifiedFileMeta.post_save(user, obj)

Invoked after the obj has been saved.

Override this to set custom/generated values on obj after it has been validated and saved. The default does nothing.

classmethod SimplifiedFileMeta.pre_full_clean(user, obj)

Invoked after the user has been authorize by write_authorize() and before obj.full_clean() in create() and update().

Override this to set custom/generated values on obj before it is validated and saved. The default does nothing.

classmethod SimplifiedFileMeta.read(user, pk, result_fieldgroups=[])

Read the requested item and return a dict with the fields specified in Meta.resultfields and additional fields specified in result_fieldgroups.

Parameters:
  • user – Django user object.
  • pk – Id of object or kwargs to the get method of the configured model.
  • result_fieldgroups – Fieldgroups from the additional_fieldgroups specified in result_fieldgroups.
Throws PermissionDenied:
 

If the given user does not have permission to view this object, or if the object does not exist.

classmethod SimplifiedFileMeta.read_authorize(user, obj)

Checks if the given user is an student in the given obj, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – An object of the type this method is used in.
Throws PermissionDenied:
 
classmethod SimplifiedFileMeta.search(user, query='', start=0, limit=50, orderby=None, result_fieldgroups=None, search_fieldgroups=None, filters={}, exact_number_of_results=None)

Search for objects.

Parameters:
  • query – A string to search for within the model specified in Meta.model. The fields to search for is specified in Meta.search_fieldgroups.
  • start – Return results from this index in the results from the given query. Defaults to 0.
  • limit – Limit results to this number of items. Defaults to 50.
  • orderby – List of fieldnames. Fieldnames can be prefixed by '-' for descending ordering. Order the result by these fields. For example, if Meta.resultfields contains the short_name and long_name fields, we can order our results by ascending short_name and descending long_name as this: orderby=('short_name', '-long_name'). This defaults to cls._meta.ordering (see devilry.simplified.simplified_modelapi()).
  • result_fieldgroups – Adds additional fields to the result. Available values are the fieldgroups in Meta.resultfields.additional_fieldgroups.
  • search_fieldgroups – Adds additional fields which are searched for the query string. Available values are the fieldgroups in Meta.searchfields.additional_fieldgroups.
  • filters – List of filters that can be parsed by devilry.simplified.FilterSpec.parse().
  • exact_number_of_results – Expect this exact number of results. If unspecified (None), this check is not performed. If the check fails, devilry.simplified.InvalidNumberOfResults is raised.
Returns:

The result of the search.

Return type:

QryResultWrapper

classmethod SimplifiedFileMeta.updatemany(user, *list_of_field_values)

Update many.

This does the same as calling update() many times, except that it does it all in a single transaction. This means that the database rolls back the changes unless they all succeed.

Param :list_of_field_values List of field_values dicts (see update()). Each dict _must_ have a _pk_ key that maps to the primary-key/id value.
Returns:List of the primary keys of the updated objects.
classmethod SimplifiedFileMeta.write_authorize(user, obj)

Check if the given user has write (update/create) permission on the given obj.

Defaults to raising :exc:NotImplementedError

Raises PermissionDenied:
 If the given user do not have write permission on the given obj.