forked from CGM_Public/pretix_original
Pagination improvements, allow to select page size
This commit is contained in:
@@ -68,7 +68,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% include "pretixcontrol/pagination.html" %}
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-condensed table-hover">
|
<table class="table table-condensed table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load urlreplace %}
|
{% load urlreplace %}
|
||||||
<nav class="text-center">
|
<nav class="text-center pagination-container">
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
{% if is_paginated %}
|
{% if is_paginated %}
|
||||||
{% if page_obj.has_previous %}
|
{% if page_obj.has_previous %}
|
||||||
@@ -32,4 +32,17 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% if page_size %}
|
||||||
|
<div class="clearfix">
|
||||||
|
<small>
|
||||||
|
{% trans "Show per page:" %}
|
||||||
|
</small>
|
||||||
|
<a href="?{% url_replace request "page_size" "25" "page" "1" %}">
|
||||||
|
{% if page_size == 25 %}<strong>{% endif %}25{% if page_size == 25 %}</strong>{% endif %}</a> |
|
||||||
|
<a href="?{% url_replace request "page_size" "50" "page" "1" %}">
|
||||||
|
{% if page_size == 50 %}<strong>{% endif %}50{% if page_size == 50 %}</strong>{% endif %}</a> |
|
||||||
|
<a href="?{% url_replace request "page_size" "100" "page" "1" %}">
|
||||||
|
{% if page_size == 100 %}<strong>{% endif %}100{% if page_size == 100 %}</strong>{% endif %}</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -35,3 +35,24 @@ class ChartContainingView:
|
|||||||
# required by raphael.js
|
# required by raphael.js
|
||||||
resp['Content-Security-Policy'] = "script-src 'unsafe-eval'; style-src 'unsafe-inline'"
|
resp['Content-Security-Policy'] = "script-src 'unsafe-eval'; style-src 'unsafe-inline'"
|
||||||
return resp
|
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.checkin import CheckinListForm
|
||||||
from pretix.control.forms.filter import CheckInFilterForm
|
from pretix.control.forms.filter import CheckInFilterForm
|
||||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
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
|
model = Checkin
|
||||||
context_object_name = 'entries'
|
context_object_name = 'entries'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/checkin/index.html'
|
template_name = 'pretixcontrol/checkin/index.html'
|
||||||
permission = 'can_view_orders'
|
permission = 'can_view_orders'
|
||||||
|
|
||||||
@@ -109,10 +108,9 @@ class CheckInListShow(EventPermissionRequiredMixin, ListView):
|
|||||||
}) + '?' + request.GET.urlencode())
|
}) + '?' + request.GET.urlencode())
|
||||||
|
|
||||||
|
|
||||||
class CheckinListList(EventPermissionRequiredMixin, ListView):
|
class CheckinListList(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||||
model = CheckinList
|
model = CheckinList
|
||||||
context_object_name = 'checkinlists'
|
context_object_name = 'checkinlists'
|
||||||
paginate_by = 30
|
|
||||||
permission = 'can_view_orders'
|
permission = 'can_view_orders'
|
||||||
template_name = 'pretixcontrol/checkin/lists.html'
|
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.multidomain.urlreverse import get_domain
|
||||||
from pretix.presale.style import regenerate_css
|
from pretix.presale.style import regenerate_css
|
||||||
|
|
||||||
from . import CreateView, UpdateView
|
from . import CreateView, PaginationMixin, UpdateView
|
||||||
from ..logdisplay import OVERVIEW_BLACKLIST
|
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
|
model = TaxRule
|
||||||
context_object_name = 'taxrules'
|
context_object_name = 'taxrules'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/event/tax_index.html'
|
template_name = 'pretixcontrol/event/tax_index.html'
|
||||||
permission = 'can_change_event_settings'
|
permission = 'can_change_event_settings'
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from pretix.control.permissions import (
|
|||||||
EventPermissionRequiredMixin, event_permission_required,
|
EventPermissionRequiredMixin, event_permission_required,
|
||||||
)
|
)
|
||||||
|
|
||||||
from . import ChartContainingView, CreateView, UpdateView
|
from . import ChartContainingView, CreateView, PaginationMixin, UpdateView
|
||||||
|
|
||||||
|
|
||||||
class ItemList(ListView):
|
class ItemList(ListView):
|
||||||
@@ -192,10 +192,9 @@ class CategoryCreate(EventPermissionRequiredMixin, CreateView):
|
|||||||
return super().form_invalid(form)
|
return super().form_invalid(form)
|
||||||
|
|
||||||
|
|
||||||
class CategoryList(ListView):
|
class CategoryList(PaginationMixin, ListView):
|
||||||
model = ItemCategory
|
model = ItemCategory
|
||||||
context_object_name = 'categories'
|
context_object_name = 'categories'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/items/categories.html'
|
template_name = 'pretixcontrol/items/categories.html'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
@@ -245,10 +244,9 @@ def category_move_down(request, organizer, event, category):
|
|||||||
event=request.event.slug)
|
event=request.event.slug)
|
||||||
|
|
||||||
|
|
||||||
class QuestionList(ListView):
|
class QuestionList(PaginationMixin, ListView):
|
||||||
model = Question
|
model = Question
|
||||||
context_object_name = 'questions'
|
context_object_name = 'questions'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/items/questions.html'
|
template_name = 'pretixcontrol/items/questions.html'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
@@ -545,10 +543,9 @@ class QuestionCreate(EventPermissionRequiredMixin, QuestionMixin, CreateView):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
class QuotaList(ListView):
|
class QuotaList(PaginationMixin, ListView):
|
||||||
model = Quota
|
model = Quota
|
||||||
context_object_name = 'quotas'
|
context_object_name = 'quotas'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/items/quotas.html'
|
template_name = 'pretixcontrol/items/quotas.html'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ from pretix.control.forms.event import (
|
|||||||
)
|
)
|
||||||
from pretix.control.forms.filter import EventFilterForm
|
from pretix.control.forms.filter import EventFilterForm
|
||||||
from pretix.control.permissions import OrganizerPermissionRequiredMixin
|
from pretix.control.permissions import OrganizerPermissionRequiredMixin
|
||||||
|
from pretix.control.views import PaginationMixin
|
||||||
|
|
||||||
|
|
||||||
class EventList(ListView):
|
class EventList(PaginationMixin, ListView):
|
||||||
model = Event
|
model = Event
|
||||||
context_object_name = 'events'
|
context_object_name = 'events'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/events/index.html'
|
template_name = 'pretixcontrol/events/index.html'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ from pretix.control.forms.orders import (
|
|||||||
OtherOperationsForm,
|
OtherOperationsForm,
|
||||||
)
|
)
|
||||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||||
|
from pretix.control.views import PaginationMixin
|
||||||
from pretix.helpers.safedownload import check_token
|
from pretix.helpers.safedownload import check_token
|
||||||
from pretix.multidomain.urlreverse import build_absolute_uri
|
from pretix.multidomain.urlreverse import build_absolute_uri
|
||||||
from pretix.presale.signals import question_form_fields
|
from pretix.presale.signals import question_form_fields
|
||||||
@@ -57,10 +58,9 @@ from pretix.presale.signals import question_form_fields
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class OrderList(EventPermissionRequiredMixin, ListView):
|
class OrderList(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||||
model = Order
|
model = Order
|
||||||
context_object_name = 'orders'
|
context_object_name = 'orders'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/orders/index.html'
|
template_name = 'pretixcontrol/orders/index.html'
|
||||||
permission = 'can_view_orders'
|
permission = 'can_view_orders'
|
||||||
|
|
||||||
@@ -815,7 +815,7 @@ class OrderEmailHistory(EventPermissionRequiredMixin, OrderViewMixin, ListView):
|
|||||||
permission = 'can_view_orders'
|
permission = 'can_view_orders'
|
||||||
model = LogEntry
|
model = LogEntry
|
||||||
context_object_name = 'logs'
|
context_object_name = 'logs'
|
||||||
paginate_by = 5
|
paginate_by = 10
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
order = Order.objects.filter(
|
order = Order.objects.filter(
|
||||||
|
|||||||
@@ -24,15 +24,15 @@ from pretix.control.forms.organizer import (
|
|||||||
)
|
)
|
||||||
from pretix.control.permissions import OrganizerPermissionRequiredMixin
|
from pretix.control.permissions import OrganizerPermissionRequiredMixin
|
||||||
from pretix.control.signals import nav_organizer
|
from pretix.control.signals import nav_organizer
|
||||||
|
from pretix.control.views import PaginationMixin
|
||||||
from pretix.helpers.urls import build_absolute_uri
|
from pretix.helpers.urls import build_absolute_uri
|
||||||
from pretix.presale.style import regenerate_organizer_css
|
from pretix.presale.style import regenerate_organizer_css
|
||||||
|
|
||||||
|
|
||||||
class OrganizerList(ListView):
|
class OrganizerList(PaginationMixin, ListView):
|
||||||
model = Organizer
|
model = Organizer
|
||||||
context_object_name = 'organizers'
|
context_object_name = 'organizers'
|
||||||
template_name = 'pretixcontrol/organizers/index.html'
|
template_name = 'pretixcontrol/organizers/index.html'
|
||||||
paginate_by = 30
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
qs = Organizer.objects.all()
|
qs = Organizer.objects.all()
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ from django.views.generic import ListView
|
|||||||
|
|
||||||
from pretix.base.models import Order
|
from pretix.base.models import Order
|
||||||
from pretix.control.forms.filter import OrderSearchFilterForm
|
from pretix.control.forms.filter import OrderSearchFilterForm
|
||||||
|
from pretix.control.views import PaginationMixin
|
||||||
|
|
||||||
|
|
||||||
class OrderSearch(ListView):
|
class OrderSearch(PaginationMixin, ListView):
|
||||||
model = Order
|
model = Order
|
||||||
context_object_name = 'orders'
|
context_object_name = 'orders'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/search/orders.html'
|
template_name = 'pretixcontrol/search/orders.html'
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ from pretix.control.forms.subevents import (
|
|||||||
SubEventItemVariationForm, SubEventMetaValueForm,
|
SubEventItemVariationForm, SubEventMetaValueForm,
|
||||||
)
|
)
|
||||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||||
|
from pretix.control.views import PaginationMixin
|
||||||
from pretix.control.views.event import MetaDataEditorMixin
|
from pretix.control.views.event import MetaDataEditorMixin
|
||||||
|
|
||||||
|
|
||||||
class SubEventList(EventPermissionRequiredMixin, ListView):
|
class SubEventList(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||||
model = SubEvent
|
model = SubEvent
|
||||||
context_object_name = 'subevents'
|
context_object_name = 'subevents'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/subevents/index.html'
|
template_name = 'pretixcontrol/subevents/index.html'
|
||||||
permission = 'can_change_settings'
|
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.forms.vouchers import VoucherBulkForm, VoucherForm
|
||||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||||
from pretix.control.signals import voucher_form_class
|
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
|
model = Voucher
|
||||||
context_object_name = 'vouchers'
|
context_object_name = 'vouchers'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/vouchers/index.html'
|
template_name = 'pretixcontrol/vouchers/index.html'
|
||||||
permission = 'can_view_vouchers'
|
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.services.waitinglist import assign_automatically
|
||||||
from pretix.base.views.async import AsyncAction
|
from pretix.base.views.async import AsyncAction
|
||||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||||
|
from pretix.control.views import PaginationMixin
|
||||||
|
|
||||||
|
|
||||||
class AutoAssign(EventPermissionRequiredMixin, AsyncAction, View):
|
class AutoAssign(EventPermissionRequiredMixin, AsyncAction, View):
|
||||||
@@ -39,10 +40,9 @@ class AutoAssign(EventPermissionRequiredMixin, AsyncAction, View):
|
|||||||
self.request.POST.get('subevent'))
|
self.request.POST.get('subevent'))
|
||||||
|
|
||||||
|
|
||||||
class WaitingListView(EventPermissionRequiredMixin, ListView):
|
class WaitingListView(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
||||||
model = WaitingListEntry
|
model = WaitingListEntry
|
||||||
context_object_name = 'entries'
|
context_object_name = 'entries'
|
||||||
paginate_by = 30
|
|
||||||
template_name = 'pretixcontrol/waitinglist/index.html'
|
template_name = 'pretixcontrol/waitinglist/index.html'
|
||||||
permission = 'can_view_orders'
|
permission = 'can_view_orders'
|
||||||
|
|
||||||
|
|||||||
@@ -486,3 +486,10 @@ body.loading #wrapper {
|
|||||||
.iconcol {
|
.iconcol {
|
||||||
width: 1.28571em;
|
width: 1.28571em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.pagination {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
.pagination-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user