Fix page list bug
This commit is contained in:
parent
ff8f12c134
commit
7ce3bdda49
3 changed files with 15 additions and 10 deletions
12
dmoj/urls.py
12
dmoj/urls.py
|
@ -95,10 +95,10 @@ def exception(request):
|
||||||
raise RuntimeError('@Xyene asked me to cause this')
|
raise RuntimeError('@Xyene asked me to cause this')
|
||||||
|
|
||||||
|
|
||||||
def paged_list_view(view, name):
|
def paged_list_view(view, name, **kwargs):
|
||||||
return include([
|
return include([
|
||||||
url(r'^$', view.as_view(), name=name),
|
url(r'^$', view.as_view(**kwargs), name=name),
|
||||||
url(r'^(?P<page>\d+)$', view.as_view(), name=name),
|
url(r'^(?P<page>\d+)$', view.as_view(**kwargs), name=name),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,10 +114,10 @@ urlpatterns = [
|
||||||
url(r'^tickets/$', blog.TicketFeed.as_view(), name='ticket_feed'),
|
url(r'^tickets/$', blog.TicketFeed.as_view(), name='ticket_feed'),
|
||||||
url(r'^comments/$', blog.CommentFeed.as_view(), name='comment_feed'),
|
url(r'^comments/$', blog.CommentFeed.as_view(), name='comment_feed'),
|
||||||
])),
|
])),
|
||||||
url(r'^problems/$', problem.ProblemList.as_view(), name='problem_list'),
|
url(r'^problems/', paged_list_view(problem.ProblemList, 'problem_list')),
|
||||||
url(r'^problems/random/$', problem.RandomProblem.as_view(), name='problem_random'),
|
url(r'^problems/random/$', problem.RandomProblem.as_view(), name='problem_random'),
|
||||||
url(r'^problems/feed$', problem.ProblemFeed.as_view(feed_type='for_you'), name='problem_feed'),
|
url(r'^problems/feed/', paged_list_view(problem.ProblemFeed, 'problem_feed', feed_type='for_you')),
|
||||||
url(r'^problems/feed/new$', problem.ProblemFeed.as_view(feed_type='new'), name='problem_feed_new'),
|
url(r'^problems/feed/new/', paged_list_view(problem.ProblemFeed, 'problem_feed_new', feed_type='new')),
|
||||||
|
|
||||||
url(r'^problem/(?P<problem>[^/]+)', include([
|
url(r'^problem/(?P<problem>[^/]+)', include([
|
||||||
url(r'^$', problem.ProblemDetail.as_view(), name='problem_detail'),
|
url(r'^$', problem.ProblemDetail.as_view(), name='problem_detail'),
|
||||||
|
|
|
@ -348,6 +348,7 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
||||||
all_sorts = sql_sort | manual_sort
|
all_sorts = sql_sort | manual_sort
|
||||||
default_desc = frozenset(('date', 'points', 'ac_rate', 'user_count'))
|
default_desc = frozenset(('date', 'points', 'ac_rate', 'user_count'))
|
||||||
default_sort = '-date'
|
default_sort = '-date'
|
||||||
|
first_page_href = None
|
||||||
|
|
||||||
def get_paginator(self, queryset, per_page, orphans=0,
|
def get_paginator(self, queryset, per_page, orphans=0,
|
||||||
allow_empty_first_page=True, **kwargs):
|
allow_empty_first_page=True, **kwargs):
|
||||||
|
@ -468,6 +469,7 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ProblemList, self).get_context_data(**kwargs)
|
context = super(ProblemList, self).get_context_data(**kwargs)
|
||||||
|
|
||||||
context['hide_solved'] = 0 if self.in_contest else int(self.hide_solved)
|
context['hide_solved'] = 0 if self.in_contest else int(self.hide_solved)
|
||||||
context['show_types'] = 0 if self.in_contest else int(self.show_types)
|
context['show_types'] = 0 if self.in_contest else int(self.show_types)
|
||||||
context['full_text'] = 0 if self.in_contest else int(self.full_text)
|
context['full_text'] = 0 if self.in_contest else int(self.full_text)
|
||||||
|
@ -489,10 +491,8 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
||||||
context.update(self.get_sort_paginate_context())
|
context.update(self.get_sort_paginate_context())
|
||||||
if not self.in_contest:
|
if not self.in_contest:
|
||||||
context.update(self.get_sort_context())
|
context.update(self.get_sort_context())
|
||||||
context['hot_problems'] = hot_problems(timedelta(days=1), 7)
|
|
||||||
context['point_start'], context['point_end'], context['point_values'] = self.get_noui_slider_points()
|
context['point_start'], context['point_end'], context['point_values'] = self.get_noui_slider_points()
|
||||||
else:
|
else:
|
||||||
context['hot_problems'] = None
|
|
||||||
context['point_start'], context['point_end'], context['point_values'] = 0, 0, {}
|
context['point_start'], context['point_end'], context['point_values'] = 0, 0, {}
|
||||||
context['hide_contest_scoreboard'] = self.contest.scoreboard_visibility in \
|
context['hide_contest_scoreboard'] = self.contest.scoreboard_visibility in \
|
||||||
(self.contest.SCOREBOARD_AFTER_CONTEST, self.contest.SCOREBOARD_AFTER_PARTICIPATION)
|
(self.contest.SCOREBOARD_AFTER_CONTEST, self.contest.SCOREBOARD_AFTER_PARTICIPATION)
|
||||||
|
@ -506,6 +506,12 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
||||||
context['clarifications'] = clarifications.order_by('-date')
|
context['clarifications'] = clarifications.order_by('-date')
|
||||||
if participation.contest.is_editable_by(self.request.user):
|
if participation.contest.is_editable_by(self.request.user):
|
||||||
context['can_edit_contest'] = True
|
context['can_edit_contest'] = True
|
||||||
|
|
||||||
|
context['page_prefix'] = None
|
||||||
|
context['page_suffix'] = suffix = (
|
||||||
|
'?' + self.request.GET.urlencode()) if self.request.GET else ''
|
||||||
|
context['first_page_href'] = (self.first_page_href or '.') + suffix
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_noui_slider_points(self):
|
def get_noui_slider_points(self):
|
||||||
|
@ -657,8 +663,6 @@ class ProblemFeed(ProblemList):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ProblemFeed, self).get_context_data(**kwargs)
|
context = super(ProblemFeed, self).get_context_data(**kwargs)
|
||||||
context['first_page_href'] = self.request.path
|
|
||||||
context['page_prefix'] = '?page='
|
|
||||||
context['page_type'] = 'feed'
|
context['page_type'] = 'feed'
|
||||||
context['title'] = self.title
|
context['title'] = self.title
|
||||||
context['feed_type'] = self.feed_type
|
context['feed_type'] = self.feed_type
|
||||||
|
|
|
@ -358,6 +358,7 @@ class SubmissionsListBase(DiggPaginatorMixin, TitleMixin, ListView):
|
||||||
context['my_submissions_link'] = self.get_my_submissions_page()
|
context['my_submissions_link'] = self.get_my_submissions_page()
|
||||||
context['all_submissions_link'] = self.get_all_submissions_page()
|
context['all_submissions_link'] = self.get_all_submissions_page()
|
||||||
context['tab'] = self.tab
|
context['tab'] = self.tab
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
|
Loading…
Reference in a new issue