onadata.apps.api.models package¶
Submodules¶
onadata.apps.api.models.odk_token module¶
ODK token model module
- class onadata.apps.api.models.odk_token.ODKToken(*args, **kwargs)¶
Bases:
Model
ODK Token class
- ACTIVE = '1'¶
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- INACTIVE = '2'¶
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- STATUS_CHOICES = (('1', 'Active'), ('2', 'Inactive'))¶
- check_key(key)¶
Check that the passed in key matches the stored hashed key
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- expires¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- generate_key()¶
Generates and returns ODK Token key encrypted with the Fernet cryptography scheme.
- get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)¶
- get_status_display(*, field=<django.db.models.fields.CharField: status>)¶
- key¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- property raw_key¶
Decrypts the key and returns it in its Raw Form
- save(*args, **kwargs)¶
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.
- status¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- user_id¶
onadata.apps.api.models.organization_profile module¶
OrganizationProfile module.
- class onadata.apps.api.models.organization_profile.OrgProfileGroupObjectPermission(*args, **kwargs)¶
Bases:
GroupObjectPermissionBase
Guardian model to create direct foreign keys.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- content_object¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- content_object_id¶
- group¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- group_id¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- permission¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- permission_id¶
- class onadata.apps.api.models.organization_profile.OrgProfileUserObjectPermission(*args, **kwargs)¶
Bases:
UserObjectPermissionBase
Guardian model to create direct foreign keys.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- content_object¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- content_object_id¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- permission¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- permission_id¶
- user¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- user_id¶
- class onadata.apps.api.models.organization_profile.OrganizationProfile(*args, **kwargs)¶
Bases:
UserProfile
Organization: Extends the user profile for organization specific info
- What does this do?
it has a createor
it has owner(s), through permissions/group
has members, through permissions/group
no login access, no password? no registration like a normal user?
created by a user who becomes the organization owner
What relationships?
- exception DoesNotExist¶
Bases:
DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- creator¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- creator_id¶
- email¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_organization¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_organization_owner(user)¶
Checks if user is in the organization owners team.
- Parameters:
user – User to check.
- Returns:
Boolean whether user has organization level permissions.
- orgprofilegroupobjectpermission_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- orgprofileuserobjectpermission_set¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- remove_user_from_organization(user)¶
Removes a user from all teams/groups in the organization.
- Parameters:
user – The user to remove from this organization.
- save(*args, **kwargs)¶
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.
- userprofile_ptr¶
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.place
is aForwardOneToOneDescriptor
instance.
- userprofile_ptr_id¶
- onadata.apps.api.models.organization_profile.add_user_to_team(team, user)¶
Adds a user to a team and assigns them team permissions.
- onadata.apps.api.models.organization_profile.create_organization_team(organization, name, permission_names=None)¶
Creates an organization team with the given permissions as defined in permission_names.
- onadata.apps.api.models.organization_profile.create_owner_team_and_assign_permissions(org)¶
Creates an Owner Team for a given organization and assigns the group and user permissions
- onadata.apps.api.models.organization_profile.get_or_create_organization_owners_team(org)¶
Get the owners team of an organization :param org: organization :return: Owners team of the organization
- onadata.apps.api.models.organization_profile.get_organization_members_team(organization)¶
Get organization members team create members team if it does not exist and add organization owner to the members team
- onadata.apps.api.models.organization_profile.org_profile_post_delete_callback(sender, instance, **kwargs)¶
Signal handler to delete the organization user object.
onadata.apps.api.models.team module¶
Team model
- class onadata.apps.api.models.team.Team(*args, **kwargs)¶
Bases:
Group
Team model based on the Group.
- exception DoesNotExist¶
Bases:
DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- OWNER_TEAM_NAME = 'Owners'¶
- created_by¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- created_by_id¶
- date_created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- date_modified¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- group_ptr¶
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.place
is aForwardOneToOneDescriptor
instance.
- group_ptr_id¶
- organization¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- organization_id¶
- projects¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- save(*args, **kwargs)¶
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.
- property team_name¶
Return the team name.
- onadata.apps.api.models.team.set_object_permissions(sender, instance=None, created=False, **kwargs)¶
Apply permissions to the creator of the team.
onadata.apps.api.models.temp_token module¶
Temporary token authorization model class
- class onadata.apps.api.models.temp_token.TempToken(*args, **kwargs)¶
Bases:
Model
The temporary authorization token model.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- created¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- generate_key()¶
Generates a token key.
- get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)¶
- key¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- save(*args, **kwargs)¶
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.
- user¶
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.place
is aForwardOneToOneDescriptor
instance.
- user_id¶
Module contents¶
API models.