Docs: начальная структура проекта
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
35
app/users/views.py
Normal file
35
app/users/views.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
Вход, выход и главная страница.
|
||||
"""
|
||||
import logging
|
||||
from django.contrib.auth.views import LoginView, LogoutView
|
||||
from django.views.generic import TemplateView
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HomeView(LoginRequiredMixin, TemplateView):
|
||||
"""Главная страница после входа: меню справочников и документов."""
|
||||
template_name = "home.html"
|
||||
login_url = "users:login"
|
||||
|
||||
|
||||
class ErpLoginView(LoginView):
|
||||
"""Страница входа."""
|
||||
template_name = "registration/login.html"
|
||||
redirect_authenticated_user = True
|
||||
|
||||
def form_valid(self, form):
|
||||
logger.info("Вход пользователя: %s", form.get_user().username)
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class ErpLogoutView(LogoutView):
|
||||
"""Выход."""
|
||||
next_page = "users:login"
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if request.user.is_authenticated:
|
||||
logger.info("Выход пользователя: %s", request.user.username)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
Reference in New Issue
Block a user