This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/passbook/admin/views/groups.py

84 lines
2.3 KiB
Python
Raw Normal View History

"""passbook Group administration"""
from django.contrib.auth.mixins import LoginRequiredMixin
2019-12-31 11:51:16 +00:00
from django.contrib.auth.mixins import (
PermissionRequiredMixin as DjangoPermissionRequiredMixin,
)
2019-03-08 14:49:45 +00:00
from django.contrib.messages.views import SuccessMessageMixin
from django.urls import reverse_lazy
2020-09-11 21:21:11 +00:00
from django.utils.translation import gettext as _
from django.views.generic import ListView, UpdateView
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
from passbook.admin.views.utils import (
BackSuccessUrlMixin,
DeleteMessageView,
SearchListMixin,
UserPaginateListMixin,
)
2019-03-08 14:49:45 +00:00
from passbook.core.forms.groups import GroupForm
from passbook.core.models import Group
from passbook.lib.views import CreateAssignPermView
class GroupListView(
LoginRequiredMixin,
PermissionListMixin,
UserPaginateListMixin,
SearchListMixin,
ListView,
):
2019-03-08 14:49:45 +00:00
"""Show list of all groups"""
model = Group
2019-12-31 11:51:16 +00:00
permission_required = "passbook_core.view_group"
ordering = "name"
template_name = "administration/group/list.html"
search_fields = ["name", "attributes"]
2019-03-08 14:49:45 +00:00
2019-12-31 11:51:16 +00:00
class GroupCreateView(
SuccessMessageMixin,
BackSuccessUrlMixin,
2019-12-31 11:51:16 +00:00
LoginRequiredMixin,
DjangoPermissionRequiredMixin,
CreateAssignPermView,
):
2019-03-08 14:49:45 +00:00
"""Create new Group"""
model = Group
2019-03-08 14:49:45 +00:00
form_class = GroupForm
2019-12-31 11:51:16 +00:00
permission_required = "passbook_core.add_group"
2019-12-31 11:51:16 +00:00
template_name = "generic/create.html"
success_url = reverse_lazy("passbook_admin:groups")
success_message = _("Successfully created Group")
2019-03-08 14:49:45 +00:00
2019-12-31 11:51:16 +00:00
class GroupUpdateView(
SuccessMessageMixin,
BackSuccessUrlMixin,
LoginRequiredMixin,
PermissionRequiredMixin,
UpdateView,
2019-12-31 11:51:16 +00:00
):
2019-03-08 14:49:45 +00:00
"""Update group"""
model = Group
form_class = GroupForm
2019-12-31 11:51:16 +00:00
permission_required = "passbook_core.change_group"
2019-03-08 14:49:45 +00:00
2019-12-31 11:51:16 +00:00
template_name = "generic/update.html"
success_url = reverse_lazy("passbook_admin:groups")
success_message = _("Successfully updated Group")
2019-03-08 14:49:45 +00:00
2020-07-05 21:15:07 +00:00
class GroupDeleteView(LoginRequiredMixin, PermissionRequiredMixin, DeleteMessageView):
2019-03-08 14:49:45 +00:00
"""Delete group"""
model = Group
2020-07-05 21:15:07 +00:00
permission_required = "passbook_flows.delete_group"
2019-03-08 14:49:45 +00:00
2019-12-31 11:51:16 +00:00
template_name = "generic/delete.html"
success_url = reverse_lazy("passbook_admin:groups")
success_message = _("Successfully deleted Group")