Skip to content

Commit

Permalink
Merge pull request #1497 from codalab/server-status-fix
Browse files Browse the repository at this point in the history
Fix server status when not logged in
  • Loading branch information
Didayolo authored Jun 21, 2024
2 parents e1ea17e + f388de8 commit 82fd30f
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/apps/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,24 @@ def get_context_data(self, *args, **kwargs):
# Get all submissions
qs = Submission.objects.all()

# If user is not super user then:
# filter this user's own submissions
# and
# submissions running on queue which belongs to this user
if not self.request.user.is_superuser:
qs = qs.filter(
Q(owner=self.request.user) |
Q(phase__competition__queue__isnull=False, phase__competition__queue__owner=self.request.user)
)

# filter for fetching last 2 days submissions
# Only if user is authenticated
if self.request.user.is_authenticated:
# If user is not super user then:
# filter this user's own submissions
# and
# submissions running on queue which belongs to this user
if not self.request.user.is_superuser:
qs = qs.filter(
Q(owner=self.request.user) |
Q(phase__competition__queue__isnull=False, phase__competition__queue__owner=self.request.user)
)
else:
qs = qs.none() # This returns an empty queryset

# Filter for fetching last 2 days submissions
qs = qs.filter(created_when__gte=now() - timedelta(days=2))

# filter out child submissions i.e. submission has no parent
# Filter out child submissions i.e. submission has no parent
if not show_child_submissions:
qs = qs.filter(parent__isnull=True)

Expand Down

0 comments on commit 82fd30f

Please sign in to comment.