onadata.apps.viewer package

Subpackages

Submodules

onadata.apps.viewer.admin module

class onadata.apps.viewer.admin.DataDictionaryAdmin(*args, **kwargs)

Bases: VersionAdmin, ModelAdmin

exclude = ('user',)
get_queryset(request)

Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.

property media

onadata.apps.viewer.parsed_instance_tools module

ParsedInstance model utility functions

onadata.apps.viewer.parsed_instance_tools.get_where_clause(query, form_integer_fields=None, form_decimal_fields=None)

Returns where clause and related parameters.

onadata.apps.viewer.tasks module

Export tasks.

onadata.apps.viewer.tasks.create_async_export(xform, export_type, query, force_xlsx, options=None)

Starts asynchronous export tasks and returns an export object.

Throws ExportTypeError if export_type is not in EXPORT_TYPES. Throws ExportConnectionError if rabbitmq broker is down.

onadata.apps.viewer.views module

data views.

onadata.apps.viewer.views.add_submission_with(request, username, id_string)

Returns JSON response with Enketo form url preloaded with coordinates.

onadata.apps.viewer.views.attachment_url(request, size='medium')

Redirects to image attachment of the specified size, defaults to ‘medium’.

onadata.apps.viewer.views.average(values)

Get average of a list of values.

onadata.apps.viewer.views.charts(request, username, id_string)

Charts view.

onadata.apps.viewer.views.create_export(request, username, id_string, export_type)

Create async export tasks view.

onadata.apps.viewer.views.data_export(request, username, id_string, export_type)

Data export view.

onadata.apps.viewer.views.data_view(request, username, id_string)

Data view displays submission data.

onadata.apps.viewer.views.delete_export(request, username, id_string, export_type)

Delete export view.

onadata.apps.viewer.views.encode(time_str)

Reformat a time string into YYYY-MM-dd HH:mm:ss.

onadata.apps.viewer.views.export_download(request, username, id_string, export_type, filename)

Export download view.

onadata.apps.viewer.views.export_list(request, username, id_string, export_type)

Export list view.

onadata.apps.viewer.views.export_progress(request, username, id_string, export_type)

Async export progress view.

onadata.apps.viewer.views.format_date_for_mongo(time_str)

Reformat a time string into YYYY-MM-ddTHH:mm:ss.

onadata.apps.viewer.views.google_xlsx_export(request, username, id_string)

Google export view, uploads an excel export to google drive and then redirects to the uploaded google sheet.

onadata.apps.viewer.views.instance(request, username, id_string)

Data view for browsing submissions one at a time.

onadata.apps.viewer.views.instances_for_export(data_dictionary, start=None, end=None)

Returns Instance submission queryset filtered by start and end dates.

onadata.apps.viewer.views.kml_export(request, username, id_string)

KML export view.

onadata.apps.viewer.views.map_embed_view(request, username, id_string)

Embeded map view.

onadata.apps.viewer.views.map_view(request, username, id_string, template='map.html')

Map view.

onadata.apps.viewer.views.set_instances_for_export(id_string, owner, request)

Apply start and end filters to DataDictionary.instances_for_export.

Returns True/False and DataDictionary/HttpResponseBadRequest if the process is successful or not respectively.

onadata.apps.viewer.views.stats_tables(request, username, id_string)

Stats view.

onadata.apps.viewer.views.thank_you_submission(request, username, id_string)

Thank you view after successful submission.

onadata.apps.viewer.views.zip_export(request, username, id_string)

Zip export view.

onadata.apps.viewer.xls_writer module

XlsWriter module - generate a spreadsheet workbook in XLSX format.

class onadata.apps.viewer.xls_writer.XlsWriter

Bases: object

XlsWriter class - generate a spreadsheet workbook in XLSX format.

add_column(sheet_name, column_name)

Add a column_name to the given sheet_name to this workbook.

add_obs(obs)

Add data in obs dictionary into specified sheets to this workbook.

add_row(sheet_name, row)

Add a row to the given sheet_name to this workbook.

add_sheet(name)

Add a given name sheet to this workbook.

reset_workbook()

Reset a Workbook to sensible default.

save_workbook_to_file()

Saves the XLSX workbook to a file.

set_data_dictionary(data_dictionary)

Set the data_dictionary XForm model object for this class.

set_file(file_object=None)

If the file object is None use a StringIO object.

write_tables_to_workbook(tables)

tables should be a list of pairs, the first element in the pair is the name of the table, the second is the actual data.

TODO: figure out how to write to the xls file rather than keep the whole workbook in memory.

Module contents