-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard): sort archived announcements+pagination
Closes #1604
- Loading branch information
1 parent
8a1b67a
commit 8c7a0cc
Showing
8 changed files
with
152 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from typing import List, Union | ||
|
||
from django import template | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def query_transform(request, **kwargs): | ||
query = request.GET.copy() | ||
for k, v in kwargs.items(): | ||
query[k] = v | ||
return query.urlencode() | ||
|
||
|
||
@register.filter # TODO: replace return type with list[int | None] | ||
def page_list(paginator, current_page) -> List[Union[int, None]]: | ||
"""Pagination | ||
If there is a ``None`` in the output, it should be replaced | ||
with ...'s. | ||
""" | ||
SURROUNDING_PAGES = 2 | ||
BEGINNING_PAGES = 2 | ||
END_PAGES = 2 | ||
total_pages = paginator.page_range | ||
|
||
# The page numbers to show | ||
actual_numbers = [ | ||
page | ||
for page in total_pages | ||
if ( | ||
page >= total_pages[-1] - END_PAGES + 1 | ||
or page <= BEGINNING_PAGES | ||
or (current_page.number - SURROUNDING_PAGES <= page <= current_page.number + SURROUNDING_PAGES) | ||
) | ||
] | ||
|
||
pages = [] | ||
for i, number in enumerate(actual_numbers[:-1]): | ||
pages.append(number) | ||
# if there is a mismatch, that means we should add a ... | ||
if actual_numbers[i + 1] != number + 1: | ||
pages.append(None) | ||
pages.append(actual_numbers[-1]) | ||
return pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,7 @@ | |
.btn-link { | ||
border-color: $darkborder; | ||
} | ||
|
||
.ellipses { | ||
--ellipses-color: white; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters