Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions oioioi/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
'oioioi.su.middleware.SuFirstTimeRedirectionMiddleware',
'oioioi.base.middleware.UserInfoInErrorMessage',
'django.contrib.messages.middleware.MessageMiddleware',
'dj_pagination.middleware.PaginationMiddleware',
'pagination.middleware.PaginationMiddleware',
'oioioi.contests.middleware.CurrentContestMiddleware',
'oioioi.base.middleware.HttpResponseNotAllowedMiddleware',
'oioioi.base.middleware.CheckLoginMiddleware',
Expand Down Expand Up @@ -305,7 +305,7 @@
'registration',
'django_extensions',
'compressor',
'dj_pagination',
'pagination',
'mptt',

'django.contrib.admin',
Expand Down Expand Up @@ -391,7 +391,6 @@

# For dj_pagination
PAGINATION_DEFAULT_WINDOW = 4
PAGINATION_DEFAULT_MARGIN = 1
FILES_ON_PAGE = 100
PROBLEMS_ON_PAGE = 100
CONTESTS_ON_PAGE = 20
Expand Down
1 change: 0 additions & 1 deletion oioioi/deployment/settings.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ FILETRACKER_CACHE_ROOT = '__DIR__/cache'

# For dj_pagination
# PAGINATION_DEFAULT_WINDOW = 4
# PAGINATION_DEFAULT_MARGIN = 1
# FILES_ON_PAGE = 100
# PROBLEMS_ON_PAGE = 100
# CONTESTS_ON_PAGE = 20
Expand Down
13 changes: 10 additions & 3 deletions oioioi/rankings/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,16 @@ def _fake_request(self, page):
fake_req = RequestFactory().get("/?page=" + str(page))
fake_req.user = AnonymousUser()
fake_req.contest = self.contest
# This is required by dj-pagination
# Normally they monkey patch this function in their middleware
fake_req.page = lambda _: page
# django-pagination-py3 reads request.page as a property returning an int.
# We create a per-call subclass so we can override the property cleanly
# without mutating the shared WSGIRequest class (which the middleware
# already patches at the class level).
page_number = page
fake_req.__class__ = type(
"PaginatedRequest",
(type(fake_req),),
{"page": property(lambda self: page_number)},
)
return fake_req

def _render_ranking_page(self, key, data, page):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies = [
"django-registration-redux>=2.12,<2.13",
"Celery>=5.5,<5.6",
"drf-spectacular>=0.28.0",
"dj-pagination>=2.5,<2.6",
"django-pagination-py3>=2.3.0",
"django-compressor>=4.6,<4.7",
"Pygments>=2.19,<2.20",
"django-libsass>=0.9,<0.10",
Expand Down
Loading