From 3b16791d54898d3695bb9d918357968418a1c5b8 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Mon, 21 Aug 2023 18:24:42 +0500 Subject: [PATCH 1/3] give access of server status page to all users --- src/apps/pages/views.py | 18 ++++++++++++++++-- src/templates/base.html | 3 ++- src/templates/pages/server_status.html | 7 +++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/apps/pages/views.py b/src/apps/pages/views.py index bf32519b7..867372064 100644 --- a/src/apps/pages/views.py +++ b/src/apps/pages/views.py @@ -59,15 +59,29 @@ class ServerStatusView(TemplateView): template_name = 'pages/server_status.html' def get_context_data(self, *args, **kwargs): - if not self.request.user.is_staff: - raise HttpResponse(status=404) show_child_submissions = self.request.GET.get('show_child_submissions', False) + # 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 qs = qs.filter(created_when__gte=now() - timedelta(days=2)) + + # filter out child submissions i.e. submission has no parent if not show_child_submissions: qs = qs.filter(parent__isnull=True) + qs = qs.order_by('-created_when') qs = qs.select_related('phase__competition', 'owner') diff --git a/src/templates/base.html b/src/templates/base.html index e6530429f..565f51943 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -123,10 +123,11 @@ + {% endif %}