Beispiel #1
0
def send_pin(request):
    data = request.POST
    try:
        student = Student.objects.get(penncard=data["penncard"])
        send_pin_to_student(student)
        return http_json({"success": True, "phone": student.phone})
    except Student.DoesNotExist:
        return json_failure("No student with that PennCard is registered.")
Beispiel #2
0
def send_pin(request):
    penncard = request.GET.get("penncard")
    try:
        student = Student.objects.get(penncard=penncard)
    except Student.DoesNotExist:
        messages.info(
            request,
            "Student with penncard {} does not exist. "
            "Sign up for PennCycle using the form below.".format(penncard)
        )
        return HttpResponseRedirect("/signup?penncard={}".format(penncard))
    send_pin_to_student(student)
    messages.info(request, "Pin sent to {}.".format(student.phone))
    return HttpResponseRedirect("/signin?penncard={}".format(penncard))
Beispiel #3
0
def signup(request):
    form = SignupForm(request.POST)
    if form.is_valid():
        student = form.save()
        reply = {
            'success': True,
            'pin': student.pin,
            'waiver': render_to_string('waiver.html')
        }
        send_pin_to_student(student)
        welcome_email(student)
    else:
        reply = {
            'success': False,
            'signup_form': render_crispy_form(form)
        }
    return http_json(reply)