Exemple #1
0
def home_page(request):
    if request.method == "POST":
        print "Set the session..."
        username = request.POST["username"]
        request.session["current_user"] = username
        new_user = Mother()
        new_user.name = username
        new_user.save()
        if username == request.session["current_user"]:
            print "session has been set!"
        return redirect("/")
    return render(request, "index.html", {"current_user":get_current_user(request=request)})
Exemple #2
0
def registration(request):
    current_user = get_current_user(request=request)
    if request.method == "POST":
        password1 = request.POST["password1"]
        password2 = request.POST["password2"]
        if password1 == password2 and password1 != "":
            user = Mother()
            user.email = request.POST["email"]
            user.password = password1
            user.save()
            send_email(user)
            return redirect("login")
    return render(request, "registration.html", {"current_user": current_user})