Muhammad Labeeb d2c41f4639
chore: change repo name
* automatically add issues to project board

* chore: rename app
2025-03-28 19:51:39 +05:00

26 lines
781 B
Python

import typing as t
from tutordeck.server import constants
def pagination_context(
plugins: list[dict[str, str]], current_page: int
) -> dict[str, t.Any]:
total_pages = (
len(plugins) + constants.ITEMS_PER_PAGE - 1
) // constants.ITEMS_PER_PAGE
return {
"current_page": current_page,
"total_pages": total_pages,
"previous_page": current_page - 1 if current_page > 1 else None,
"next_page": current_page + 1 if current_page < total_pages else None,
}
def current_page_plugins(
plugins: list[dict[str, str]], current_page: int
) -> list[dict[str, str]]:
start_index = (current_page - 1) * constants.ITEMS_PER_PAGE
end_index = start_index + constants.ITEMS_PER_PAGE
return plugins[start_index:end_index]