online-judge
online-judge copied to clipboard
loading a different page of problems does not persist default "hide solved problems" setting
Start by setting the Hide solved problems
setting to be on.
Reproduction steps:
- Open https://dmoj.ca/problems/ and confirm that the setting is checked by default, and that the URL has not mutated to include a
hide_solved
param. - Go to https://dmoj.ca/problems/?page=2
Expected behavior: The hide solved problems setting is applied, and solved problems do not appear on page 2.
Actual behavior: The hide solved problems setting is not applied, and solved problems do appear on page 2.
There is an easy and known workaround, which is that https://dmoj.ca/problems/?hide_solved=1&page=2 does the right thing, but nonetheless the behavior is nonintuitive and defeats the purpose of saving that as a default.
The paginator is created in templates/list-pages.html
, and the links are created by using page_prefix
and first_page_href
. These 2 variables were added to the context here: https://github.com/DMOJ/online-judge/blob/97f2c450e88814012d19cbcfbec3ae74d14415cb/judge/views/problem.py#L426
get_sort_paginate_context
does not consider the settings that were saved in the session. (GET_with_session
is relevant here)
One approach is to override get_sort_paginate_context
. Another approach is to keep get_sort_paginate_context
but make it (somehow) know the saved settings.