admin: add BackSuccessUrlMixin to redirect to correct url after form edit
This commit is contained in:
parent
e104c74761
commit
899c5b63ea
|
@ -9,13 +9,19 @@ from django.utils.translation import gettext as _
|
||||||
from django.views.generic import ListView, UpdateView
|
from django.views.generic import ListView, UpdateView
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
DeleteMessageView,
|
||||||
|
UserPaginateListMixin,
|
||||||
|
)
|
||||||
from passbook.core.forms.applications import ApplicationForm
|
from passbook.core.forms.applications import ApplicationForm
|
||||||
from passbook.core.models import Application
|
from passbook.core.models import Application
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
|
|
||||||
|
|
||||||
class ApplicationListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class ApplicationListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all applications"""
|
"""Show list of all applications"""
|
||||||
|
|
||||||
model = Application
|
model = Application
|
||||||
|
@ -26,6 +32,7 @@ class ApplicationListView(LoginRequiredMixin, PermissionListMixin, UserPaginateL
|
||||||
|
|
||||||
class ApplicationCreateView(
|
class ApplicationCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
CreateAssignPermView,
|
CreateAssignPermView,
|
||||||
|
@ -42,7 +49,11 @@ class ApplicationCreateView(
|
||||||
|
|
||||||
|
|
||||||
class ApplicationUpdateView(
|
class ApplicationUpdateView(
|
||||||
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
LoginRequiredMixin,
|
||||||
|
PermissionRequiredMixin,
|
||||||
|
UpdateView,
|
||||||
):
|
):
|
||||||
"""Update application"""
|
"""Update application"""
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ from django.utils.translation import gettext as _
|
||||||
from django.views.generic import ListView, UpdateView
|
from django.views.generic import ListView, UpdateView
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
DeleteMessageView,
|
||||||
|
UserPaginateListMixin,
|
||||||
|
)
|
||||||
from passbook.crypto.forms import CertificateKeyPairForm
|
from passbook.crypto.forms import CertificateKeyPairForm
|
||||||
from passbook.crypto.models import CertificateKeyPair
|
from passbook.crypto.models import CertificateKeyPair
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
|
|
||||||
|
|
||||||
class CertificateKeyPairListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class CertificateKeyPairListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all keypairs"""
|
"""Show list of all keypairs"""
|
||||||
|
|
||||||
model = CertificateKeyPair
|
model = CertificateKeyPair
|
||||||
|
@ -26,6 +32,7 @@ class CertificateKeyPairListView(LoginRequiredMixin, PermissionListMixin, UserPa
|
||||||
|
|
||||||
class CertificateKeyPairCreateView(
|
class CertificateKeyPairCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
CreateAssignPermView,
|
CreateAssignPermView,
|
||||||
|
@ -42,7 +49,11 @@ class CertificateKeyPairCreateView(
|
||||||
|
|
||||||
|
|
||||||
class CertificateKeyPairUpdateView(
|
class CertificateKeyPairUpdateView(
|
||||||
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
LoginRequiredMixin,
|
||||||
|
PermissionRequiredMixin,
|
||||||
|
UpdateView,
|
||||||
):
|
):
|
||||||
"""Update certificatekeypair"""
|
"""Update certificatekeypair"""
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,11 @@ from django.utils.translation import gettext as _
|
||||||
from django.views.generic import DetailView, FormView, ListView, UpdateView
|
from django.views.generic import DetailView, FormView, ListView, UpdateView
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
DeleteMessageView,
|
||||||
|
UserPaginateListMixin,
|
||||||
|
)
|
||||||
from passbook.flows.forms import FlowForm, FlowImportForm
|
from passbook.flows.forms import FlowForm, FlowImportForm
|
||||||
from passbook.flows.models import Flow
|
from passbook.flows.models import Flow
|
||||||
from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER
|
from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER
|
||||||
|
@ -23,7 +27,9 @@ from passbook.lib.utils.urls import redirect_with_qs
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
|
|
||||||
|
|
||||||
class FlowListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class FlowListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all flows"""
|
"""Show list of all flows"""
|
||||||
|
|
||||||
model = Flow
|
model = Flow
|
||||||
|
@ -34,6 +40,7 @@ class FlowListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixi
|
||||||
|
|
||||||
class FlowCreateView(
|
class FlowCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
CreateAssignPermView,
|
CreateAssignPermView,
|
||||||
|
@ -50,7 +57,11 @@ class FlowCreateView(
|
||||||
|
|
||||||
|
|
||||||
class FlowUpdateView(
|
class FlowUpdateView(
|
||||||
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
LoginRequiredMixin,
|
||||||
|
PermissionRequiredMixin,
|
||||||
|
UpdateView,
|
||||||
):
|
):
|
||||||
"""Update flow"""
|
"""Update flow"""
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ from django.utils.translation import gettext as _
|
||||||
from django.views.generic import ListView, UpdateView
|
from django.views.generic import ListView, UpdateView
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
DeleteMessageView,
|
||||||
|
UserPaginateListMixin,
|
||||||
|
)
|
||||||
from passbook.core.forms.groups import GroupForm
|
from passbook.core.forms.groups import GroupForm
|
||||||
from passbook.core.models import Group
|
from passbook.core.models import Group
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
|
|
||||||
|
|
||||||
class GroupListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class GroupListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all groups"""
|
"""Show list of all groups"""
|
||||||
|
|
||||||
model = Group
|
model = Group
|
||||||
|
@ -26,6 +32,7 @@ class GroupListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMix
|
||||||
|
|
||||||
class GroupCreateView(
|
class GroupCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
CreateAssignPermView,
|
CreateAssignPermView,
|
||||||
|
@ -42,7 +49,11 @@ class GroupCreateView(
|
||||||
|
|
||||||
|
|
||||||
class GroupUpdateView(
|
class GroupUpdateView(
|
||||||
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
LoginRequiredMixin,
|
||||||
|
PermissionRequiredMixin,
|
||||||
|
UpdateView,
|
||||||
):
|
):
|
||||||
"""Update group"""
|
"""Update group"""
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,19 @@ from django.utils.translation import gettext as _
|
||||||
from django.views.generic import ListView, UpdateView
|
from django.views.generic import ListView, UpdateView
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
DeleteMessageView,
|
||||||
|
UserPaginateListMixin,
|
||||||
|
)
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
from passbook.outposts.forms import OutpostForm
|
from passbook.outposts.forms import OutpostForm
|
||||||
from passbook.outposts.models import Outpost, OutpostConfig
|
from passbook.outposts.models import Outpost, OutpostConfig
|
||||||
|
|
||||||
|
|
||||||
class OutpostListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class OutpostListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all outposts"""
|
"""Show list of all outposts"""
|
||||||
|
|
||||||
model = Outpost
|
model = Outpost
|
||||||
|
@ -29,6 +35,7 @@ class OutpostListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListM
|
||||||
|
|
||||||
class OutpostCreateView(
|
class OutpostCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
CreateAssignPermView,
|
CreateAssignPermView,
|
||||||
|
@ -52,7 +59,11 @@ class OutpostCreateView(
|
||||||
|
|
||||||
|
|
||||||
class OutpostUpdateView(
|
class OutpostUpdateView(
|
||||||
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
LoginRequiredMixin,
|
||||||
|
PermissionRequiredMixin,
|
||||||
|
UpdateView,
|
||||||
):
|
):
|
||||||
"""Update outpost"""
|
"""Update outpost"""
|
||||||
|
|
||||||
|
|
|
@ -17,16 +17,20 @@ from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.forms.policies import PolicyTestForm
|
from passbook.admin.forms.policies import PolicyTestForm
|
||||||
from passbook.admin.views.utils import (
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
DeleteMessageView,
|
DeleteMessageView,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
InheritanceListView,
|
InheritanceListView,
|
||||||
InheritanceUpdateView, UserPaginateListMixin,
|
InheritanceUpdateView,
|
||||||
|
UserPaginateListMixin,
|
||||||
)
|
)
|
||||||
from passbook.policies.models import Policy, PolicyBinding
|
from passbook.policies.models import Policy, PolicyBinding
|
||||||
from passbook.policies.process import PolicyProcess, PolicyRequest
|
from passbook.policies.process import PolicyProcess, PolicyRequest
|
||||||
|
|
||||||
|
|
||||||
class PolicyListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView):
|
class PolicyListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView
|
||||||
|
):
|
||||||
"""Show list of all policies"""
|
"""Show list of all policies"""
|
||||||
|
|
||||||
model = Policy
|
model = Policy
|
||||||
|
@ -37,6 +41,7 @@ class PolicyListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMi
|
||||||
|
|
||||||
class PolicyCreateView(
|
class PolicyCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
|
@ -53,6 +58,7 @@ class PolicyCreateView(
|
||||||
|
|
||||||
class PolicyUpdateView(
|
class PolicyUpdateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
PermissionRequiredMixin,
|
PermissionRequiredMixin,
|
||||||
InheritanceUpdateView,
|
InheritanceUpdateView,
|
||||||
|
|
|
@ -11,13 +11,19 @@ from django.views.generic import ListView, UpdateView
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
from guardian.shortcuts import get_objects_for_user
|
from guardian.shortcuts import get_objects_for_user
|
||||||
|
|
||||||
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
DeleteMessageView,
|
||||||
|
UserPaginateListMixin,
|
||||||
|
)
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
from passbook.policies.forms import PolicyBindingForm
|
from passbook.policies.forms import PolicyBindingForm
|
||||||
from passbook.policies.models import PolicyBinding
|
from passbook.policies.models import PolicyBinding
|
||||||
|
|
||||||
|
|
||||||
class PolicyBindingListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class PolicyBindingListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all policies"""
|
"""Show list of all policies"""
|
||||||
|
|
||||||
model = PolicyBinding
|
model = PolicyBinding
|
||||||
|
@ -46,6 +52,7 @@ class PolicyBindingListView(LoginRequiredMixin, PermissionListMixin, UserPaginat
|
||||||
|
|
||||||
class PolicyBindingCreateView(
|
class PolicyBindingCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
CreateAssignPermView,
|
CreateAssignPermView,
|
||||||
|
@ -62,7 +69,11 @@ class PolicyBindingCreateView(
|
||||||
|
|
||||||
|
|
||||||
class PolicyBindingUpdateView(
|
class PolicyBindingUpdateView(
|
||||||
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
LoginRequiredMixin,
|
||||||
|
PermissionRequiredMixin,
|
||||||
|
UpdateView,
|
||||||
):
|
):
|
||||||
"""Update policybinding"""
|
"""Update policybinding"""
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,17 @@ from django.contrib.auth.mixins import (
|
||||||
PermissionRequiredMixin as DjangoPermissionRequiredMixin,
|
PermissionRequiredMixin as DjangoPermissionRequiredMixin,
|
||||||
)
|
)
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.db.models import QuerySet
|
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import (
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
DeleteMessageView,
|
DeleteMessageView,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
InheritanceListView,
|
InheritanceListView,
|
||||||
InheritanceUpdateView, UserPaginateListMixin,
|
InheritanceUpdateView,
|
||||||
|
UserPaginateListMixin,
|
||||||
)
|
)
|
||||||
from passbook.core.models import PropertyMapping
|
from passbook.core.models import PropertyMapping
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ class PropertyMappingListView(
|
||||||
|
|
||||||
class PropertyMappingCreateView(
|
class PropertyMappingCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
|
@ -47,6 +49,7 @@ class PropertyMappingCreateView(
|
||||||
|
|
||||||
class PropertyMappingUpdateView(
|
class PropertyMappingUpdateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
PermissionRequiredMixin,
|
PermissionRequiredMixin,
|
||||||
InheritanceUpdateView,
|
InheritanceUpdateView,
|
||||||
|
|
|
@ -9,15 +9,19 @@ from django.utils.translation import gettext as _
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import (
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
DeleteMessageView,
|
DeleteMessageView,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
InheritanceListView,
|
InheritanceListView,
|
||||||
InheritanceUpdateView, UserPaginateListMixin,
|
InheritanceUpdateView,
|
||||||
|
UserPaginateListMixin,
|
||||||
)
|
)
|
||||||
from passbook.core.models import Provider
|
from passbook.core.models import Provider
|
||||||
|
|
||||||
|
|
||||||
class ProviderListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView):
|
class ProviderListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView
|
||||||
|
):
|
||||||
"""Show list of all providers"""
|
"""Show list of all providers"""
|
||||||
|
|
||||||
model = Provider
|
model = Provider
|
||||||
|
@ -28,6 +32,7 @@ class ProviderListView(LoginRequiredMixin, PermissionListMixin, UserPaginateList
|
||||||
|
|
||||||
class ProviderCreateView(
|
class ProviderCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
|
@ -44,6 +49,7 @@ class ProviderCreateView(
|
||||||
|
|
||||||
class ProviderUpdateView(
|
class ProviderUpdateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
PermissionRequiredMixin,
|
PermissionRequiredMixin,
|
||||||
InheritanceUpdateView,
|
InheritanceUpdateView,
|
||||||
|
|
|
@ -9,15 +9,19 @@ from django.utils.translation import gettext as _
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import (
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
DeleteMessageView,
|
DeleteMessageView,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
InheritanceListView,
|
InheritanceListView,
|
||||||
InheritanceUpdateView, UserPaginateListMixin,
|
InheritanceUpdateView,
|
||||||
|
UserPaginateListMixin,
|
||||||
)
|
)
|
||||||
from passbook.core.models import Source
|
from passbook.core.models import Source
|
||||||
|
|
||||||
|
|
||||||
class SourceListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView):
|
class SourceListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView
|
||||||
|
):
|
||||||
"""Show list of all sources"""
|
"""Show list of all sources"""
|
||||||
|
|
||||||
model = Source
|
model = Source
|
||||||
|
@ -28,6 +32,7 @@ class SourceListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMi
|
||||||
|
|
||||||
class SourceCreateView(
|
class SourceCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
|
@ -44,6 +49,7 @@ class SourceCreateView(
|
||||||
|
|
||||||
class SourceUpdateView(
|
class SourceUpdateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
PermissionRequiredMixin,
|
PermissionRequiredMixin,
|
||||||
InheritanceUpdateView,
|
InheritanceUpdateView,
|
||||||
|
|
|
@ -9,15 +9,19 @@ from django.utils.translation import gettext as _
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import (
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
DeleteMessageView,
|
DeleteMessageView,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
InheritanceListView,
|
InheritanceListView,
|
||||||
InheritanceUpdateView, UserPaginateListMixin,
|
InheritanceUpdateView,
|
||||||
|
UserPaginateListMixin,
|
||||||
)
|
)
|
||||||
from passbook.flows.models import Stage
|
from passbook.flows.models import Stage
|
||||||
|
|
||||||
|
|
||||||
class StageListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView):
|
class StageListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView
|
||||||
|
):
|
||||||
"""Show list of all stages"""
|
"""Show list of all stages"""
|
||||||
|
|
||||||
model = Stage
|
model = Stage
|
||||||
|
@ -28,6 +32,7 @@ class StageListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMix
|
||||||
|
|
||||||
class StageCreateView(
|
class StageCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
|
@ -44,6 +49,7 @@ class StageCreateView(
|
||||||
|
|
||||||
class StageUpdateView(
|
class StageUpdateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
PermissionRequiredMixin,
|
PermissionRequiredMixin,
|
||||||
InheritanceUpdateView,
|
InheritanceUpdateView,
|
||||||
|
|
|
@ -9,13 +9,19 @@ from django.utils.translation import gettext as _
|
||||||
from django.views.generic import ListView, UpdateView
|
from django.views.generic import ListView, UpdateView
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
DeleteMessageView,
|
||||||
|
UserPaginateListMixin,
|
||||||
|
)
|
||||||
from passbook.flows.forms import FlowStageBindingForm
|
from passbook.flows.forms import FlowStageBindingForm
|
||||||
from passbook.flows.models import FlowStageBinding
|
from passbook.flows.models import FlowStageBinding
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
|
|
||||||
|
|
||||||
class StageBindingListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class StageBindingListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all flows"""
|
"""Show list of all flows"""
|
||||||
|
|
||||||
model = FlowStageBinding
|
model = FlowStageBinding
|
||||||
|
@ -26,6 +32,7 @@ class StageBindingListView(LoginRequiredMixin, PermissionListMixin, UserPaginate
|
||||||
|
|
||||||
class StageBindingCreateView(
|
class StageBindingCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
CreateAssignPermView,
|
CreateAssignPermView,
|
||||||
|
@ -42,7 +49,11 @@ class StageBindingCreateView(
|
||||||
|
|
||||||
|
|
||||||
class StageBindingUpdateView(
|
class StageBindingUpdateView(
|
||||||
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
LoginRequiredMixin,
|
||||||
|
PermissionRequiredMixin,
|
||||||
|
UpdateView,
|
||||||
):
|
):
|
||||||
"""Update FlowStageBinding"""
|
"""Update FlowStageBinding"""
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,20 @@ from django.utils.translation import gettext as _
|
||||||
from django.views.generic import ListView
|
from django.views.generic import ListView
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
DeleteMessageView,
|
||||||
|
UserPaginateListMixin,
|
||||||
|
)
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
from passbook.stages.invitation.forms import InvitationForm
|
from passbook.stages.invitation.forms import InvitationForm
|
||||||
from passbook.stages.invitation.models import Invitation
|
from passbook.stages.invitation.models import Invitation
|
||||||
from passbook.stages.invitation.signals import invitation_created
|
from passbook.stages.invitation.signals import invitation_created
|
||||||
|
|
||||||
|
|
||||||
class InvitationListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class InvitationListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all invitations"""
|
"""Show list of all invitations"""
|
||||||
|
|
||||||
model = Invitation
|
model = Invitation
|
||||||
|
@ -28,6 +34,7 @@ class InvitationListView(LoginRequiredMixin, PermissionListMixin, UserPaginateLi
|
||||||
|
|
||||||
class InvitationCreateView(
|
class InvitationCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
CreateAssignPermView,
|
CreateAssignPermView,
|
||||||
|
|
|
@ -9,13 +9,19 @@ from django.utils.translation import gettext as _
|
||||||
from django.views.generic import ListView, UpdateView
|
from django.views.generic import ListView, UpdateView
|
||||||
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
|
|
||||||
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
DeleteMessageView,
|
||||||
|
UserPaginateListMixin,
|
||||||
|
)
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
from passbook.stages.prompt.forms import PromptAdminForm
|
from passbook.stages.prompt.forms import PromptAdminForm
|
||||||
from passbook.stages.prompt.models import Prompt
|
from passbook.stages.prompt.models import Prompt
|
||||||
|
|
||||||
|
|
||||||
class PromptListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class PromptListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all prompts"""
|
"""Show list of all prompts"""
|
||||||
|
|
||||||
model = Prompt
|
model = Prompt
|
||||||
|
@ -26,6 +32,7 @@ class PromptListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMi
|
||||||
|
|
||||||
class PromptCreateView(
|
class PromptCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
CreateAssignPermView,
|
CreateAssignPermView,
|
||||||
|
@ -42,7 +49,11 @@ class PromptCreateView(
|
||||||
|
|
||||||
|
|
||||||
class PromptUpdateView(
|
class PromptUpdateView(
|
||||||
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
LoginRequiredMixin,
|
||||||
|
PermissionRequiredMixin,
|
||||||
|
UpdateView,
|
||||||
):
|
):
|
||||||
"""Update prompt"""
|
"""Update prompt"""
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,9 @@ from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
||||||
from passbook.core.models import Token
|
from passbook.core.models import Token
|
||||||
|
|
||||||
|
|
||||||
class TokenListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class TokenListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all tokens"""
|
"""Show list of all tokens"""
|
||||||
|
|
||||||
model = Token
|
model = Token
|
||||||
|
|
|
@ -18,12 +18,18 @@ from guardian.mixins import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from passbook.admin.forms.users import UserForm
|
from passbook.admin.forms.users import UserForm
|
||||||
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
from passbook.admin.views.utils import (
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
DeleteMessageView,
|
||||||
|
UserPaginateListMixin,
|
||||||
|
)
|
||||||
from passbook.core.models import Token, User
|
from passbook.core.models import Token, User
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
|
|
||||||
|
|
||||||
class UserListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
class UserListView(
|
||||||
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all users"""
|
"""Show list of all users"""
|
||||||
|
|
||||||
model = User
|
model = User
|
||||||
|
@ -37,6 +43,7 @@ class UserListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixi
|
||||||
|
|
||||||
class UserCreateView(
|
class UserCreateView(
|
||||||
SuccessMessageMixin,
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
DjangoPermissionRequiredMixin,
|
DjangoPermissionRequiredMixin,
|
||||||
CreateAssignPermView,
|
CreateAssignPermView,
|
||||||
|
@ -53,7 +60,11 @@ class UserCreateView(
|
||||||
|
|
||||||
|
|
||||||
class UserUpdateView(
|
class UserUpdateView(
|
||||||
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
SuccessMessageMixin,
|
||||||
|
BackSuccessUrlMixin,
|
||||||
|
LoginRequiredMixin,
|
||||||
|
PermissionRequiredMixin,
|
||||||
|
UpdateView,
|
||||||
):
|
):
|
||||||
"""Update user"""
|
"""Update user"""
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""passbook admin util views"""
|
"""passbook admin util views"""
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict, Optional
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
|
@ -73,10 +74,29 @@ class InheritanceUpdateView(UpdateView):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class BackSuccessUrlMixin:
|
||||||
|
"""Checks if a relative URL has been given as ?back param, and redirect to it. Otherwise
|
||||||
|
default to self.success_url."""
|
||||||
|
|
||||||
|
request: HttpRequest
|
||||||
|
|
||||||
|
success_url: Optional[str]
|
||||||
|
|
||||||
|
def get_success_url(self) -> str:
|
||||||
|
"""get_success_url from FormMixin"""
|
||||||
|
back_param = self.request.GET.get("back")
|
||||||
|
if back_param:
|
||||||
|
if not bool(urlparse(back_param).netloc):
|
||||||
|
return back_param
|
||||||
|
return str(self.success_url)
|
||||||
|
|
||||||
|
|
||||||
class UserPaginateListMixin:
|
class UserPaginateListMixin:
|
||||||
"""Get paginate_by value from user's attributes, defaulting to 15"""
|
"""Get paginate_by value from user's attributes, defaulting to 15"""
|
||||||
|
|
||||||
request: HttpRequest
|
request: HttpRequest
|
||||||
|
|
||||||
|
# pylint: disable=unused-argument
|
||||||
def get_paginate_by(self, queryset: QuerySet) -> int:
|
def get_paginate_by(self, queryset: QuerySet) -> int:
|
||||||
|
"""get_paginate_by Function of ListView"""
|
||||||
return self.request.user.attributes.get("paginate_by", 15)
|
return self.request.user.attributes.get("paginate_by", 15)
|
||||||
|
|
Reference in New Issue