Beispiel #1
0
def start_page(request):
    # For GET, display the form
    if request.method == "GET":
        return render_to_response("consent.html", context_instance=RequestContext(request))
    # For POST, create a new user and then send user to the next page, then update the session.
    elif request.method == "POST":
        participant = Participant()
        participant.save()
        participant.num_images = 2 if participant.id % 2 is 0 else 3
        # Demographics will be set at the end.
        participant.save()
        request.session['participant_id'] = participant.id
        response = HttpResponse()
        response.status_code = 303
        response['Location'] = "/experiment/" # Get the URL and set it.
        return response