Models
We have four main abstractions: Users, Collections, Memberships, and Roles.
Users represent people, like students in a school, teachers for a classroom, or volunteers setting up informal
installations. A FacilityUser
belongs to a particular facility, and has permissions only with respect to other data
that is associated with that facility. FacilityUser
accounts (like other facility data) may be synced across multiple
devices.
Collections form a hierarchy, with Collections able to belong to other Collections. Collections are subdivided
into several pre-defined levels (Facility
> Classroom
> LearnerGroup
).
A FacilityUser
(but not a DeviceOwner
) can be marked as a member of a Collection
through a Membership
object. Being a member of a Collection also means being a member of all the Collections above that Collection in the
hierarchy.
Another way in which a FacilityUser
can be associated with a particular Collection
is through a Role
object, which grants the user a role with respect to the Collection
and all the collections below it. A Role
object also stores the “kind” of the role (currently, one of “admin” or “coach”), which affects what permissions the
user gains through the Role
.
- class kolibri.core.auth.models.AbstractFacilityDataModel(*args, **kwargs)[source]
Base model for Kolibri “Facility Data”, which is data that is specific to a particular
Facility
, such asFacilityUsers
,Collections
, and other data associated with those users and collections.- Parameters:
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
dataset_id (ForeignKey to
~
) – Dataset
- cached_related_dataset_lookup(related_obj_name)[source]
Attempt to get the dataset_id either from the cache or the actual related obj instance.
- Parameters:
related_obj_name – string representing the name of the related object on this model
- Returns:
the dataset_id associated with the related obj
- calculate_source_id()[source]
Should return a string that uniquely defines the model instance or None for a random uuid.
- clean_fields(*args, **kwargs)[source]
Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
- ensure_dataset(*args, **kwargs)[source]
If no dataset has yet been specified, try to infer it. If a dataset has already been specified, to prevent inconsistencies, make sure it matches the inferred dataset, otherwise raise a
KolibriValidationError
. If we have no dataset and it can’t be inferred, we raise aKolibriValidationError
exception as well.
- full_clean(*args, **kwargs)[source]
Call clean_fields(), clean(), and validate_unique() on the model. Raise a ValidationError for any errors that occur.
- infer_dataset(*args, **kwargs)[source]
This method is used by ensure_dataset to “infer” which dataset should be associated with this instance. It should be overridden in any subclass of
AbstractFacilityDataModel
, to define a model-specific inference.
- save(*args, **kwargs)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class kolibri.core.auth.models.AdHocGroup(*args, **kwargs)[source]
An
AdHocGroup
is a collection kind that can be used in an assignment to create a group that is specific to a singleLesson
orExam
.- Parameters:
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
dataset_id (ForeignKey to
~
) – Datasetname (CharField) – Name
parent_id (ForeignKey to
~
) – Parentkind (CharField) – Kind
- exception DoesNotExist
- exception MultipleObjectsReturned
- classmethod deserialize(dict_model)[source]
Returns an unsaved class object based on the valid properties passed in.
- get_classroom()[source]
Gets the
AdHocGroup
’s parentClassroom
.- Returns:
A
Classroom
instance.
- save(*args, **kwargs)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class kolibri.core.auth.models.Classroom(id, _morango_dirty_bit, _morango_source_id, _morango_partition, dataset, name, parent, kind)[source]
- Parameters:
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
dataset_id (ForeignKey to
~
) – Datasetname (CharField) – Name
parent_id (ForeignKey to
~
) – Parentkind (CharField) – Kind
- exception DoesNotExist
- exception MultipleObjectsReturned
- get_facility()[source]
Gets the
Classroom
’s parentFacility
.- Returns:
A
Facility
instance.
- get_individual_learners_group()[source]
Returns a
QuerySet
ofAdHocGroups
.:return A
AdHocGroup
QuerySet
.
- get_learner_groups()[source]
Returns a
QuerySet
ofLearnerGroups
associated with thisClassroom
.- Returns:
A
LearnerGroup
QuerySet
.
- save(*args, **kwargs)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class kolibri.core.auth.models.Collection(*args, **kwargs)[source]
Collections
are hierarchical groups ofFacilityUsers
, used for grouping users and making decisions about permissions.FacilityUsers
can have roles for one or moreCollections
, by way of obtainingRoles
associated with thoseCollections
.Collections
can belong to otherCollections
, and user membership in aCollection
is conferred throughMemberships
.Collections
are subdivided into several pre-defined levels.- Parameters:
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
dataset_id (ForeignKey to
~
) – Datasetname (CharField) – Name
parent_id (ForeignKey to
~
) – Parentkind (CharField) – Kind
- exception DoesNotExist
- exception MultipleObjectsReturned
- add_member(user)[source]
Create a
Membership
associating the provided user with thisCollection
. If theMembership
object already exists, just return that, without changing anything.- Parameters:
user – The
FacilityUser
to add to thisCollection
.- Returns:
The
Membership
object (possibly new) that associates the user with theCollection
.
- add_role(user, role_kind)[source]
Create a
Role
associating the provided user with this collection, with the specified kind of role. If the Role object already exists, just return that, without changing anything.- Parameters:
user – The
FacilityUser
to associate with thisCollection
.role_kind – The kind of role to give the user with respect to this
Collection
.
- Returns:
The
Role
object (possibly new) that associates the user with theCollection
.
- calculate_partition()[source]
Should return a string specifying this model instance’s partition, using self.ID_PLACEHOLDER in place of its own ID, if needed.
- clean_fields(*args, **kwargs)[source]
Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
- get_admins()[source]
Returns users who have the admin role for this immediate collection.
- get_coaches()[source]
Returns users who have the coach role for this immediate collection.
- infer_dataset(*args, **kwargs)[source]
This method is used by ensure_dataset to “infer” which dataset should be associated with this instance. It should be overridden in any subclass of
AbstractFacilityDataModel
, to define a model-specific inference.
- remove_member(user)[source]
Remove any
Membership
objects associating the provided user with thisCollection
.- Parameters:
user – The
FacilityUser
to remove from thisCollection
.- Returns:
True
if aMembership
was removed,False
if there was no matchingMembership
to remove.
- remove_role(user, role_kind)[source]
Remove any
Role
objects associating the provided user with thisCollection
, with the specified kind of role.- Parameters:
user – The
FacilityUser
to dissociate from thisCollection
(for the specific role kind).role_kind – The kind of role to remove from the user with respect to this
Collection
.
- save(*args, **kwargs)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class kolibri.core.auth.models.DatasetCache[source]
- class kolibri.core.auth.models.Facility(id, _morango_dirty_bit, _morango_source_id, _morango_partition, dataset, name, parent, kind)[source]
- Parameters:
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
dataset_id (ForeignKey to
~
) – Datasetname (CharField) – Name
parent_id (ForeignKey to
~
) – Parentkind (CharField) – Kind
- exception DoesNotExist
- exception MultipleObjectsReturned
- ensure_dataset(*args, **kwargs)[source]
If no dataset has yet been specified, try to infer it. If a dataset has already been specified, to prevent inconsistencies, make sure it matches the inferred dataset, otherwise raise a
KolibriValidationError
. If we have no dataset and it can’t be inferred, we raise aKolibriValidationError
exception as well.
- get_classrooms()[source]
Returns a QuerySet of Classrooms under this Facility.
- Returns:
A Classroom QuerySet.
- infer_dataset(*args, **kwargs)[source]
This method is used by ensure_dataset to “infer” which dataset should be associated with this instance. It should be overridden in any subclass of
AbstractFacilityDataModel
, to define a model-specific inference.
- save(*args, **kwargs)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class kolibri.core.auth.models.FacilityDataSyncableModel(*args, **kwargs)[source]
- Parameters:
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
- class kolibri.core.auth.models.FacilityDataset(*args, **kwargs)[source]
FacilityDataset
stores high-level metadata and settings for a particularFacility
. It is also the model that all models storing facility data (data that is associated with a particular facility, and that inherits fromAbstractFacilityDataModel
) foreign key onto, to indicate that they belong to this particularFacility
.- Parameters:
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
description (TextField) – Description
location (CharField) – Location
preset (CharField) – Preset
learner_can_edit_username (BooleanField) – Learner can edit username
learner_can_edit_name (BooleanField) – Learner can edit name
learner_can_edit_password (BooleanField) – Learner can edit password
learner_can_sign_up (BooleanField) – Learner can sign up
learner_can_delete_account (BooleanField) – Learner can delete account
learner_can_login_with_no_password (BooleanField) – Learner can login with no password
show_download_button_in_learn (BooleanField) – Show download button in learn
extra_fields (JSONField) – Extra fields
registered (BooleanField) – Registered
- exception DoesNotExist
- exception MultipleObjectsReturned
- calculate_partition()[source]
Should return a string specifying this model instance’s partition, using self.ID_PLACEHOLDER in place of its own ID, if needed.
- calculate_source_id()[source]
Should return a string that uniquely defines the model instance or None for a random uuid.
- full_facility_import
Returns True if this user is a member of a facility that has been fully imported.
- save(*args, **kwargs)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- validate_demographic_data(demographic_data)[source]
Use the custom schema to validate demographic data being set on a FacilityUser.
- class kolibri.core.auth.models.FacilityUser(*args, **kwargs)[source]
FacilityUser
is the fundamental object of the auth app. These users represent the main users, and can be associated with a hierarchy ofCollections
throughMemberships
andRoles
, which then serve to help determine permissions.- Parameters:
password (CharField) – Password
last_login (DateTimeField) – Last login
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
dataset_id (ForeignKey to
~
) – Datasetusername (CharField) – Required. 254 characters or fewer.
full_name (CharField) – Full name
date_joined (DateTimeTzField) – Date joined
facility_id (ForeignKey to
~
) – Facilitygender (CharField) – Gender
birth_year (CharField) – Birth year
id_number (CharField) – Id number
extra_demographics (JSONField) – Extra demographics
- exception DoesNotExist
- exception MultipleObjectsReturned
- calculate_partition()[source]
Should return a string specifying this model instance’s partition, using self.ID_PLACEHOLDER in place of its own ID, if needed.
- can_create_instance(obj)[source]
Checks whether this user (self) has permission to create a particular model instance (obj).
This method should be overridden by classes that inherit from
KolibriBaseUserMixin
.In general, unless an instance has already been initialized, this method should not be called directly; instead, it should be preferred to call
can_create
.- Parameters:
obj – An (unsaved) instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to create the object, otherwiseFalse
.- Return type:
bool
- can_delete(obj)[source]
Checks whether this user (self) has permission to delete a particular model instance (obj).
This method should be overridden by classes that inherit from KolibriBaseUserMixin.
- Parameters:
obj – An instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to delete the object, otherwiseFalse
.- Return type:
bool
- property can_manage_content
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
- can_read(obj)[source]
Checks whether this user (self) has permission to read a particular model instance (obj).
This method should be overridden by classes that inherit from
KolibriBaseUserMixin
.- Parameters:
obj – An instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to read the object, otherwiseFalse
.- Return type:
bool
- can_update(obj)[source]
Checks whether this user (self) has permission to update a particular model instance (obj).
This method should be overridden by classes that inherit from KolibriBaseUserMixin.
- Parameters:
obj – An instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to update the object, otherwiseFalse
.- Return type:
bool
- classmethod deserialize(dict_model)[source]
Returns an unsaved class object based on the valid properties passed in.
- filter_readable(queryset)[source]
Filters a queryset down to only the elements that this user should have permission to read.
- Parameters:
queryset – A
QuerySet
instance that the filtering should be applied to.- Returns:
Filtered
QuerySet
including only elements that are readable by this user.
- full_facility_import
Returns True if this user is a member of a facility that has been fully imported.
- has_role_for_collection(kinds, coll)[source]
Determine whether this user has (at least one of) the specified role kind(s) in relation to the specified
Collection
.- Parameters:
kinds (string from kolibri.core.auth.constants.role_kinds.*) – The kind (or kinds) of role to check for, as a string or iterable.
coll – The target
Collection
for which this user has the roles.
- Returns:
True
if this user has the specified role kind with respect to the targetCollection
, otherwiseFalse
.- Return type:
bool
- has_role_for_user(kinds, user)[source]
Determine whether this user has (at least one of) the specified role kind(s) in relation to the specified user.
- Parameters:
user – The user that is the target of the role (for which this user has the roles).
kinds (string from
kolibri.core.auth.constants.role_kinds.*
) – The kind (or kinds) of role to check for, as a string or iterable.
- Returns:
True
if this user has the specified role kind with respect to the target user, otherwiseFalse
.- Return type:
bool
- infer_dataset(*args, **kwargs)[source]
This method is used by ensure_dataset to “infer” which dataset should be associated with this instance. It should be overridden in any subclass of
AbstractFacilityDataModel
, to define a model-specific inference.
- is_member_of(coll)[source]
Determine whether this user is a member of the specified
Collection
.- Parameters:
coll – The
Collection
for which we are checking this user’s membership.- Returns:
True
if this user is a member of the specifiedCollection
, otherwise False.- Return type:
bool
- property is_staff
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
- property is_superuser
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
- property session_data
Data that is added to the session data at login and during session updates.
- class kolibri.core.auth.models.KolibriAnonymousUser[source]
Custom anonymous user that also exposes the same interface as KolibriBaseUserMixin, for consistency.
- can_create_instance(obj)[source]
Checks whether this user (self) has permission to create a particular model instance (obj).
This method should be overridden by classes that inherit from
KolibriBaseUserMixin
.In general, unless an instance has already been initialized, this method should not be called directly; instead, it should be preferred to call
can_create
.- Parameters:
obj – An (unsaved) instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to create the object, otherwiseFalse
.- Return type:
bool
- can_delete(obj)[source]
Checks whether this user (self) has permission to delete a particular model instance (obj).
This method should be overridden by classes that inherit from KolibriBaseUserMixin.
- Parameters:
obj – An instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to delete the object, otherwiseFalse
.- Return type:
bool
- can_read(obj)[source]
Checks whether this user (self) has permission to read a particular model instance (obj).
This method should be overridden by classes that inherit from
KolibriBaseUserMixin
.- Parameters:
obj – An instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to read the object, otherwiseFalse
.- Return type:
bool
- can_update(obj)[source]
Checks whether this user (self) has permission to update a particular model instance (obj).
This method should be overridden by classes that inherit from KolibriBaseUserMixin.
- Parameters:
obj – An instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to update the object, otherwiseFalse
.- Return type:
bool
- filter_readable(queryset)[source]
Filters a queryset down to only the elements that this user should have permission to read.
- Parameters:
queryset – A
QuerySet
instance that the filtering should be applied to.- Returns:
Filtered
QuerySet
including only elements that are readable by this user.
- has_role_for_collection(kinds, coll)[source]
Determine whether this user has (at least one of) the specified role kind(s) in relation to the specified
Collection
.- Parameters:
kinds (string from kolibri.core.auth.constants.role_kinds.*) – The kind (or kinds) of role to check for, as a string or iterable.
coll – The target
Collection
for which this user has the roles.
- Returns:
True
if this user has the specified role kind with respect to the targetCollection
, otherwiseFalse
.- Return type:
bool
- has_role_for_user(kinds, user)[source]
Determine whether this user has (at least one of) the specified role kind(s) in relation to the specified user.
- Parameters:
user – The user that is the target of the role (for which this user has the roles).
kinds (string from
kolibri.core.auth.constants.role_kinds.*
) – The kind (or kinds) of role to check for, as a string or iterable.
- Returns:
True
if this user has the specified role kind with respect to the target user, otherwiseFalse
.- Return type:
bool
- is_member_of(coll)[source]
Determine whether this user is a member of the specified
Collection
.- Parameters:
coll – The
Collection
for which we are checking this user’s membership.- Returns:
True
if this user is a member of the specifiedCollection
, otherwise False.- Return type:
bool
- property session_data
Data that is added to the session data at login and during session updates.
- class kolibri.core.auth.models.KolibriBaseUserMixin[source]
This mixin is inherited by
KolibriAnonymousUser
andFacilityUser
. Use a mixin instead of an abstract base class because of difficulties with multiple inheritance and Django’sAbstractBaseUser
.- can_create(Model, data)[source]
Checks whether this user (self) has permission to create an instance of Model with the specified attributes (data).
This method defers to the
can_create_instance
method, and in most cases should not itself be overridden.- Parameters:
Model – A subclass of
django.db.models.Model
data – A
dict
of data to be used in creating an instance of the Model
- Returns:
True
if this user should have permission to create an instance of Model with the specified data, elseFalse
.- Return type:
bool
- can_create_instance(obj)[source]
Checks whether this user (self) has permission to create a particular model instance (obj).
This method should be overridden by classes that inherit from
KolibriBaseUserMixin
.In general, unless an instance has already been initialized, this method should not be called directly; instead, it should be preferred to call
can_create
.- Parameters:
obj – An (unsaved) instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to create the object, otherwiseFalse
.- Return type:
bool
- can_delete(obj)[source]
Checks whether this user (self) has permission to delete a particular model instance (obj).
This method should be overridden by classes that inherit from KolibriBaseUserMixin.
- Parameters:
obj – An instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to delete the object, otherwiseFalse
.- Return type:
bool
- can_read(obj)[source]
Checks whether this user (self) has permission to read a particular model instance (obj).
This method should be overridden by classes that inherit from
KolibriBaseUserMixin
.- Parameters:
obj – An instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to read the object, otherwiseFalse
.- Return type:
bool
- can_update(obj)[source]
Checks whether this user (self) has permission to update a particular model instance (obj).
This method should be overridden by classes that inherit from KolibriBaseUserMixin.
- Parameters:
obj – An instance of a Django model, to check permissions for.
- Returns:
True
if this user should have permission to update the object, otherwiseFalse
.- Return type:
bool
- filter_readable(queryset)[source]
Filters a queryset down to only the elements that this user should have permission to read.
- Parameters:
queryset – A
QuerySet
instance that the filtering should be applied to.- Returns:
Filtered
QuerySet
including only elements that are readable by this user.
- has_role_for(kinds, obj)[source]
Helper function that defers to
has_role_for_user
orhas_role_for_collection
based on the type of object passed in.
- has_role_for_collection(kinds, coll)[source]
Determine whether this user has (at least one of) the specified role kind(s) in relation to the specified
Collection
.- Parameters:
kinds (string from kolibri.core.auth.constants.role_kinds.*) – The kind (or kinds) of role to check for, as a string or iterable.
coll – The target
Collection
for which this user has the roles.
- Returns:
True
if this user has the specified role kind with respect to the targetCollection
, otherwiseFalse
.- Return type:
bool
- has_role_for_user(kinds, user)[source]
Determine whether this user has (at least one of) the specified role kind(s) in relation to the specified user.
- Parameters:
user – The user that is the target of the role (for which this user has the roles).
kinds (string from
kolibri.core.auth.constants.role_kinds.*
) – The kind (or kinds) of role to check for, as a string or iterable.
- Returns:
True
if this user has the specified role kind with respect to the target user, otherwiseFalse
.- Return type:
bool
- is_member_of(coll)[source]
Determine whether this user is a member of the specified
Collection
.- Parameters:
coll – The
Collection
for which we are checking this user’s membership.- Returns:
True
if this user is a member of the specifiedCollection
, otherwise False.- Return type:
bool
- property session_data
Data that is added to the session data at login and during session updates.
- class kolibri.core.auth.models.LearnerGroup(id, _morango_dirty_bit, _morango_source_id, _morango_partition, dataset, name, parent, kind)[source]
- Parameters:
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
dataset_id (ForeignKey to
~
) – Datasetname (CharField) – Name
parent_id (ForeignKey to
~
) – Parentkind (CharField) – Kind
- exception DoesNotExist
- exception MultipleObjectsReturned
- get_classroom()[source]
Gets the
LearnerGroup
’s parentClassroom
.- Returns:
A
Classroom
instance.
- save(*args, **kwargs)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class kolibri.core.auth.models.Membership(*args, **kwargs)[source]
A
FacilityUser
can be marked as a member of aCollection
through aMembership
object. Being a member of aCollection
also means being a member of all theCollections
above thatCollection
in the tree (i.e. if you are a member of aLearnerGroup
, you are also a member of theClassroom
that contains thatLearnerGroup
, and of theFacility
that contains thatClassroom
).- Parameters:
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
dataset_id (ForeignKey to
~
) – Datasetuser_id (ForeignKey to
~
) – Usercollection_id (TreeForeignKey to
~
) – Collection
- exception DoesNotExist
- exception MultipleObjectsReturned
- calculate_partition()[source]
Should return a string specifying this model instance’s partition, using self.ID_PLACEHOLDER in place of its own ID, if needed.
- calculate_source_id()[source]
Should return a string that uniquely defines the model instance or None for a random uuid.
- infer_dataset(*args, **kwargs)[source]
This method is used by ensure_dataset to “infer” which dataset should be associated with this instance. It should be overridden in any subclass of
AbstractFacilityDataModel
, to define a model-specific inference.
- save(*args, **kwargs)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class kolibri.core.auth.models.Role(*args, **kwargs)[source]
A
FacilityUser
can have a role for a particularCollection
through aRole
object, which also stores the “kind” of theRole
(currently, one of “admin” or “coach”). Having a role for aCollection
also implies having that role for all sub-collections of thatCollection
(i.e. all theCollections
below it in the tree).- Parameters:
id (UUIDField) – Id
_morango_dirty_bit (BooleanField) – morango dirty bit
_morango_source_id (CharField) – morango source id
_morango_partition (CharField) – morango partition
dataset_id (ForeignKey to
~
) – Datasetuser_id (ForeignKey to
~
) – Usercollection_id (TreeForeignKey to
~
) – Collectionkind (CharField) – Kind
- exception DoesNotExist
- exception MultipleObjectsReturned
- calculate_partition()[source]
Should return a string specifying this model instance’s partition, using self.ID_PLACEHOLDER in place of its own ID, if needed.
- calculate_source_id()[source]
Should return a string that uniquely defines the model instance or None for a random uuid.
- infer_dataset(*args, **kwargs)[source]
This method is used by ensure_dataset to “infer” which dataset should be associated with this instance. It should be overridden in any subclass of
AbstractFacilityDataModel
, to define a model-specific inference.
- save(*args, **kwargs)[source]
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.