Add user-configurable pagination and enhance case view filters

This commit is contained in:
Ross
2025-08-11 17:12:22 +01:00
parent 99bc89fe20
commit a8840290f5
4 changed files with 52 additions and 13 deletions
+19
View File
@@ -62,3 +62,22 @@ class AuthorMixin():
def remove_author(self, user: User):
"""Remove an author from the object"""
self.author.remove(user)
class UserConfigurablePaginationMixin:
default_per_page = 25
allowed_per_page = [25, 50, 100, 250, 500]
def get_table_pagination(self, table):
try:
per_page = int(self.request.GET.get("per_page", self.default_per_page))
if per_page not in self.allowed_per_page:
per_page = self.default_per_page
except (TypeError, ValueError):
per_page = self.default_per_page
return {"per_page": per_page}
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["page_sizes"] = [25, 50, 100, 250, 500]
return context