From e7c6ff94993aa72c349454225a772d879c5beb68 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 29 Mar 2021 12:03:11 +0200 Subject: [PATCH] admin: remove group views Signed-off-by: Jens Langhammer --- authentik/admin/urls.py | 8 ------ authentik/admin/views/groups.py | 48 --------------------------------- authentik/core/forms/groups.py | 38 -------------------------- 3 files changed, 94 deletions(-) delete mode 100644 authentik/admin/views/groups.py delete mode 100644 authentik/core/forms/groups.py diff --git a/authentik/admin/urls.py b/authentik/admin/urls.py index 33d2e0a58..217145e3c 100644 --- a/authentik/admin/urls.py +++ b/authentik/admin/urls.py @@ -7,7 +7,6 @@ from authentik.admin.views import ( events_notifications_rules, events_notifications_transports, flows, - groups, outposts, outposts_service_connections, policies, @@ -161,13 +160,6 @@ urlpatterns = [ users.UserPasswordResetView.as_view(), name="user-password-reset", ), - # Groups - path("groups/create/", groups.GroupCreateView.as_view(), name="group-create"), - path( - "groups//update/", - groups.GroupUpdateView.as_view(), - name="group-update", - ), # Certificate-Key Pairs path( "crypto/certificates/create/", diff --git a/authentik/admin/views/groups.py b/authentik/admin/views/groups.py deleted file mode 100644 index 302280259..000000000 --- a/authentik/admin/views/groups.py +++ /dev/null @@ -1,48 +0,0 @@ -"""authentik Group administration""" -from django.contrib.auth.mixins import LoginRequiredMixin -from django.contrib.auth.mixins import ( - PermissionRequiredMixin as DjangoPermissionRequiredMixin, -) -from django.contrib.messages.views import SuccessMessageMixin -from django.urls import reverse_lazy -from django.utils.translation import gettext as _ -from django.views.generic import UpdateView -from guardian.mixins import PermissionRequiredMixin - -from authentik.core.forms.groups import GroupForm -from authentik.core.models import Group -from authentik.lib.views import CreateAssignPermView - - -class GroupCreateView( - SuccessMessageMixin, - LoginRequiredMixin, - DjangoPermissionRequiredMixin, - CreateAssignPermView, -): - """Create new Group""" - - model = Group - form_class = GroupForm - permission_required = "authentik_core.add_group" - - template_name = "generic/create.html" - success_url = reverse_lazy("authentik_core:if-admin") - success_message = _("Successfully created Group") - - -class GroupUpdateView( - SuccessMessageMixin, - LoginRequiredMixin, - PermissionRequiredMixin, - UpdateView, -): - """Update group""" - - model = Group - form_class = GroupForm - permission_required = "authentik_core.change_group" - - template_name = "generic/update.html" - success_url = reverse_lazy("authentik_core:if-admin") - success_message = _("Successfully updated Group") diff --git a/authentik/core/forms/groups.py b/authentik/core/forms/groups.py deleted file mode 100644 index 8d10f1eae..000000000 --- a/authentik/core/forms/groups.py +++ /dev/null @@ -1,38 +0,0 @@ -"""authentik Core Group forms""" -from django import forms - -from authentik.admin.fields import CodeMirrorWidget, YAMLField -from authentik.core.models import Group, User - - -class GroupForm(forms.ModelForm): - """Group Form""" - - members = forms.ModelMultipleChoiceField( - User.objects.all(), - required=False, - ) - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - if self.instance.pk: - self.initial["members"] = self.instance.users.values_list("pk", flat=True) - - def save(self, *args, **kwargs): - instance = super().save(*args, **kwargs) - if instance.pk: - instance.users.clear() - instance.users.add(*self.cleaned_data["members"]) - return instance - - class Meta: - - model = Group - fields = ["name", "is_superuser", "parent", "members", "attributes"] - widgets = { - "name": forms.TextInput(), - "attributes": CodeMirrorWidget, - } - field_classes = { - "attributes": YAMLField, - }