admin: make pagination size configurable
This commit is contained in:
parent
5d46c1ea5a
commit
e104c74761
|
@ -9,19 +9,18 @@ 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
|
from passbook.admin.views.utils import 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, ListView):
|
class ApplicationListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all applications"""
|
"""Show list of all applications"""
|
||||||
|
|
||||||
model = Application
|
model = Application
|
||||||
permission_required = "passbook_core.view_application"
|
permission_required = "passbook_core.view_application"
|
||||||
ordering = "name"
|
ordering = "name"
|
||||||
paginate_by = 40
|
|
||||||
template_name = "administration/application/list.html"
|
template_name = "administration/application/list.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,19 +9,18 @@ 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
|
from passbook.admin.views.utils import 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, ListView):
|
class CertificateKeyPairListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all keypairs"""
|
"""Show list of all keypairs"""
|
||||||
|
|
||||||
model = CertificateKeyPair
|
model = CertificateKeyPair
|
||||||
permission_required = "passbook_crypto.view_certificatekeypair"
|
permission_required = "passbook_crypto.view_certificatekeypair"
|
||||||
ordering = "name"
|
ordering = "name"
|
||||||
paginate_by = 40
|
|
||||||
template_name = "administration/certificatekeypair/list.html"
|
template_name = "administration/certificatekeypair/list.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ 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
|
from passbook.admin.views.utils import 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,13 +23,12 @@ 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, ListView):
|
class FlowListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all flows"""
|
"""Show list of all flows"""
|
||||||
|
|
||||||
model = Flow
|
model = Flow
|
||||||
permission_required = "passbook_flows.view_flow"
|
permission_required = "passbook_flows.view_flow"
|
||||||
ordering = "name"
|
ordering = "name"
|
||||||
paginate_by = 40
|
|
||||||
template_name = "administration/flow/list.html"
|
template_name = "administration/flow/list.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,19 +9,18 @@ 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
|
from passbook.admin.views.utils import 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, ListView):
|
class GroupListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all groups"""
|
"""Show list of all groups"""
|
||||||
|
|
||||||
model = Group
|
model = Group
|
||||||
permission_required = "passbook_core.view_group"
|
permission_required = "passbook_core.view_group"
|
||||||
ordering = "name"
|
ordering = "name"
|
||||||
paginate_by = 40
|
|
||||||
template_name = "administration/group/list.html"
|
template_name = "administration/group/list.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,18 @@ 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
|
from passbook.admin.views.utils import 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, ListView):
|
class OutpostListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all outposts"""
|
"""Show list of all outposts"""
|
||||||
|
|
||||||
model = Outpost
|
model = Outpost
|
||||||
permission_required = "passbook_outposts.view_outpost"
|
permission_required = "passbook_outposts.view_outpost"
|
||||||
ordering = "name"
|
ordering = "name"
|
||||||
paginate_by = 40
|
|
||||||
template_name = "administration/outpost/list.html"
|
template_name = "administration/outpost/list.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,18 +20,17 @@ from passbook.admin.views.utils import (
|
||||||
DeleteMessageView,
|
DeleteMessageView,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
InheritanceListView,
|
InheritanceListView,
|
||||||
InheritanceUpdateView,
|
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, InheritanceListView):
|
class PolicyListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView):
|
||||||
"""Show list of all policies"""
|
"""Show list of all policies"""
|
||||||
|
|
||||||
model = Policy
|
model = Policy
|
||||||
permission_required = "passbook_policies.view_policy"
|
permission_required = "passbook_policies.view_policy"
|
||||||
paginate_by = 10
|
|
||||||
ordering = "name"
|
ordering = "name"
|
||||||
template_name = "administration/policy/list.html"
|
template_name = "administration/policy/list.html"
|
||||||
|
|
||||||
|
|
|
@ -11,18 +11,17 @@ 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
|
from passbook.admin.views.utils import 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, ListView):
|
class PolicyBindingListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all policies"""
|
"""Show list of all policies"""
|
||||||
|
|
||||||
model = PolicyBinding
|
model = PolicyBinding
|
||||||
permission_required = "passbook_policies.view_policybinding"
|
permission_required = "passbook_policies.view_policybinding"
|
||||||
paginate_by = 10
|
|
||||||
ordering = ["order", "target"]
|
ordering = ["order", "target"]
|
||||||
template_name = "administration/policy_binding/list.html"
|
template_name = "administration/policy_binding/list.html"
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ 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
|
||||||
|
@ -12,13 +13,13 @@ from passbook.admin.views.utils import (
|
||||||
DeleteMessageView,
|
DeleteMessageView,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
InheritanceListView,
|
InheritanceListView,
|
||||||
InheritanceUpdateView,
|
InheritanceUpdateView, UserPaginateListMixin,
|
||||||
)
|
)
|
||||||
from passbook.core.models import PropertyMapping
|
from passbook.core.models import PropertyMapping
|
||||||
|
|
||||||
|
|
||||||
class PropertyMappingListView(
|
class PropertyMappingListView(
|
||||||
LoginRequiredMixin, PermissionListMixin, InheritanceListView
|
LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView
|
||||||
):
|
):
|
||||||
"""Show list of all property_mappings"""
|
"""Show list of all property_mappings"""
|
||||||
|
|
||||||
|
@ -26,7 +27,6 @@ class PropertyMappingListView(
|
||||||
permission_required = "passbook_core.view_propertymapping"
|
permission_required = "passbook_core.view_propertymapping"
|
||||||
template_name = "administration/property_mapping/list.html"
|
template_name = "administration/property_mapping/list.html"
|
||||||
ordering = "name"
|
ordering = "name"
|
||||||
paginate_by = 40
|
|
||||||
|
|
||||||
|
|
||||||
class PropertyMappingCreateView(
|
class PropertyMappingCreateView(
|
||||||
|
|
|
@ -12,18 +12,17 @@ from passbook.admin.views.utils import (
|
||||||
DeleteMessageView,
|
DeleteMessageView,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
InheritanceListView,
|
InheritanceListView,
|
||||||
InheritanceUpdateView,
|
InheritanceUpdateView, UserPaginateListMixin,
|
||||||
)
|
)
|
||||||
from passbook.core.models import Provider
|
from passbook.core.models import Provider
|
||||||
|
|
||||||
|
|
||||||
class ProviderListView(LoginRequiredMixin, PermissionListMixin, InheritanceListView):
|
class ProviderListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView):
|
||||||
"""Show list of all providers"""
|
"""Show list of all providers"""
|
||||||
|
|
||||||
model = Provider
|
model = Provider
|
||||||
permission_required = "passbook_core.add_provider"
|
permission_required = "passbook_core.add_provider"
|
||||||
template_name = "administration/provider/list.html"
|
template_name = "administration/provider/list.html"
|
||||||
paginate_by = 10
|
|
||||||
ordering = "id"
|
ordering = "id"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,18 +12,17 @@ from passbook.admin.views.utils import (
|
||||||
DeleteMessageView,
|
DeleteMessageView,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
InheritanceListView,
|
InheritanceListView,
|
||||||
InheritanceUpdateView,
|
InheritanceUpdateView, UserPaginateListMixin,
|
||||||
)
|
)
|
||||||
from passbook.core.models import Source
|
from passbook.core.models import Source
|
||||||
|
|
||||||
|
|
||||||
class SourceListView(LoginRequiredMixin, PermissionListMixin, InheritanceListView):
|
class SourceListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView):
|
||||||
"""Show list of all sources"""
|
"""Show list of all sources"""
|
||||||
|
|
||||||
model = Source
|
model = Source
|
||||||
permission_required = "passbook_core.view_source"
|
permission_required = "passbook_core.view_source"
|
||||||
ordering = "name"
|
ordering = "name"
|
||||||
paginate_by = 40
|
|
||||||
template_name = "administration/source/list.html"
|
template_name = "administration/source/list.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,18 @@ from passbook.admin.views.utils import (
|
||||||
DeleteMessageView,
|
DeleteMessageView,
|
||||||
InheritanceCreateView,
|
InheritanceCreateView,
|
||||||
InheritanceListView,
|
InheritanceListView,
|
||||||
InheritanceUpdateView,
|
InheritanceUpdateView, UserPaginateListMixin,
|
||||||
)
|
)
|
||||||
from passbook.flows.models import Stage
|
from passbook.flows.models import Stage
|
||||||
|
|
||||||
|
|
||||||
class StageListView(LoginRequiredMixin, PermissionListMixin, InheritanceListView):
|
class StageListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, InheritanceListView):
|
||||||
"""Show list of all stages"""
|
"""Show list of all stages"""
|
||||||
|
|
||||||
model = Stage
|
model = Stage
|
||||||
template_name = "administration/stage/list.html"
|
template_name = "administration/stage/list.html"
|
||||||
permission_required = "passbook_flows.view_stage"
|
permission_required = "passbook_flows.view_stage"
|
||||||
ordering = "name"
|
ordering = "name"
|
||||||
paginate_by = 40
|
|
||||||
|
|
||||||
|
|
||||||
class StageCreateView(
|
class StageCreateView(
|
||||||
|
|
|
@ -9,18 +9,17 @@ 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
|
from passbook.admin.views.utils import 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, ListView):
|
class StageBindingListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all flows"""
|
"""Show list of all flows"""
|
||||||
|
|
||||||
model = FlowStageBinding
|
model = FlowStageBinding
|
||||||
permission_required = "passbook_flows.view_flowstagebinding"
|
permission_required = "passbook_flows.view_flowstagebinding"
|
||||||
paginate_by = 10
|
|
||||||
ordering = ["target", "order"]
|
ordering = ["target", "order"]
|
||||||
template_name = "administration/stage_binding/list.html"
|
template_name = "administration/stage_binding/list.html"
|
||||||
|
|
||||||
|
|
|
@ -10,20 +10,19 @@ 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
|
from passbook.admin.views.utils import 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, ListView):
|
class InvitationListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all invitations"""
|
"""Show list of all invitations"""
|
||||||
|
|
||||||
model = Invitation
|
model = Invitation
|
||||||
permission_required = "passbook_stages_invitation.view_invitation"
|
permission_required = "passbook_stages_invitation.view_invitation"
|
||||||
template_name = "administration/stage_invitation/list.html"
|
template_name = "administration/stage_invitation/list.html"
|
||||||
paginate_by = 10
|
|
||||||
ordering = "-expires"
|
ordering = "-expires"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,19 +9,18 @@ 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
|
from passbook.admin.views.utils import 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, ListView):
|
class PromptListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all prompts"""
|
"""Show list of all prompts"""
|
||||||
|
|
||||||
model = Prompt
|
model = Prompt
|
||||||
permission_required = "passbook_stages_prompt.view_prompt"
|
permission_required = "passbook_stages_prompt.view_prompt"
|
||||||
ordering = "order"
|
ordering = "order"
|
||||||
paginate_by = 40
|
|
||||||
template_name = "administration/stage_prompt/list.html"
|
template_name = "administration/stage_prompt/list.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,17 +5,16 @@ 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
|
from passbook.admin.views.utils import DeleteMessageView, UserPaginateListMixin
|
||||||
from passbook.core.models import Token
|
from passbook.core.models import Token
|
||||||
|
|
||||||
|
|
||||||
class TokenListView(LoginRequiredMixin, PermissionListMixin, ListView):
|
class TokenListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all tokens"""
|
"""Show list of all tokens"""
|
||||||
|
|
||||||
model = Token
|
model = Token
|
||||||
permission_required = "passbook_core.view_token"
|
permission_required = "passbook_core.view_token"
|
||||||
ordering = "expires"
|
ordering = "expires"
|
||||||
paginate_by = 40
|
|
||||||
template_name = "administration/token/list.html"
|
template_name = "administration/token/list.html"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,18 +18,17 @@ 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
|
from passbook.admin.views.utils import 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, ListView):
|
class UserListView(LoginRequiredMixin, PermissionListMixin, UserPaginateListMixin, ListView):
|
||||||
"""Show list of all users"""
|
"""Show list of all users"""
|
||||||
|
|
||||||
model = User
|
model = User
|
||||||
permission_required = "passbook_core.view_user"
|
permission_required = "passbook_core.view_user"
|
||||||
ordering = "username"
|
ordering = "username"
|
||||||
paginate_by = 40
|
|
||||||
template_name = "administration/user/list.html"
|
template_name = "administration/user/list.html"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
|
|
@ -3,7 +3,9 @@ from typing import Any, Dict
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
|
from django.db.models import QuerySet
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
|
from django.http.request import HttpRequest
|
||||||
from django.views.generic import DeleteView, ListView, UpdateView
|
from django.views.generic import DeleteView, ListView, UpdateView
|
||||||
|
|
||||||
from passbook.lib.utils.reflection import all_subclasses
|
from passbook.lib.utils.reflection import all_subclasses
|
||||||
|
@ -69,3 +71,12 @@ class InheritanceUpdateView(UpdateView):
|
||||||
.select_subclasses()
|
.select_subclasses()
|
||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class UserPaginateListMixin:
|
||||||
|
"""Get paginate_by value from user's attributes, defaulting to 15"""
|
||||||
|
|
||||||
|
request: HttpRequest
|
||||||
|
|
||||||
|
def get_paginate_by(self, queryset: QuerySet) -> int:
|
||||||
|
return self.request.user.attributes.get("paginate_by", 15)
|
||||||
|
|
|
@ -3,14 +3,16 @@ from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.views.generic import ListView
|
from django.views.generic import ListView
|
||||||
from guardian.mixins import PermissionListMixin
|
from guardian.mixins import PermissionListMixin
|
||||||
|
|
||||||
|
from passbook.admin.views.utils import UserPaginateListMixin
|
||||||
from passbook.audit.models import Event
|
from passbook.audit.models import Event
|
||||||
|
|
||||||
|
|
||||||
class EventListView(PermissionListMixin, LoginRequiredMixin, ListView):
|
class EventListView(
|
||||||
|
PermissionListMixin, LoginRequiredMixin, UserPaginateListMixin, ListView
|
||||||
|
):
|
||||||
"""Show list of all invitations"""
|
"""Show list of all invitations"""
|
||||||
|
|
||||||
model = Event
|
model = Event
|
||||||
template_name = "audit/list.html"
|
template_name = "audit/list.html"
|
||||||
permission_required = "passbook_audit.view_event"
|
permission_required = "passbook_audit.view_event"
|
||||||
ordering = "-created"
|
ordering = "-created"
|
||||||
paginate_by = 20
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ LOGGER = get_logger()
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
def back(context: Context) -> str:
|
def back(context: Context) -> str:
|
||||||
"""Return a link back (either from GET paramter or referer."""
|
"""Return a link back (either from GET parameter or referer."""
|
||||||
if "request" not in context:
|
if "request" not in context:
|
||||||
return ""
|
return ""
|
||||||
request = context.get("request")
|
request = context.get("request")
|
||||||
|
|
Reference in New Issue