Simplify logic
This commit is contained in:
parent
64a5c73c21
commit
bd05ba6b78
2 changed files with 3 additions and 14 deletions
|
@ -371,7 +371,7 @@ class Problem(models.Model):
|
|||
@classmethod
|
||||
def get_visible_problems(cls, user):
|
||||
# Do unauthenticated check here so we can skip authentication checks later on.
|
||||
if not user.is_authenticated:
|
||||
if not user.is_authenticated or not user:
|
||||
return cls.get_public_problems()
|
||||
|
||||
# Conditions for visible problem:
|
||||
|
|
|
@ -585,19 +585,8 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
|||
]
|
||||
|
||||
def get_normal_queryset(self):
|
||||
filter = Q(is_public=True)
|
||||
if self.profile is not None:
|
||||
filter |= Q(authors=self.profile)
|
||||
filter |= Q(curators=self.profile)
|
||||
filter |= Q(testers=self.profile)
|
||||
queryset = (
|
||||
Problem.objects.filter(filter).select_related("group").defer("description")
|
||||
)
|
||||
if not self.request.user.has_perm("see_organization_problem"):
|
||||
filter = Q(is_organization_private=False)
|
||||
if self.profile is not None:
|
||||
filter |= Q(organizations__in=self.profile.organizations.all())
|
||||
queryset = queryset.filter(filter)
|
||||
queryset = Problem.get_visible_problems(self.request.user)
|
||||
queryset = queryset.select_related("group")
|
||||
if self.profile is not None and self.hide_solved:
|
||||
queryset = queryset.exclude(
|
||||
id__in=Submission.objects.filter(
|
||||
|
|
Loading…
Reference in a new issue