From f6a6088e10f0a4077913bfa37a780d7f23a1679b Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Fri, 23 Feb 2024 12:01:58 -0400
Subject: [PATCH] =?UTF-8?q?fix:=20don=E2=80=99t=20limit=20the=20image=20qu?=
 =?UTF-8?q?eryset=20for=20superusers?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 program/views.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/program/views.py b/program/views.py
index d7af879f..923d6f2f 100644
--- a/program/views.py
+++ b/program/views.py
@@ -307,9 +307,13 @@ class APIImageViewSet(viewsets.ModelViewSet):
     pagination_class = LimitOffsetPagination
 
     def get_queryset(self):
-        """The queryset contains only images owned by the requesting user."""
+        """The queryset contains all the images if the requesting user is superuser, otherwise it
+        only includes the images owned by the requesting user."""
 
-        return Image.objects.filter(owner=self.request.user.username)
+        if self.request.user.is_superuser:
+            return Image.objects.all()
+        else:
+            return Image.objects.filter(owner=self.request.user.username)
 
     def create(self, request, *args, **kwargs):
         """Create an Image instance. Any user can create an image."""
-- 
GitLab