onadata.apps.main.models package¶
Submodules¶
onadata.apps.main.models.audit module¶
-
class
onadata.apps.main.models.audit.
Audit
(id, json)¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
json
¶ 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>¶
-
exception
-
class
onadata.apps.main.models.audit.
AuditLog
(data)¶ Bases:
object
-
ACCOUNT
= 'account'¶
-
CREATED_ON
= 'created_on'¶
-
DEFAULT_BATCHSIZE
= 1000¶
-
classmethod
query_data
(username, query=None, fields=None, sort=None, start=0, limit=1000, count=False)¶
-
classmethod
query_iterator
(sql, fields=None, params=[], count=False)¶
-
save
()¶
-
onadata.apps.main.models.google_oath module¶
Google auth token storage model class
-
class
onadata.apps.main.models.google_oath.
TokenStorageModel
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Google Auth Token storage model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
credential
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
id
¶ 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.
-
id_id
¶ 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>¶
-
exception
onadata.apps.main.models.meta_data module¶
-
class
onadata.apps.main.models.meta_data.
MetaData
(id, data_type, data_value, data_file, data_file_type, file_hash, date_created, date_modified, deleted_at, content_type, object_id)¶ Bases:
django.db.models.base.Model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
content_object
¶ Provide a generic many-to-one relation through the
content_type
andobject_id
fields.This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.
-
content_type
¶ 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_type_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
data_file
¶ The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assign a file object on assignment so you can do:
>>> with open('/path/to/hello.world', 'r') as f: ... instance.file = File(f)
-
data_file_type
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
static
data_license
(content_object, data_value=None)¶
-
data_type
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
data_value
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
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.
-
deleted_at
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
static
enketo_preview_url
(content_object, data_value=None)¶
-
static
enketo_url
(content_object, data_value=None)¶
-
static
external_export
(content_object, data_value=None)¶
-
external_export_name
¶
-
external_export_template
¶
-
external_export_url
¶
-
file_hash
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
static
form_license
(content_object, data_value=None)¶
-
static
get_google_sheet_details
(obj)¶ Converts a metadata google sheet value, which contains data that is pipe separated, to a dictionary e.g ‘valueA a | valueB b’ to { ‘valueA’: ‘a’, ‘valueB’: ‘b’} :param content_object_pk: xform primary key :return dictionary containing google sheet details
-
hash
¶
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
is_linked_dataset
¶
-
static
mapbox_layer_upload
(content_object, data=None)¶
-
static
media_add_uri
(content_object, uri)¶ Add a uri as a media resource
-
static
media_upload
(content_object, data_file=None, download=False)¶
-
object_id
¶ 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>¶
-
static
public_link
(content_object, data_value=None)¶
-
static
published_by_formbuilder
(content_object, data_value=None)¶
-
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.
-
static
set_google_sheet_details
(content_object, data_value=None)¶
-
static
source
(content_object, data_value=None, data_file=None)¶
-
static
submission_review
(content_object, data_value=None)¶
-
static
supporting_docs
(content_object, data_file=None)¶
-
static
textit
(content_object, data_value=None)¶ Add a textit auth token flow uuid and default contact uuid
-
static
xform_meta_permission
(content_object, data_value=None)¶
-
exception
-
onadata.apps.main.models.meta_data.
clear_cached_metadata_instance_object
(sender, instance=None, created=False, **kwargs)¶
-
onadata.apps.main.models.meta_data.
create_media
(media)¶ Download media link
-
onadata.apps.main.models.meta_data.
get_default_content_type
()¶
-
onadata.apps.main.models.meta_data.
is_valid_url
(uri)¶
-
onadata.apps.main.models.meta_data.
media_resources
(media_list, download=False)¶ List of MetaData objects of type media
@param media_list - list of MetaData objects of type media @param download - boolean, when True downloads media files when media.data_value is a valid url
return a list of MetaData objects
-
onadata.apps.main.models.meta_data.
save_metadata
(metadata_obj)¶
-
onadata.apps.main.models.meta_data.
type_for_form
(content_object, data_type)¶
-
onadata.apps.main.models.meta_data.
unique_type_for_form
(content_object, data_type, data_value=None, data_file=None)¶ Ensure that each metadata object has unique xform and data_type fields
return the metadata object
-
onadata.apps.main.models.meta_data.
update_attached_object
(sender, instance=None, created=False, **kwargs)¶
-
onadata.apps.main.models.meta_data.
upload_to
(instance, filename)¶
onadata.apps.main.models.user_profile module¶
UserProfile model class
-
class
onadata.apps.main.models.user_profile.
UserProfile
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Userprofile model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
address
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
city
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
country
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
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
¶ 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.
-
description
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
get_country_display
(*, field=<django.db.models.fields.CharField: country>)¶
-
get_next_by_date_modified
(*, field=<django.db.models.fields.DateTimeField: date_modified>, is_next=True, **kwargs)¶
-
get_previous_by_date_modified
(*, field=<django.db.models.fields.DateTimeField: date_modified>, is_next=False, **kwargs)¶
-
gravatar
¶
-
gravatar_exists
¶
-
home_page
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
metadata
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
name
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
num_of_submissions
¶ 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>¶
-
organization
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
organizationprofile
¶ Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Place.restaurant
is aReverseOneToOneDescriptor
instance.
-
phonenumber
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
require_auth
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
save
(force_insert=False, force_update=False, using=None, update_fields=None)¶ 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.
-
submission_count
(force_update=False)¶
-
twitter
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
twitter_clean
¶
-
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
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
userprofilegroupobjectpermission_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.
-
userprofileuserobjectpermission_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.
-
exception
-
class
onadata.apps.main.models.user_profile.
UserProfileGroupObjectPermission
(*args, **kwargs)¶ Bases:
guardian.models.GroupObjectPermissionBase
Guardian model to create direct foreign keys.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.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
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
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.
-
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.
-
exception
-
class
onadata.apps.main.models.user_profile.
UserProfileUserObjectPermission
(*args, **kwargs)¶ Bases:
guardian.models.UserObjectPermissionBase
Guardian model to create direct foreign keys.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.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
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
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.
-
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.
-
exception
-
onadata.apps.main.models.user_profile.
create_auth_token
(sender, instance=None, created=False, **kwargs)¶
-
onadata.apps.main.models.user_profile.
set_kpi_formbuilder_permissions
(sender, instance=None, created=False, **kwargs)¶
-
onadata.apps.main.models.user_profile.
set_object_permissions
(sender, instance=None, created=False, **kwargs)¶