From ceb48b5bbe22cc6781f5dca42dd799e0b4cc5601 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Sat, 7 Jan 2023 03:18:16 -0600 Subject: [PATCH] Fix organization problem bug while in contest --- judge/views/organization.py | 15 +++++++++++++-- judge/views/problem.py | 1 + templates/problem/list-base.html | 10 +++++----- templates/problem/list.html | 18 +++++++++--------- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/judge/views/organization.py b/judge/views/organization.py index fd2e2fa..dd3eee7 100644 --- a/judge/views/organization.py +++ b/judge/views/organization.py @@ -67,7 +67,7 @@ from judge.utils.views import ( QueryStringSortMixin, DiggPaginatorMixin, ) -from judge.utils.problems import user_attempted_ids +from judge.utils.problems import user_attempted_ids, user_completed_ids from judge.views.problem import ProblemList from judge.views.contests import ContestList from judge.views.submission import AllSubmissions, SubmissionsListBase @@ -388,7 +388,7 @@ class OrganizationProblems(LoginRequiredMixin, MemberOrganizationMixin, ProblemL return super().get(request, *args, **kwargs) def get_latest_attempted_problems(self, limit=None): - if self.in_contest or not self.profile: + if not self.profile: return () problems = set(self.get_queryset().values_list("code", flat=True)) result = list(user_attempted_ids(self.profile).values()) @@ -398,9 +398,20 @@ class OrganizationProblems(LoginRequiredMixin, MemberOrganizationMixin, ProblemL result = result[:limit] return result + def get_completed_problems(self): + return user_completed_ids(self.profile) if self.profile is not None else () + + def get_attempted_problems(self): + return user_attempted_ids(self.profile) if self.profile is not None else () + + @cached_property + def in_contest(self): + return False + def get_context_data(self, **kwargs): context = super(OrganizationProblems, self).get_context_data(**kwargs) context["page_type"] = "problems" + context["show_contest_mode"] = False return context diff --git a/judge/views/problem.py b/judge/views/problem.py index 11f1ec6..2b309a1 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -715,6 +715,7 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView ) context["first_page_href"] = (self.first_page_href or ".") + suffix context["has_show_editorial_option"] = True + context["show_contest_mode"] = self.request.in_contest_mode return context def get_noui_slider_points(self): diff --git a/templates/problem/list-base.html b/templates/problem/list-base.html index 2dbc968..d6cee15 100644 --- a/templates/problem/list-base.html +++ b/templates/problem/list-base.html @@ -8,7 +8,7 @@ } - {% if not request.in_contest_mode %} + {% if not show_contest_mode %}