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"))
|
||||
|
||||
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 "-start_time"
|
||||
|
||||
|
@ -161,7 +161,7 @@ class ContestList(
|
|||
if request.GET.get("show_orgs"):
|
||||
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:
|
||||
self.org_query = list(map(int, request.GET.getlist("orgs")))
|
||||
if not self.request.user.is_superuser:
|
||||
|
@ -169,9 +169,11 @@ class ContestList(
|
|||
i
|
||||
for i in self.org_query
|
||||
if i
|
||||
in self.request.profile.organizations.values_list(
|
||||
in set(
|
||||
self.request.profile.organizations.values_list(
|
||||
"id", flat=True
|
||||
)
|
||||
)
|
||||
]
|
||||
except ValueError:
|
||||
pass
|
||||
|
@ -185,7 +187,7 @@ class ContestList(
|
|||
.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.request.GET.getlist("contest")
|
||||
).strip()
|
||||
|
@ -253,9 +255,6 @@ class ContestList(
|
|||
context["org_query"] = self.org_query
|
||||
context["show_orgs"] = int(self.show_orgs)
|
||||
if self.request.profile:
|
||||
if self.request.user.is_superuser:
|
||||
context["organizations"] = Organization.objects.all()
|
||||
else:
|
||||
context["organizations"] = self.request.profile.organizations.all()
|
||||
context["page_type"] = "list"
|
||||
context.update(self.get_sort_context())
|
||||
|
|
Loading…
Reference in a new issue