Fix contest filter
This commit is contained in:
parent
2ac300ff02
commit
32a1ea8919
1 changed files with 8 additions and 9 deletions
|
@ -146,7 +146,7 @@ class ContestList(
|
||||||
default_desc = frozenset(("name", "user_count"))
|
default_desc = frozenset(("name", "user_count"))
|
||||||
|
|
||||||
def get_default_sort_order(self, request):
|
def get_default_sort_order(self, request):
|
||||||
if "contest" in request.GET and settings.ENABLE_FTS:
|
if request.GET.get("contest") and settings.ENABLE_FTS:
|
||||||
return "-relevance"
|
return "-relevance"
|
||||||
return "-start_time"
|
return "-start_time"
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ class ContestList(
|
||||||
if request.GET.get("show_orgs"):
|
if request.GET.get("show_orgs"):
|
||||||
self.show_orgs = 1
|
self.show_orgs = 1
|
||||||
|
|
||||||
if "orgs" in self.request.GET and self.request.profile:
|
if self.request.GET.get("orgs") and self.request.profile:
|
||||||
try:
|
try:
|
||||||
self.org_query = list(map(int, request.GET.getlist("orgs")))
|
self.org_query = list(map(int, request.GET.getlist("orgs")))
|
||||||
if not self.request.user.is_superuser:
|
if not self.request.user.is_superuser:
|
||||||
|
@ -169,8 +169,10 @@ class ContestList(
|
||||||
i
|
i
|
||||||
for i in self.org_query
|
for i in self.org_query
|
||||||
if i
|
if i
|
||||||
in self.request.profile.organizations.values_list(
|
in set(
|
||||||
"id", flat=True
|
self.request.profile.organizations.values_list(
|
||||||
|
"id", flat=True
|
||||||
|
)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -185,7 +187,7 @@ class ContestList(
|
||||||
.prefetch_related("tags", "organizations", "authors", "curators", "testers")
|
.prefetch_related("tags", "organizations", "authors", "curators", "testers")
|
||||||
)
|
)
|
||||||
|
|
||||||
if "contest" in self.request.GET:
|
if self.request.GET.get("contest"):
|
||||||
self.contest_query = query = " ".join(
|
self.contest_query = query = " ".join(
|
||||||
self.request.GET.getlist("contest")
|
self.request.GET.getlist("contest")
|
||||||
).strip()
|
).strip()
|
||||||
|
@ -253,10 +255,7 @@ class ContestList(
|
||||||
context["org_query"] = self.org_query
|
context["org_query"] = self.org_query
|
||||||
context["show_orgs"] = int(self.show_orgs)
|
context["show_orgs"] = int(self.show_orgs)
|
||||||
if self.request.profile:
|
if self.request.profile:
|
||||||
if self.request.user.is_superuser:
|
context["organizations"] = self.request.profile.organizations.all()
|
||||||
context["organizations"] = Organization.objects.all()
|
|
||||||
else:
|
|
||||||
context["organizations"] = self.request.profile.organizations.all()
|
|
||||||
context["page_type"] = "list"
|
context["page_type"] = "list"
|
||||||
context.update(self.get_sort_context())
|
context.update(self.get_sort_context())
|
||||||
context.update(self.get_sort_paginate_context())
|
context.update(self.get_sort_paginate_context())
|
||||||
|
|
Loading…
Reference in a new issue