From e6d2568686a4690db0938908ec2f560eca2edd34 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 9 Nov 2022 18:55:36 +0100 Subject: [PATCH] Cleanup activation views --- src/charasheet/urls.py | 15 +-------------- src/common/views.py | 18 ------------------ 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/src/charasheet/urls.py b/src/charasheet/urls.py index 101fa47..8a36ba2 100644 --- a/src/charasheet/urls.py +++ b/src/charasheet/urls.py @@ -18,11 +18,10 @@ from django.conf.urls.static import static from django.contrib import admin from django.contrib.auth import logout from django.urls import include, path -from django.views.generic import TemplateView from django_registration.backends.activation.views import RegistrationView from common.forms import RegistrationForm -from common.views import ActivationView, hello_world +from common.views import hello_world urlpatterns = [ path("logout/", logout, {"next_page": settings.LOGOUT_REDIRECT_URL}, name="logout"), @@ -31,18 +30,6 @@ urlpatterns = [ RegistrationView.as_view(form_class=RegistrationForm), name="django_registration_register", ), - path( - "accounts/activate/complete/", - TemplateView.as_view( - template_name="django_registration/activation_complete.html" - ), - name="django_registration_activation_complete", - ), - path( - "accounts/activate//", - ActivationView.as_view(), - name="django_registration_activate", - ), path("accounts/", include("django_registration.backends.activation.urls")), path("accounts/", include("django.contrib.auth.urls")), path("admin/", admin.site.urls), diff --git a/src/common/views.py b/src/common/views.py index 00dcbb4..4a9aa59 100644 --- a/src/common/views.py +++ b/src/common/views.py @@ -1,27 +1,9 @@ -from django.contrib.auth.models import Permission from django.core.handlers.wsgi import WSGIRequest from django.http import HttpResponse from django.shortcuts import redirect, render -from django_registration.backends.activation.views import ( - ActivationView as BaseActivationView, -) def hello_world(request: WSGIRequest) -> HttpResponse: if request.user.is_authenticated: return redirect("character:list") return render(request, "common/hello.html") - - -class ActivationView(BaseActivationView): - def activate(self, *args, **kwargs): - user = super().activate(*args, **kwargs) - perm = Permission.objects.get( - content_type__app_label="character", - content_type__model="character", - codename="add_character", - ) - user.user_permissions.add(perm) - user.is_staff = True - user.save() - return user