Skip to content

Commit b020e07

Browse files
committed
Don't discard values from 'archive' filter
The pagination functionality used in the 'patchwork.view.generic_list' generates the filter querystring from scratch. To do this, it calls the 'patchwork.filters.Filters.params' function, which in turn calls the 'patchwork.filters.Filter.key' function for each filter. If any of these 'key' functions return None, the relevant filter is not included in the querystring. This ensures we don't end up with a load of filters like the below: ?submitter=&state=&series=&q=&delegate=&archive=both which would be functionally equivalent to: ?archive=both There is one exception to this rule, however: ArchiveFilter. This is a little unusual in that it is active by default, excluding patches that are "archived" from the list. As a result, the 'key' function should return None for this active state, not for the disabled state. This has been the case up until commit d848f04 which falsely equated 'is False' with 'is None'. This small typo resulted in the filter being ignored when generating pagination links and essentially broke pagination for some use cases. Fix this up. We could probably simplify this thing greatly by not recalculating filters for pagination at least or, better yet, by using django-filter here too. That is a change for another day though. Signed-off-by: Stephen Finucane <[email protected]> Reported-by: John McNamara <[email protected]> Reported-by: Eli Schwartz <[email protected]> Fixes: d848f04 ("trivial: Don't shadow built-ins") Closes: #184 (cherry picked from commit 24c4bef)
1 parent 9d669c2 commit b020e07

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

patchwork/filters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ def condition(self):
340340
return self.description_map[self.archive_state]
341341

342342
def key(self):
343-
if not self.archive_state:
343+
# NOTE(stephenfin): this is a shortcut to ensure we don't both
344+
# including the 'archive' querystring filter for the default case
345+
if self.archive_state is False:
344346
return None
345347
return self.param_map[self.archive_state]
346348

0 commit comments

Comments
 (0)