onadata.apps.viewer package

Subpackages

Submodules

onadata.apps.viewer.admin module

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

Bases: reversion.admin.VersionAdmin, django.contrib.admin.options.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.

media

onadata.apps.viewer.parsed_instance_tools module

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

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 Export.ExportTypeError if export_type is not in EXPORT_TYPES. Throws Export.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_xls_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

class onadata.apps.viewer.xls_writer.XlsWriter

Bases: object

add_column(sheet_name, column_name)
add_obs(obs)
add_row(sheet_name, row)
add_sheet(name)
reset_workbook()
save_workbook_to_file()
set_data_dictionary(data_dictionary)
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