onadata.libs.mixins package

Submodules

onadata.libs.mixins.anonymous_user_mixin module

class onadata.libs.mixins.anonymous_user_mixin.AnonymousUserMixin

Bases: object

get_queryset()

Set AnonymousUser from the database to allow object permissions.

onadata.libs.mixins.anonymous_user_public_forms_mixin module

class onadata.libs.mixins.anonymous_user_public_forms_mixin.AnonymousUserPublicFormsMixin

Bases: object

get_queryset()

Public forms only for anonymous Users.

onadata.libs.mixins.authenticate_header_mixin module

class onadata.libs.mixins.authenticate_header_mixin.AuthenticateHeaderMixin

Bases: object

get_authenticate_header(request)

onadata.libs.mixins.cache_control_mixin module

class onadata.libs.mixins.cache_control_mixin.CacheControlMixin

Bases: object

finalize_response(request, response, *args, **kwargs)
set_cache_control(response, max_age=60)

onadata.libs.mixins.etags_mixin module

class onadata.libs.mixins.etags_mixin.ETagsMixin

Bases: object

Applies the Etag on GET responses with status code 200, 201, 202

self.etag_data - if it is set, the etag is calculated from this data,
otherwise the date_modifed of self.object or self.object_list is used.
finalize_response(request, response, *args, **kwargs)
set_etag_header(etag_value, etag_hash=None)

onadata.libs.mixins.labels_mixin module

class onadata.libs.mixins.labels_mixin.LabelsMixin

Bases: object

labels(request, format='json', **kwargs)
class onadata.libs.mixins.labels_mixin.TagForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)

Bases: django.forms.forms.Form

base_fields = {'tags': <taggit.forms.TagField object>}
declared_fields = {'tags': <taggit.forms.TagField object>}
media
onadata.libs.mixins.labels_mixin.process_label_request(request, label, instance)

Process request to labels endpoint.

Parameters:
  • request – HTTP request object.
  • label – label that is being acted on.
  • instance – object that label is applied to.
Returns:

A response object based on the type of request.

onadata.libs.mixins.last_modified_mixin module

class onadata.libs.mixins.last_modified_mixin.LastModifiedMixin

Bases: object

finalize_response(request, response, *args, **kwargs)
last_modified_date = None
last_modified_field = 'modified'

onadata.libs.mixins.multi_lookup_mixin module

class onadata.libs.mixins.multi_lookup_mixin.MultiLookupMixin

Bases: object

get_object(queryset=None)

onadata.libs.mixins.object_lookup_mixin module

class onadata.libs.mixins.object_lookup_mixin.ObjectLookupMixin

Bases: object

get_object(queryset=None)

Incase the lookup is on an object that has been hyperlinked then update the queryset filter appropriately

onadata.libs.mixins.openrosa_headers_mixin module

OpenRosaHeadersMixin module

class onadata.libs.mixins.openrosa_headers_mixin.OpenRosaHeadersMixin

Bases: object

OpenRosaHeadersMixin class - sets OpenRosa headers in a response for a View or Viewset.

finalize_response(request, response, *args, **kwargs)

Adds OpenRosa headers into the response.

onadata.libs.mixins.openrosa_headers_mixin.get_openrosa_headers(request, location=True)

Returns a dict with OpenRosa headers ‘Date’, ‘X-OpenRosa-Version’, ‘X-OpenRosa-Accept-Content-Length’ and ‘Location’.

onadata.libs.mixins.profiler_mixin module

class onadata.libs.mixins.profiler_mixin.ProfilerMixin

Bases: object

dispatch(request, *args, **kwargs)
get_serializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)
onadata.libs.mixins.profiler_mixin.finished(sender, **kwargs)
onadata.libs.mixins.profiler_mixin.started(sender, **kwargs)

onadata.libs.mixins.total_header_mixin module

onadata.libs.mixins.xform_id_string_lookup module

class onadata.libs.mixins.xform_id_string_lookup.XFormIdStringLookupMixin

Bases: object

get_object(queryset=None)
lookup_id_string = 'id_string'

Module contents