onadata.apps.viewer package¶
Subpackages¶
- onadata.apps.viewer.management package
- Subpackages
- onadata.apps.viewer.management.commands package
- Submodules
- onadata.apps.viewer.management.commands.import module
- onadata.apps.viewer.management.commands.import_forms module
- onadata.apps.viewer.management.commands.mark_start_times module
- onadata.apps.viewer.management.commands.set_uuid_in_xml module
- onadata.apps.viewer.management.commands.update_delete_from_mongo module
- Module contents
- onadata.apps.viewer.management.commands package
- Module contents
- Subpackages
- onadata.apps.viewer.migrations package
- Submodules
- onadata.apps.viewer.migrations.0001_initial module
- onadata.apps.viewer.migrations.0002_export_options module
- onadata.apps.viewer.migrations.0003_auto_20151226_0100 module
- onadata.apps.viewer.migrations.0004_auto_20151226_0109 module
- onadata.apps.viewer.migrations.0005_auto_20160408_0325 module
- onadata.apps.viewer.migrations.0006_auto_20160418_0525 module
- onadata.apps.viewer.migrations.0007_export_error_message module
- Module contents
- onadata.apps.viewer.models package
- Submodules
- onadata.apps.viewer.models.column_rename module
- onadata.apps.viewer.models.data_dictionary module
- onadata.apps.viewer.models.export module
Export
Export.CSV_EXPORT
Export.CSV_ZIP_EXPORT
Export.DoesNotExist
Export.EXPORT_MIMES
Export.EXPORT_OPTION_FIELDS
Export.EXPORT_TYPES
Export.EXPORT_TYPE_DICT
Export.EXTERNAL_EXPORT
Export.FAILED
Export.GEOJSON_EXPORT
Export.GOOGLE_SHEETS_EXPORT
Export.KML_EXPORT
Export.MAX_EXPORTS
Export.MultipleObjectsReturned
Export.OSM_EXPORT
Export.PENDING
Export.SAV_EXPORT
Export.SAV_ZIP_EXPORT
Export.SUCCESSFUL
Export.XLSX_EXPORT
Export.ZIP_EXPORT
Export.created_on
Export.error_message
Export.export_type
Export.export_url
Export.exports_outdated()
Export.filedir
Export.filename
Export.filepath
Export.full_filepath
Export.get_export_type_display()
Export.get_next_by_created_on()
Export.get_previous_by_created_on()
Export.id
Export.internal_status
Export.is_filename_unique()
Export.is_pending
Export.is_successful
Export.objects
Export.options
Export.save()
Export.set_filename()
Export.status
Export.task_id
Export.time_of_last_submission
Export.xform
Export.xform_id
ExportConnectionError
ExportTypeError
export_delete_callback()
get_export_options_query_kwargs()
- onadata.apps.viewer.models.parsed_instance module
ParseError
ParsedInstance
ParsedInstance.DEFAULT_BATCHSIZE
ParsedInstance.DEFAULT_LIMIT
ParsedInstance.DoesNotExist
ParsedInstance.MultipleObjectsReturned
ParsedInstance.STATUS
ParsedInstance.USERFORM_ID
ParsedInstance.add_note()
ParsedInstance.dicts()
ParsedInstance.end_time
ParsedInstance.get_notes()
ParsedInstance.id
ParsedInstance.instance
ParsedInstance.instance_id
ParsedInstance.lat
ParsedInstance.lng
ParsedInstance.objects
ParsedInstance.remove_note()
ParsedInstance.save()
ParsedInstance.start_time
ParsedInstance.to_dict()
ParsedInstance.to_dict_for_mongo()
build_sql_where()
datetime_from_str()
dict_for_mongo()
get_etag_hash_from_query()
get_name_from_survey_element()
get_sql_with_params()
query_count()
query_data()
query_fields_data()
- Module contents
- onadata.apps.viewer.templatetags package
- onadata.apps.viewer.tests package
- Submodules
- onadata.apps.viewer.tests.export_helpers module
- onadata.apps.viewer.tests.surveyor_registration module
- onadata.apps.viewer.tests.test_attachment_url module
- onadata.apps.viewer.tests.test_charts_view module
- onadata.apps.viewer.tests.test_data_view module
TestDataView
TestDataView.setUp()
TestDataView.test_allow_if_shared()
TestDataView.test_allow_if_user_given_permission()
TestDataView.test_data_view()
TestDataView.test_data_view_with_username_and_id_string_in_uppercase()
TestDataView.test_disallow_if_user_permission_revoked()
TestDataView.test_restrict_for_anon()
TestDataView.test_restrict_for_not_owner()
- onadata.apps.viewer.tests.test_export_builder module
- onadata.apps.viewer.tests.test_export_list module
TestDataExportURL
TestDataExportURL.setUp()
TestDataExportURL.test_csv_export_url()
TestDataExportURL.test_csv_export_url_without_records()
TestDataExportURL.test_csv_zip_export_url()
TestDataExportURL.test_sav_zip_export_long_variable_length()
TestDataExportURL.test_sav_zip_export_url()
TestDataExportURL.test_xlsx_export_url()
TestExportList
TestExportList.setUp()
TestExportList.test_csv_export_list()
TestExportList.test_csv_zip_export_list()
TestExportList.test_export_data_with_unavailable_id_string()
TestExportList.test_external_export_list()
TestExportList.test_external_export_list_no_template()
TestExportList.test_kml_export_list()
TestExportList.test_sav_zip_export_list()
TestExportList.test_unauthorised_users_cannot_export_form_data()
TestExportList.test_unsupported_type_export()
TestExportList.test_xls_export_not_supported()
TestExportList.test_xlsx_export_list()
TestExportList.test_zip_export_list()
- onadata.apps.viewer.tests.test_exports module
- onadata.apps.viewer.tests.test_instance_view module
TestInstanceView
TestInstanceView.setUp()
TestInstanceView.test_allow_if_shared()
TestInstanceView.test_allow_if_user_given_permission()
TestInstanceView.test_disallow_if_user_permission_revoked()
TestInstanceView.test_instance_view()
TestInstanceView.test_restrict_for_anon()
TestInstanceView.test_restrict_for_not_owner()
- onadata.apps.viewer.tests.test_kml_export module
- onadata.apps.viewer.tests.test_map_view module
- onadata.apps.viewer.tests.test_parsed_instance module
TestParsedInstance
TestParsedInstance.test_get_where_clause_with_integer()
TestParsedInstance.test_get_where_clause_with_json_query()
TestParsedInstance.test_get_where_clause_with_string_query()
TestParsedInstance.test_parse_sort_fields_function()
TestParsedInstance.test_parse_where_clause_simple_query()
TestParsedInstance.test_parse_where_with_date_value()
TestParsedInstance.test_parse_where_with_null_value()
TestParsedInstance.test_retrieve_records_based_on_form_verion()
TestParsedInstance.test_retrieve_records_using_list_of_queries()
- onadata.apps.viewer.tests.test_stats_table_view module
- onadata.apps.viewer.tests.test_tasks module
- onadata.apps.viewer.tests.test_viewer_tools module
- Module contents
Submodules¶
onadata.apps.viewer.admin module¶
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 givensheet_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 givensheet_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.