Exemplo n.º 1
0
def unsubscribe(request, student_id, token):
    """
    If the student matches the token and the tokens is valid ,
    unsubscribes user from emails marking student.emails_enabled
    to false. Redirects to index.
    """
    student = Student.objects.get(id=student_id)

    if student and check_student_token(student, token):
        # Link is valid
        student.emails_enabled = False
        student.save()

        return render(request, 'unsubscribe.html')

    # Link is invalid. Redirect to homepage.
    return HttpResponseRedirect("/")
Exemplo n.º 2
0
def unsubscribe(request, student_id, token):
    """
    If the student matches the token and the tokens is valid ,
    unsubscribes user from emails marking student.emails_enabled
    to false. Redirects to index.
    """
    student = Student.objects.get(id=student_id)

    if student and check_student_token(student, token):
        # Link is valid
        student.emails_enabled = False
        student.save()

        return render(request, 'unsubscribe.html')

    # Link is invalid. Redirect to homepage.
    return HttpResponseRedirect("/")