forked from CGM_Public/pretix_original
Pagination improvements, allow to select page size
This commit is contained in:
@@ -35,3 +35,24 @@ class ChartContainingView:
|
||||
# required by raphael.js
|
||||
resp['Content-Security-Policy'] = "script-src 'unsafe-eval'; style-src 'unsafe-inline'"
|
||||
return resp
|
||||
|
||||
|
||||
class PaginationMixin:
|
||||
DEFAULT_PAGINATION = 25
|
||||
|
||||
def get_paginate_by(self, queryset):
|
||||
skey = 'stored_page_size_' + self.request.resolver_match.url_name
|
||||
default = self.request.session.get(skey) or self.paginate_by or self.DEFAULT_PAGINATION
|
||||
if self.request.GET.get('page_size'):
|
||||
try:
|
||||
size = min(250, int(self.request.GET.get("page_size")))
|
||||
self.request.session[skey] = size
|
||||
return min(250, int(self.request.GET.get("page_size")))
|
||||
except ValueError:
|
||||
return default
|
||||
return default
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx['page_size'] = self.get_paginate_by(None)
|
||||
return ctx
|
||||
|
||||
@@ -16,13 +16,12 @@ from pretix.base.models.checkin import CheckinList
|
||||
from pretix.control.forms.checkin import CheckinListForm
|
||||
from pretix.control.forms.filter import CheckInFilterForm
|
||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||
from pretix.control.views import CreateView, UpdateView
|
||||
from pretix.control.views import CreateView, PaginationMixin, UpdateView
|
||||
|
||||
|
||||
class CheckInListShow(EventPermissionRequiredMixin, ListView):
|
||||
class CheckInListShow(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||
model = Checkin
|
||||
context_object_name = 'entries'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/checkin/index.html'
|
||||
permission = 'can_view_orders'
|
||||
|
||||
@@ -109,10 +108,9 @@ class CheckInListShow(EventPermissionRequiredMixin, ListView):
|
||||
}) + '?' + request.GET.urlencode())
|
||||
|
||||
|
||||
class CheckinListList(EventPermissionRequiredMixin, ListView):
|
||||
class CheckinListList(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||
model = CheckinList
|
||||
context_object_name = 'checkinlists'
|
||||
paginate_by = 30
|
||||
permission = 'can_view_orders'
|
||||
template_name = 'pretixcontrol/checkin/lists.html'
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ from pretix.helpers.urls import build_absolute_uri
|
||||
from pretix.multidomain.urlreverse import get_domain
|
||||
from pretix.presale.style import regenerate_css
|
||||
|
||||
from . import CreateView, UpdateView
|
||||
from . import CreateView, PaginationMixin, UpdateView
|
||||
from ..logdisplay import OVERVIEW_BLACKLIST
|
||||
|
||||
|
||||
@@ -877,10 +877,9 @@ class EventComment(EventPermissionRequiredMixin, View):
|
||||
})
|
||||
|
||||
|
||||
class TaxList(EventSettingsViewMixin, EventPermissionRequiredMixin, ListView):
|
||||
class TaxList(EventSettingsViewMixin, EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||
model = TaxRule
|
||||
context_object_name = 'taxrules'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/event/tax_index.html'
|
||||
permission = 'can_change_event_settings'
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ from pretix.control.permissions import (
|
||||
EventPermissionRequiredMixin, event_permission_required,
|
||||
)
|
||||
|
||||
from . import ChartContainingView, CreateView, UpdateView
|
||||
from . import ChartContainingView, CreateView, PaginationMixin, UpdateView
|
||||
|
||||
|
||||
class ItemList(ListView):
|
||||
@@ -192,10 +192,9 @@ class CategoryCreate(EventPermissionRequiredMixin, CreateView):
|
||||
return super().form_invalid(form)
|
||||
|
||||
|
||||
class CategoryList(ListView):
|
||||
class CategoryList(PaginationMixin, ListView):
|
||||
model = ItemCategory
|
||||
context_object_name = 'categories'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/items/categories.html'
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -245,10 +244,9 @@ def category_move_down(request, organizer, event, category):
|
||||
event=request.event.slug)
|
||||
|
||||
|
||||
class QuestionList(ListView):
|
||||
class QuestionList(PaginationMixin, ListView):
|
||||
model = Question
|
||||
context_object_name = 'questions'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/items/questions.html'
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -545,10 +543,9 @@ class QuestionCreate(EventPermissionRequiredMixin, QuestionMixin, CreateView):
|
||||
return ret
|
||||
|
||||
|
||||
class QuotaList(ListView):
|
||||
class QuotaList(PaginationMixin, ListView):
|
||||
model = Quota
|
||||
context_object_name = 'quotas'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/items/quotas.html'
|
||||
|
||||
def get_queryset(self):
|
||||
|
||||
@@ -22,12 +22,12 @@ from pretix.control.forms.event import (
|
||||
)
|
||||
from pretix.control.forms.filter import EventFilterForm
|
||||
from pretix.control.permissions import OrganizerPermissionRequiredMixin
|
||||
from pretix.control.views import PaginationMixin
|
||||
|
||||
|
||||
class EventList(ListView):
|
||||
class EventList(PaginationMixin, ListView):
|
||||
model = Event
|
||||
context_object_name = 'events'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/events/index.html'
|
||||
|
||||
def get_queryset(self):
|
||||
|
||||
@@ -50,6 +50,7 @@ from pretix.control.forms.orders import (
|
||||
OtherOperationsForm,
|
||||
)
|
||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||
from pretix.control.views import PaginationMixin
|
||||
from pretix.helpers.safedownload import check_token
|
||||
from pretix.multidomain.urlreverse import build_absolute_uri
|
||||
from pretix.presale.signals import question_form_fields
|
||||
@@ -57,10 +58,9 @@ from pretix.presale.signals import question_form_fields
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OrderList(EventPermissionRequiredMixin, ListView):
|
||||
class OrderList(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||
model = Order
|
||||
context_object_name = 'orders'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/orders/index.html'
|
||||
permission = 'can_view_orders'
|
||||
|
||||
@@ -815,7 +815,7 @@ class OrderEmailHistory(EventPermissionRequiredMixin, OrderViewMixin, ListView):
|
||||
permission = 'can_view_orders'
|
||||
model = LogEntry
|
||||
context_object_name = 'logs'
|
||||
paginate_by = 5
|
||||
paginate_by = 10
|
||||
|
||||
def get_queryset(self):
|
||||
order = Order.objects.filter(
|
||||
|
||||
@@ -24,15 +24,15 @@ from pretix.control.forms.organizer import (
|
||||
)
|
||||
from pretix.control.permissions import OrganizerPermissionRequiredMixin
|
||||
from pretix.control.signals import nav_organizer
|
||||
from pretix.control.views import PaginationMixin
|
||||
from pretix.helpers.urls import build_absolute_uri
|
||||
from pretix.presale.style import regenerate_organizer_css
|
||||
|
||||
|
||||
class OrganizerList(ListView):
|
||||
class OrganizerList(PaginationMixin, ListView):
|
||||
model = Organizer
|
||||
context_object_name = 'organizers'
|
||||
template_name = 'pretixcontrol/organizers/index.html'
|
||||
paginate_by = 30
|
||||
|
||||
def get_queryset(self):
|
||||
qs = Organizer.objects.all()
|
||||
|
||||
@@ -4,12 +4,12 @@ from django.views.generic import ListView
|
||||
|
||||
from pretix.base.models import Order
|
||||
from pretix.control.forms.filter import OrderSearchFilterForm
|
||||
from pretix.control.views import PaginationMixin
|
||||
|
||||
|
||||
class OrderSearch(ListView):
|
||||
class OrderSearch(PaginationMixin, ListView):
|
||||
model = Order
|
||||
context_object_name = 'orders'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/search/orders.html'
|
||||
|
||||
@cached_property
|
||||
|
||||
@@ -22,13 +22,13 @@ from pretix.control.forms.subevents import (
|
||||
SubEventItemVariationForm, SubEventMetaValueForm,
|
||||
)
|
||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||
from pretix.control.views import PaginationMixin
|
||||
from pretix.control.views.event import MetaDataEditorMixin
|
||||
|
||||
|
||||
class SubEventList(EventPermissionRequiredMixin, ListView):
|
||||
class SubEventList(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||
model = SubEvent
|
||||
context_object_name = 'subevents'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/subevents/index.html'
|
||||
permission = 'can_change_settings'
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ from pretix.base.models.vouchers import _generate_random_code
|
||||
from pretix.control.forms.vouchers import VoucherBulkForm, VoucherForm
|
||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||
from pretix.control.signals import voucher_form_class
|
||||
from pretix.control.views import PaginationMixin
|
||||
|
||||
|
||||
class VoucherList(EventPermissionRequiredMixin, ListView):
|
||||
class VoucherList(PaginationMixin, EventPermissionRequiredMixin, ListView):
|
||||
model = Voucher
|
||||
context_object_name = 'vouchers'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/vouchers/index.html'
|
||||
permission = 'can_view_vouchers'
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ from pretix.base.models.waitinglist import WaitingListException
|
||||
from pretix.base.services.waitinglist import assign_automatically
|
||||
from pretix.base.views.async import AsyncAction
|
||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||
from pretix.control.views import PaginationMixin
|
||||
|
||||
|
||||
class AutoAssign(EventPermissionRequiredMixin, AsyncAction, View):
|
||||
@@ -39,10 +40,9 @@ class AutoAssign(EventPermissionRequiredMixin, AsyncAction, View):
|
||||
self.request.POST.get('subevent'))
|
||||
|
||||
|
||||
class WaitingListView(EventPermissionRequiredMixin, ListView):
|
||||
class WaitingListView(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||
model = WaitingListEntry
|
||||
context_object_name = 'entries'
|
||||
paginate_by = 30
|
||||
template_name = 'pretixcontrol/waitinglist/index.html'
|
||||
permission = 'can_view_orders'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user