diff --git a/judge/views/problem.py b/judge/views/problem.py index a366ef5..fbb2721 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -29,7 +29,7 @@ from judge.comments import CommentedDetailView from judge.forms import ProblemCloneForm, ProblemSubmitForm from judge.models import ContestProblem, ContestSubmission, Judge, Language, Problem, ProblemGroup, \ ProblemTranslation, ProblemType, RuntimeVersion, Solution, Submission, SubmissionSource, \ - TranslatedProblemForeignKeyQuerySet + TranslatedProblemForeignKeyQuerySet, Organization from judge.pdf_problems import DefaultPdfMaker, HAS_PDF from judge.utils.diggpaginator import DiggPaginator from judge.utils.opengraph import generate_opengraph @@ -374,6 +374,10 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView if self.profile is not None and self.hide_solved: queryset = queryset.exclude(id__in=Submission.objects.filter(user=self.profile, points=F('problem__points')) .values_list('problem__id', flat=True)) + if self.org_query: + queryset = queryset.filter( + Q(organizations__in=self.org_query) | + Q(contests__contest__organizations__in=self.org_query)) if self.show_types: queryset = queryset.prefetch_related('types') if self.category is not None: @@ -414,12 +418,14 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView context['full_text'] = 0 if self.in_contest else int(self.full_text) context['show_editorial'] = 0 if self.in_contest else int(self.show_editorial) + context['organizations'] = Organization.objects.all() context['category'] = self.category context['categories'] = ProblemGroup.objects.all() if self.show_types: context['selected_types'] = self.selected_types context['problem_types'] = ProblemType.objects.all() context['has_fts'] = settings.ENABLE_FTS + context['org_query'] = self.org_query context['search_query'] = self.search_query context['completed_problem_ids'] = self.get_completed_problems() context['attempted_problems'] = self.get_attempted_problems() @@ -467,6 +473,7 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView self.search_query = None self.category = None + self.org_query = [] self.selected_types = [] # This actually copies into the instance dictionary... @@ -481,6 +488,12 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView except ValueError: pass + if 'orgs' in request.GET: + try: + self.org_query = list(map(int, request.GET.getlist('orgs'))) + except ValueError: + pass + self.point_start = safe_float_or_none(request.GET.get('point_start')) self.point_end = safe_float_or_none(request.GET.get('point_end')) diff --git a/templates/problem/list.html b/templates/problem/list.html index 0f70a7e..0054d24 100644 --- a/templates/problem/list.html +++ b/templates/problem/list.html @@ -3,13 +3,17 @@ {% block media %} {% if not request.in_contest %}