phase2: add modular apps, auth scaffolding, and base template routing
This commit is contained in:
31
apps/users/views.py
Normal file
31
apps/users/views.py
Normal file
@ -0,0 +1,31 @@
|
||||
from django.contrib.auth import login
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.auth.views import LoginView, LogoutView
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic import CreateView, TemplateView
|
||||
|
||||
from .forms import SignupForm
|
||||
|
||||
|
||||
class SignupView(CreateView):
|
||||
form_class = SignupForm
|
||||
template_name = "users/signup.html"
|
||||
success_url = reverse_lazy("core:dashboard")
|
||||
|
||||
def form_valid(self, form):
|
||||
response = super().form_valid(form)
|
||||
login(self.request, self.object)
|
||||
return response
|
||||
|
||||
|
||||
class UserLoginView(LoginView):
|
||||
template_name = "users/login.html"
|
||||
redirect_authenticated_user = True
|
||||
|
||||
|
||||
class UserLogoutView(LogoutView):
|
||||
next_page = reverse_lazy("core:home")
|
||||
|
||||
|
||||
class ProfileView(LoginRequiredMixin, TemplateView):
|
||||
template_name = "users/profile.html"
|
||||
Reference in New Issue
Block a user