Refactor frontend views
All checks were successful
Build and push image / build-containers (push) Successful in 10m14s

This commit is contained in:
2025-06-14 21:56:17 +02:00
parent b3debd3ed2
commit bce372a1d1
32 changed files with 1230 additions and 458 deletions

View File

@ -0,0 +1,41 @@
"""Common utilities."""
import math
from pydantic import BaseModel
class PagingInfo(BaseModel):
page: int
limit: int
total: int
offset: int = 0
@property
def first(self) -> int:
"""The first result number."""
return self.offset + 1
@property
def last(self) -> int:
"""Return the last result number."""
return self.offset + self.limit
@property
def total_pages(self) -> int:
"""Return total pages."""
return math.ceil(self.total / self.limit)
@property
def pages(self) -> list[int]:
"""Return all page numbers."""
return [page for page in range(1, self.total_pages + 1)]
@property
def is_last(self) -> bool:
"""Is this the last page?"""
return self.page == self.total_pages
@property
def is_first(self) -> bool:
"""Is this the first page?"""
return self.page == 1