예제 #1
0
def serve_post_response(request, reporter):
    username = reporter.urn_tel
    run_id = request.POST['run_id']

    if request.POST.get('password'):
        user = activate_user(request, reporter)
        user.backend = 'django.contrib.auth.backends.ModelBackend'
        login(request, user)
        send_message_to_rapidpro({'from': username, 'text': 'next'})
    else:
        send_message_to_rapidpro({'from': username, 'text': request.POST['send']})

    is_complete = is_registration_complete(run_id)
    if is_complete:
        got_messages = True
        msgs = ["Thank you for joining us. Please click or tap below to take the latest U-Report poll."]
    else:
        msgs, got_messages = get_messages_for_user(username)
    if not got_messages:
        return serve_timeout_message(request, msgs)

    is_password = has_password_keyword(msgs, username)
    post_password = get_post_password_status(request, is_password)
    show_latest_poll_link = post_password > ON_PASSWORD

    return render(request, 'register.html', {
        'is_complete': is_complete,
        'messages': msgs,
        'submission': request.POST.get('send') or None,
        'is_password': is_password,
        'post_password': post_password,
        'show_latest_poll_link': show_latest_poll_link,
        'uuid': reporter.uuid,
        'run_id': run_id})
예제 #2
0
def serve_post_response(request, uuid, ureporter):
    username = Ureporter.objects.get(uuid=uuid).urn_tel
    if request.POST.get('password'):
        activate_user(request, ureporter)
        send_message_to_rapidpro({'from': username, 'text': 'next'})
    else:
        send_message_to_rapidpro({'from': username, 'text': request.POST['send']})
    msgs = get_messages_for_user(username)
    return render(request, 'register.html', {
        'messages': msgs,
        'submission': request.POST.get('send') or None,
        'is_password': has_password_keyword(msgs, username),
        'uuid': uuid})