Skip to content

Commit

Permalink
#86 fix mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ephes committed Mar 20, 2023
1 parent f324eae commit b131234
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cast/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def render_option(self, name: str, selected_choices: set[str], option_value: str
option_label = _("All")

# remove page from querystring, because otherwise the pagination breaks
# filters like date facets
data_dict = {k: v for k, v in self.data.items() if k != "page"}
# filters like date facets, str to make mypy happy
data_dict = {k: str(v) for k, v in self.data.items() if k != "page"}
data = QueryDict("", mutable=True)
data.update(data_dict)

Expand Down
9 changes: 4 additions & 5 deletions cast/models/index_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ def get_published_posts(filtered_posts: models.QuerySet) -> models.QuerySet[Post
)
return queryset

def paginate_queryset(
self, context: ContextDict, posts_queryset: models.QuerySet, get_params: QueryDict
) -> ContextDict:
@staticmethod
def paginate_queryset(context: ContextDict, posts_queryset: models.QuerySet, get_params: QueryDict) -> ContextDict:
paginator = Paginator(posts_queryset, appsettings.POST_LIST_PAGINATION)
page_from_url = "1"
if "page" in get_params:
page_from_url = get_params["page"]
page_from_url = str(get_params["page"])
try:
page_number = int(page_from_url)
except ValueError:
Expand All @@ -155,7 +154,7 @@ def paginate_queryset(

@staticmethod
def get_other_get_params(get_params: QueryDict) -> str:
filtered_get_params = {k: v for k, v in get_params.items() if k != "page"}
filtered_get_params = {k: str(v) for k, v in get_params.items() if k != "page"}
new_get_params = QueryDict("", mutable=True)
new_get_params.update(filtered_get_params)
parameters = new_get_params.urlencode()
Expand Down

0 comments on commit b131234

Please sign in to comment.