26 lines
755 B
Python
26 lines
755 B
Python
from django.contrib.auth.views import LoginView as BaseLoginView
|
|
from django.views.generic import TemplateView
|
|
|
|
from cabinet.utils import CabinetViewMixin
|
|
|
|
|
|
class CabinetIndexView(CabinetViewMixin, TemplateView):
|
|
template_name = 'cabinet/index.html'
|
|
title = 'Cabinet home'
|
|
|
|
|
|
class LoginView(BaseLoginView):
|
|
template_name = 'cabinet/login.html'
|
|
redirect_authenticated_user = True
|
|
|
|
def get_context_data(self, **kwargs):
|
|
ctx = super(LoginView, self).get_context_data(**kwargs)
|
|
ctx['title'] = 'Login'
|
|
return ctx
|
|
|
|
def form_valid(self, form):
|
|
res = super(LoginView, self).form_valid(form)
|
|
if not self.request.POST.get('remember'):
|
|
self.request.session.set_expiry(0)
|
|
return res
|