def submission_ignored_response(): return OpenRosaResponse( # would have done ✓ but our test Nokias' fonts don't have that character message=u'√ (this submission was ignored)', nature=ResponseNature.SUBMIT_SUCCESS, status=201, ).response()
def get_success_response(): return OpenRosaResponse( # would have done ✓ but our test Nokias' fonts don't have that character message=u' √ ', nature=ResponseNature.SUBMIT_SUCCESS, status=201, ).response()
def get_success_response(doc, errors): if errors: response = OpenRosaResponse( message=doc.problem, nature=ResponseNature.SUBMIT_ERROR, status=201, ).response() else: response = OpenRosaResponse( # would have done ✓ but our test Nokias' fonts don't have that character message=u' √ ', nature=ResponseNature.SUBMIT_SUCCESS, status=201, ).response() return response
def get_retry_response(message, nature): """Returns a 422(Unprocessable Entity) response, mobile will retry this submission """ return OpenRosaResponse( message=message, nature=nature, status=422, ).response()
def get_blacklisted_response(): return OpenRosaResponse( message=("This submission was blocked because of an unusual volume " "of submissions from this project space. Please contact " "support to resolve."), nature=ResponseNature.SUBMIT_ERROR, status=509, ).response()
def get_v3_error_response(message, nature): """Returns a 422(Unprocessable Entity) response - if nature == 'processing_failure' the mobile device will quarantine this form and not retry it - any other value of `nature` will result in the form being marked as a failure and retrying """ return OpenRosaResponse( message=message, nature=nature, status=422, ).response()
def get_exception_response_and_log(error_instance, path): logging.exception( u"Problem receiving submission to %s. Doc id: %s, Error %s" % (path, error_instance.form_id, error_instance.problem)) return OpenRosaResponse( message="There was an error processing the form: %s" % error_instance.problem, nature=ResponseNature.SUBMIT_ERROR, status=500, ).response()
def get_exception_response_and_log(error_instance, path): logging.exception("Problem receiving submission", extra={ 'submission_path': path, 'form_id': error_instance.form_id, 'error_message': error_instance.problem }) return OpenRosaResponse( message="There was an error processing the form: %s" % error_instance.problem, nature=ResponseNature.SUBMIT_ERROR, status=500, ).response()
def get_exception_response_and_log(msg, error_instance, path): logging.warning(msg, extra={ 'submission_path': path, 'form_id': error_instance.form_id, 'error_message': error_instance.problem }) # This are generally badly formed XML resulting from file corruption, encryption errors # or other errors on the device which can not be recovered from. # To prevent retries of these errors we submit a 422 response with `processing_failure` nature. return OpenRosaResponse( message="There was an error processing the form: %s" % error_instance.problem, nature=ResponseNature.PROCESSING_FAILURE, status=422, ).response()
def get_v2_submit_error_response(doc): return OpenRosaResponse( message=doc.problem, nature=ResponseNature.SUBMIT_ERROR, status=201, ).response()
def get_failure_response(doc): return OpenRosaResponse( message=doc.problem, nature=ResponseNature.SUBMIT_ERROR, status=201, ).response()