Ejemplo n.º 1
0
def import_multiple_submissions_for_form(request, username, id_string):
    """ idem import_multiple_submissions with a defined id_string """

    messages = json.loads(request.POST.get('messages', '[]'))
    incomings = [(m.get('identity', ''), m.get('text', '')) for m in messages]

    responses = [{'status': d.get('code'),
                  'message': d.get('text'),
                  'instanceID': d.get('id')} for d
                 in process_incoming_smses(username, incomings, id_string)]

    return HttpResponse(json.dumps(responses), mimetype='application/json')
Ejemplo n.º 2
0
def import_multiple_submissions_for_form(request, username, id_string):
    """ idem import_multiple_submissions with a defined id_string """

    messages = json.loads(request.POST.get("messages", "[]"))
    incomings = [(m.get("identity", ""), m.get("text", "")) for m in messages]

    responses = [
        {"status": d.get("code"), "message": d.get("text"), "instanceID": d.get("id")}
        for d in process_incoming_smses(username, incomings, id_string)
    ]

    return HttpResponse(json.dumps(responses), mimetype="application/json")
Ejemplo n.º 3
0
def import_multiple_submissions_for_form(request, username, id_string):
    """ idem import_multiple_submissions with a defined id_string """

    messages = json.loads(request.POST.get('messages', '[]'))
    incomings = [(m.get('identity', ''), m.get('text', '')) for m in messages]

    responses = [{'status': d.get('code'),
                  'message': d.get('text'),
                  'instanceID': d.get('id')} for d
                 in process_incoming_smses(username, incomings, id_string)]

    return HttpResponse(json.dumps(responses), mimetype='application/json')
Ejemplo n.º 4
0
def import_submission_for_form(request, username, id_string):
    """ idem import_submission with a defined id_string """

    sms_identity = request.GET.get('identity', '').strip()
    sms_text = request.GET.get('text', '').strip()

    if not sms_identity or not sms_text:
        return get_response({'code': SMS_API_ERROR,
                             'text': _(u"`identity` and `message` are "
                                       u"both required and must not be "
                                       u"empty.")})
    incomings = [(sms_identity, sms_text)]
    response = process_incoming_smses(username, incomings, id_string)[-1]

    return get_response(response)
Ejemplo n.º 5
0
def import_submission_for_form(request, username, id_string):
    """ idem import_submission with a defined id_string """

    sms_identity = request.GET.get('identity', '').strip()
    sms_text = request.GET.get('text', '').strip()

    if not sms_identity or not sms_text:
        return get_response({'code': SMS_API_ERROR,
                             'text': _(u"`identity` and `message` are "
                                       u"both required and must not be "
                                       u"empty.")})
    incomings = [(sms_identity, sms_text)]
    response = process_incoming_smses(username, incomings, id_string)[-1]

    return get_response(response)