devilry.apps.administrator.simplified — Simplifed API for administrators

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

Simplified API

Node

class devilry.apps.administrator.simplified.SimplifiedNode

Bases: devilry.apps.administrator.simplified.hasadminsmixin.HasAdminsMixin, devilry.apps.administrator.simplified.cansavebase.CanSaveBase

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

class Meta

Bases: devilry.apps.administrator.simplified.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

model

alias of Node

classmethod SimplifiedNode.create_searchqryset(user)

Returns all node-objects where given user is admin or superadmin.

Parameters:user – A django user object.
Return type:a django queryset
classmethod SimplifiedNode.is_empty(obj)

Return True if the given node contains no childnodes or subjects.

classmethod SimplifiedNode.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 SimplifiedNode.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 SimplifiedNode.delete(user, pk)

Delete the given object. If the object is_empty() it can be deleted by any user with write_authorize(), if not then only a Superuser may delete the object

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

The primary key of the deleted object.

Throws PermissionDenied:
 

If the given user does not have permission to delete this object, if the object does not exist, or if the user does not have permission to recursively delete this objects and all its children.

classmethod SimplifiedNode.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 SimplifiedNode.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 SimplifiedNode.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 SimplifiedNode.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 SimplifiedNode.read_authorize(user, obj)

Check if the given user can save changes to obj, and raise PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – An object of the type this method is used in.
Throws PermissionDenied:
 
classmethod SimplifiedNode.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 SimplifiedNode.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 SimplifiedNode.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 SimplifiedNode.write_authorize(user, obj)

Check if the given user can save changes to the given obj, and raise PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – A object of the type this method is used in.
Throws PermissionDenied:
 

Subject

class devilry.apps.administrator.simplified.SimplifiedSubject

Bases: devilry.apps.administrator.simplified.hasadminsmixin.HasAdminsMixin, devilry.apps.administrator.simplified.cansavebase.CanSaveBase

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

class Meta

Bases: devilry.apps.administrator.simplified.hasadminsmixin.MetaMixin, devilry.coreutils.simplified.metabases.subject.SimplifiedSubjectMetaMixin

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

model

alias of Subject

classmethod SimplifiedSubject.is_empty(obj)

Return True if the given subject contains no periods

classmethod SimplifiedSubject.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 SimplifiedSubject.create_searchqryset(user, **kwargs)

Returns all objects of this type that matches arguments given in \*\*kwargs where user is admin or superadmin.

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.delete(user, pk)

Delete the given object. If the object is_empty() it can be deleted by any user with write_authorize(), if not then only a Superuser may delete the object

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

The primary key of the deleted object.

Throws PermissionDenied:
 

If the given user does not have permission to delete this object, if the object does not exist, or if the user does not have permission to recursively delete this objects and all its children.

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.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)

Check if the given user can save changes to obj, and raise 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.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 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 can save changes to the given obj, and raise PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – A object of the type this method is used in.
Throws PermissionDenied:
 

Period

class devilry.apps.administrator.simplified.SimplifiedPeriod

Bases: devilry.apps.administrator.simplified.hasadminsmixin.HasAdminsMixin, devilry.apps.administrator.simplified.cansavebase.CanSaveBase

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

class Meta

Bases: devilry.apps.administrator.simplified.hasadminsmixin.MetaMixin, devilry.coreutils.simplified.metabases.period.SimplifiedPeriodMetaMixin

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

model

alias of Period

classmethod SimplifiedPeriod.is_empty(obj)

Return True if the given period contains no assignments

classmethod SimplifiedPeriod.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 SimplifiedPeriod.create_searchqryset(user, **kwargs)

Returns all objects of this type that matches arguments given in \*\*kwargs where user is admin or superadmin.

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.delete(user, pk)

Delete the given object. If the object is_empty() it can be deleted by any user with write_authorize(), if not then only a Superuser may delete the object

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

The primary key of the deleted object.

Throws PermissionDenied:
 

If the given user does not have permission to delete this object, if the object does not exist, or if the user does not have permission to recursively delete this objects and all its children.

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.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)

Check if the given user can save changes to obj, and raise 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.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 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 can save changes to the given obj, and raise PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – A object of the type this method is used in.
Throws PermissionDenied:
 

Assignment

class devilry.apps.administrator.simplified.SimplifiedAssignment

Bases: devilry.apps.administrator.simplified.hasadminsmixin.HasAdminsMixin, devilry.apps.administrator.simplified.cansavebase.CanSaveBase

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

class Meta

Bases: devilry.apps.administrator.simplified.hasadminsmixin.MetaMixin, devilry.coreutils.simplified.metabases.assignment.SimplifiedAssignmentMetaMixin

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

model

alias of Assignment

classmethod SimplifiedAssignment.is_empty(obj)

Return True if the given assignment contains no assignmentgroups.

classmethod SimplifiedAssignment.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 SimplifiedAssignment.create_searchqryset(user, **kwargs)

Returns all objects of this type that matches arguments given in \*\*kwargs where user is admin or superadmin.

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.delete(user, pk)

Delete the given object. If the object is_empty() it can be deleted by any user with write_authorize(), if not then only a Superuser may delete the object

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

The primary key of the deleted object.

Throws PermissionDenied:
 

If the given user does not have permission to delete this object, if the object does not exist, or if the user does not have permission to recursively delete this objects and all its children.

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.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)

Check if the given user can save changes to obj, and raise 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.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 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 can save changes to the given obj, and raise PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – A object of the type this method is used in.
Throws PermissionDenied:
 

