onadata.apps.sms_support package¶
Submodules¶
onadata.apps.sms_support.autodoc module¶
SMS Support Automatic Documentation (Web View)
Provides the get_autodoc_for(xform) function. It is used inside the main.views.show() view to display an HTML documentation about how to fill the SMS for that form.
Output is HTML ; not raw. Output uses only span markup with classes so it should be somewhat easy to restyle
-
onadata.apps.sms_support.autodoc.
get_autodoc_for
(xform)¶ The generated documentation in a dict (HTML output)
line_names: example line filled with question line_names line_values: example line filled with fake (yet valid) data helpers: list of tuples (name, text) of helper texts.
Helper texts are based on type of question and accepted values
-
onadata.apps.sms_support.autodoc.
get_helper_text
(question, json_survey)¶ The full sentence (html) of the helper for a question
Includes the type, a description and potentialy accepted values or format
-
onadata.apps.sms_support.autodoc.
get_sample_data_for
(question, json_survey, as_names=False)¶ return an example data for a particular question.
If as_names is True, returns name (not sms_field) of the question
onadata.apps.sms_support.parser module¶
-
exception
onadata.apps.sms_support.parser.
SMSCastingError
(message, question=None)¶ Bases:
exceptions.ValueError
-
exception
onadata.apps.sms_support.parser.
SMSSyntaxError
¶ Bases:
exceptions.ValueError
-
onadata.apps.sms_support.parser.
parse_sms_text
(xform, identity, text)¶
-
onadata.apps.sms_support.parser.
process_incoming_smses
(username, incomings, id_string=None)¶ Process Incoming (identity, text[, id_string]) SMS
onadata.apps.sms_support.tools module¶
-
onadata.apps.sms_support.tools.
check_form_sms_compatibility
(form, json_survey=None)¶ Tests all SMS related rules on the XForm representation
Returns a view-compatible dict(type, text) with warnings or a success message
-
onadata.apps.sms_support.tools.
generate_instance
(username, xml_file, media_files, uuid=None)¶ Process an XForm submission as if done via HTTP
Parameters: :returns a (status, message) tuple.
-
onadata.apps.sms_support.tools.
get_sms_instance_id
(instance)¶ Human-friendly unique ID of a submission for latter ref/update
For now, we strip down to the first 8 chars of the UUID. Until we figure out what we really want (might as well be used by formhub XML)
-
onadata.apps.sms_support.tools.
is_last
(index, items)¶
Whether a form is considered to want sms Support
return True if one sms-related field is defined.
-
onadata.apps.sms_support.tools.
sms_media_to_file
(file_object, name)¶
onadata.apps.sms_support.views module¶
-
onadata.apps.sms_support.views.
get_response
(data)¶
-
onadata.apps.sms_support.views.
import_multiple_submissions
(request, *args, **kwargs)¶ Process several POSTED SMS texts as XForm submissions
Parameters: messages (json) – JSON list of {“identity”: “x”, “text”: “x”} Returns json list of {“status”: “x”, “message”: “x”, “id”: “x”}
-
onadata.apps.sms_support.views.
import_multiple_submissions_for_form
(request, *args, **kwargs)¶ idem import_multiple_submissions with a defined id_string
-
onadata.apps.sms_support.views.
import_submission
(request, *args, **kwargs)¶ Process an SMS text as a form submission
Parameters: Returns: a JSON dict with: ‘status’: one of ‘ACCEPTED’, ‘REJECTED’, ‘PARSING_FAILED’ ‘message’: Error message if not ACCEPTED. ‘id: Unique submission ID if ACCEPTED.
-
onadata.apps.sms_support.views.
import_submission_for_form
(request, *args, **kwargs)¶ idem import_submission with a defined id_string