onadata.libs.models package

Submodules

onadata.libs.models.base_model module

class onadata.libs.models.base_model.BaseModel(*args, **kwargs)

Bases: Model

class Meta

Bases: object

abstract = False

onadata.libs.models.clone_xform module

CloneXForm class model.

class onadata.libs.models.clone_xform.CloneXForm(xform, username, project=None)

Bases: object

The class takes an existing form’s XLSForm and publishes it as a new form.

save(**kwargs)

Publishes an exiting form’s XLSForm as a new form.

property user

Returns a User object for the given self.username.

onadata.libs.models.share_project module

ShareProject model - facilitate sharing of a project to a user.

class onadata.libs.models.share_project.ShareProject(project, username, role, remove=False)

Bases: object

Share project with a user.

save(**kwargs)

Assigns role permissions to a project for the user.

property user

Return the user object for the given self.username.

onadata.libs.models.share_project.remove_dataview_permissions(project, user, role)

Remove user permissions to all dataviews for the given project.

onadata.libs.models.share_project.remove_xform_permissions(project, user, role)

Remove user permissions to all forms for the given project.

onadata.libs.models.share_team_project module

ShareTeamProject model - facilitate sharing a project to a team.

class onadata.libs.models.share_team_project.ShareTeamProject(team, project, role, remove=False)

Bases: object

Share a project to a team for the given role.

remove_team()

Removes team permissions from a project.

save(**kwargs)

Assigns project role permissions to the team.

onadata.libs.models.share_xform module

ShareXForm model - facilitates sharing a form.

class onadata.libs.models.share_xform.ShareXForm(xform, username, role)

Bases: object

ShareXForm class to facilitate sharing a form to a user with specified role.

save(**kwargs)

Assign specified role permission to a user for the given form.

property user

Returns the user object matching self.username.

onadata.libs.models.signals module

onadata.libs.models.signals module

onadata.libs.models.signals.add_tags_to_xform_instances(sender, **kwargs)

Adds tags to an xform instance.

onadata.libs.models.signals.delete_tag_from_xform_instances(sender, **kwargs)

Deletes tags associated with an xform when it is deleted.

onadata.libs.models.sorting module

Sorting utility functions.

onadata.libs.models.sorting.json_order_by(sort_list, none_json_fields: Dict | None = None, model_name: str = '')

Returns SQL ORDER BY string portion based on JSON input.

onadata.libs.models.sorting.json_order_by_params(sort_list, none_json_fields: Dict | None = None)

Creates the ORDER BY parameters list from JSON input.

onadata.libs.models.sorting.sort_from_mongo_sort_str(sort_str)

Create a sort query list based on MongoDB sort string input.

onadata.libs.models.textit_service module

TextItService model: sets up all properties for interaction with TextIt or RapidPro.

class onadata.libs.models.textit_service.TextItService(xform, service_url=None, name=None, auth_token=None, flow_uuid=None, contacts=None, pk=None, flow_title: str = '')

Bases: object

TextItService model: access/create/update RestService and MetaData objects with all properties for TextIt or RapidPro like services.

retrieve()

Sets the textit or rapidpro properties from the MetaData object. The properties are:

  • auth_token

  • flow_uuid

  • contacts

save()

Creates and updates RestService and MetaData objects with textit or rapidpro service properties.

Module contents