AssignmentGroup

class devilry.apps.administrator.simplified.SimplifiedAssignmentGroup

Bases: devilry.apps.administrator.simplified.cansavebase.CanSaveBase

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

class Meta

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

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

model

alias of AssignmentGroup

classmethod SimplifiedAssignmentGroup.create_searchqryset(user)

Returns all Deadline-objects where given user is admin or superadmin.

Parameters:user – A django user object.
Return type:a django queryset
classmethod SimplifiedAssignmentGroup.is_empty(obj)

Return True if the given assignmentgroup contains no deliveries.

classmethod SimplifiedAssignmentGroup.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 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.delete(user, pk)

Delete the given object. If the object is_empty() it can be deleted by any user with write_authorize(), if not then only a Superuser may delete the object

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

The primary key of the deleted object.

Throws PermissionDenied:
 

If the given user does not have permission to delete this object, if the object does not exist, or if the user does not have permission to recursively delete this objects and all its children.

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.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)

Check if the given user can save changes to obj, and raise 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.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 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 can save changes to the given obj, and raise PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – A object of the type this method is used in.
Throws PermissionDenied:
 

Deadline

class devilry.apps.administrator.simplified.SimplifiedDeadline

Bases: devilry.simplified.modelapi.SimplifiedModelApi

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

class Meta

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

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

model

alias of Deadline

classmethod SimplifiedDeadline.create_searchqryset(user)

Returns all Deadline-objects where given user is admin or superadmin.

Parameters:user – A django user object.
Return type:a django queryset
classmethod SimplifiedDeadline.read_authorize(user_obj, obj)

Checks if the given user is an administrator for the given Deadline obj or a superadmin, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – A Deadline object.
Throws PermissionDenied:
 
classmethod SimplifiedDeadline.write_authorize(user_obj, obj)

Checks if the given user can save changes to the AssignmentGroup of the given Deadline obj, and raises PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – A Deadline object.
Throws PermissionDenied:
 
classmethod SimplifiedDeadline.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 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.delete(user, pk)

Delete the given object. If the object is_empty() it can be deleted by any user with write_authorize(), if not then only a Superuser may delete the object

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

The primary key of the deleted object.

Throws PermissionDenied:
 

If the given user does not have permission to delete this object, if the object does not exist, or if the user does not have permission to recursively delete this objects and all its children.

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.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.

Delivery

class devilry.apps.administrator.simplified.SimplifiedDelivery

Bases: devilry.simplified.modelapi.SimplifiedModelApi

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

class Meta

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

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

model

alias of Delivery

classmethod SimplifiedDelivery.create_searchqryset(user, **kwargs)

Returns all objects of this type that matches arguments given in \*\*kwargs where user is admin or superadmin.

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

a django queryset

classmethod SimplifiedDelivery.write_authorize(user, obj)

Check if the given user can save changes to the given obj, and raise PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – A 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.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.delete(user, pk)

Delete the given object. If the object is_empty() it can be deleted by any user with write_authorize(), if not then only a Superuser may delete the object

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

The primary key of the deleted object.

Throws PermissionDenied:
 

If the given user does not have permission to delete this object, if the object does not exist, or if the user does not have permission to recursively delete this objects and all its children.

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.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 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.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.administrator.simplified.SimplifiedStaticFeedback

Bases: devilry.simplified.modelapi.SimplifiedModelApi

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

class Meta

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

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

model

alias of StaticFeedback

classmethod SimplifiedStaticFeedback.create_searchqryset(user)

Returns all StaticFeedback-objects where given user is admin or superadmin.

Parameters:user – A django user object.
Return type:a django queryset
classmethod SimplifiedStaticFeedback.write_authorize(user, obj)

Check if the given user can save changes to the given obj, and raise PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – A object of the type this method is used in.
Throws PermissionDenied:
 
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.delete(user, pk)

Delete the given object. If the object is_empty() it can be deleted by any user with write_authorize(), if not then only a Superuser may delete the object

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

The primary key of the deleted object.

Throws PermissionDenied:
 

If the given user does not have permission to delete this object, if the object does not exist, or if the user does not have permission to recursively delete this objects and all its children.

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)

Check if the given user has read permission on the given obj.

Defaults to cls.write_authorize(user, obj)

Raises PermissionDenied:
 If the given user do not have read permission on the given obj.
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.

FileMeta

class devilry.apps.administrator.simplified.SimplifiedFileMeta

Bases: devilry.simplified.modelapi.SimplifiedModelApi

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

class Meta

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

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

model

alias of FileMeta

classmethod SimplifiedFileMeta.create_searchqryset(user)

Returns all FileMeta-objects where given user is admin or superadmin.

Parameters:user – A django user object.
Return type:a django queryset
classmethod SimplifiedFileMeta.write_authorize(user, obj)

Check if the given user can save changes to the given obj, and raise PermissionDenied if not.

Parameters:
  • user – A django user object.
  • obj – A object of the type this method is used in.
Throws PermissionDenied:
 
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.delete(user, pk)

Delete the given object. If the object is_empty() it can be deleted by any user with write_authorize(), if not then only a Superuser may delete the object

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

The primary key of the deleted object.

Throws PermissionDenied:
 

If the given user does not have permission to delete this object, if the object does not exist, or if the user does not have permission to recursively delete this objects and all its children.

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)

Check if the given user has read permission on the given obj.

Defaults to cls.write_authorize(user, obj)

Raises PermissionDenied:
 If the given user do not have read permission on the given obj.
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.