Ejemplo n.º 1
0
def user_login(request):
    template = 'login/login.html'
    form = AuthenticationForm(data=(request.POST or None))
    if form.is_valid():
        auth.login(request, form.get_user())
        return redirect(get_referer_view(request))
    return render_to_response(template,
                              {'form': form},
                              RequestContext(request))
Ejemplo n.º 2
0
def vote(request, cookie_id):
    cookie_obj = get_object_or_404(Cookie, pk=cookie_id)
    form = ReviewForm(request.POST)

    if request.user.is_authenticated() and form.is_valid():
        form.save(request.user, cookie_obj)
        messages.success(request, "Your vote has been added")
        return redirect(get_referer_view(request))

    return render_to_response(
        "cookies/detail.html", {"form_review": form, "cookie": cookie_obj}, RequestContext(request)
    )
Ejemplo n.º 3
0
def user_logout(request):
    auth.logout(request)
    return redirect(get_referer_view(request))