We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add functionality to filter ImageFile objects by RawImageUploadSession from a client
**Is your feature request related to a problem? Please describe.**
I would like to know which ImageFile was generated by a specific RawImageUploadSession from gcapi
**Describe the solution you'd like**
Add an additional item to the existing set of filters in ImageViewSet.get_queryset()



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `app/grandchallenge/cases/views.py`
Content:
```
1 from django.contrib import messages
2 from django.http import Http404
3 from django.views.generic import DetailView
4 from guardian.mixins import (
5     LoginRequiredMixin,
6     PermissionRequiredMixin as ObjectPermissionRequiredMixin,
7 )
8 from rest_framework import status
9 from rest_framework.decorators import action
10 from rest_framework.mixins import (
11     CreateModelMixin,
12     ListModelMixin,
13     RetrieveModelMixin,
14 )
15 from rest_framework.permissions import DjangoObjectPermissions
16 from rest_framework.response import Response
17 from rest_framework.viewsets import GenericViewSet, ReadOnlyModelViewSet
18 from rest_framework_guardian.filters import ObjectPermissionsFilter
19 
20 from grandchallenge.cases.models import (
21     Image,
22     ImageFile,
23     RawImageFile,
24     RawImageUploadSession,
25 )
26 from grandchallenge.cases.serializers import (
27     ImageSerializer,
28     RawImageFileSerializer,
29     RawImageUploadSessionSerializer,
30 )
31 from grandchallenge.core.permissions.rest_framework import (
32     DjangoObjectOnlyWithCustomPostPermissions,
33 )
34 
35 
36 class RawImageUploadSessionDetail(
37     LoginRequiredMixin, ObjectPermissionRequiredMixin, DetailView
38 ):
39     model = RawImageUploadSession
40     permission_required = f"{RawImageUploadSession._meta.app_label}.view_{RawImageUploadSession._meta.model_name}"
41     raise_exception = True
42 
43 
44 class ImageViewSet(ReadOnlyModelViewSet):
45     serializer_class = ImageSerializer
46     queryset = Image.objects.all()
47     permission_classes = [DjangoObjectPermissions]
48     filter_backends = [ObjectPermissionsFilter]
49 
50     def get_queryset(self):
51         filters = {
52             "worklist": self.request.query_params.get("worklist", None),
53             "study": self.request.query_params.get("study", None),
54         }
55         filters = {k: v for k, v in filters.items() if v is not None}
56 
57         queryset = super().get_queryset().filter(**filters)
58 
59         return queryset
60 
61 
62 def show_image(request, *, pk):
63     from django.shortcuts import render
64 
65     try:
66         image_file = ImageFile.objects.select_related("image").get(
67             image=pk, image_type="DZI"
68         )
69     except Image.DoesNotExist:
70         raise Http404("File not found.")
71 
72     return render(
73         request,
74         "cases/show_image.html",
75         {"image_file": image_file, "url": image_file.file.url},
76     )
77 
78 
79 class RawImageUploadSessionViewSet(
80     CreateModelMixin, RetrieveModelMixin, ListModelMixin, GenericViewSet
81 ):
82     serializer_class = RawImageUploadSessionSerializer
83     queryset = RawImageUploadSession.objects.all()
84     permission_classes = [DjangoObjectOnlyWithCustomPostPermissions]
85     filter_backends = [ObjectPermissionsFilter]
86 
87     def perform_create(self, serializer):
88         serializer.save(creator=self.request.user)
89 
90     @action(detail=True, methods=["patch"])
91     def process_images(self, request, pk=None):
92         upload_session: RawImageUploadSession = self.get_object()
93         if (
94             upload_session.status == upload_session.PENDING
95             and not upload_session.rawimagefile_set.filter(
96                 consumed=True
97             ).exists()
98         ):
99             upload_session.process_images()
100             messages.add_message(
101                 request, messages.SUCCESS, "Image processing job queued."
102             )
103             return Response(status=status.HTTP_200_OK)
104         else:
105             messages.add_message(
106                 request,
107                 messages.ERROR,
108                 "Image processing job could not be queued.",
109             )
110             return Response(status=status.HTTP_400_BAD_REQUEST)
111 
112 
113 class RawImageFileViewSet(
114     CreateModelMixin, RetrieveModelMixin, ListModelMixin, GenericViewSet
115 ):
116     serializer_class = RawImageFileSerializer
117     queryset = RawImageFile.objects.all()
118     permission_classes = [DjangoObjectOnlyWithCustomPostPermissions]
119     filter_backends = [ObjectPermissionsFilter]
120
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/app/grandchallenge/cases/views.py b/app/grandchallenge/cases/views.py
--- a/app/grandchallenge/cases/views.py
+++ b/app/grandchallenge/cases/views.py
@@ -51,6 +51,7 @@
         filters = {
             "worklist": self.request.query_params.get("worklist", None),
             "study": self.request.query_params.get("study", None),
+            "origin": self.request.query_params.get("origin", None),
         }
         filters = {k: v for k, v in filters.items() if v is not None}

{"golden_diff": "diff --git a/app/grandchallenge/cases/views.py b/app/grandchallenge/cases/views.py\n--- a/app/grandchallenge/cases/views.py\n+++ b/app/grandchallenge/cases/views.py\n@@ -51,6 +51,7 @@\n         filters = {\n             \"worklist\": self.request.query_params.get(\"worklist\", None),\n             \"study\": self.request.query_params.get(\"study\", None),\n+            \"origin\": self.request.query_params.get(\"origin\", None),\n         }\n         filters = {k: v for k, v in filters.items() if v is not None}\n", "issue": "Add functionality to filter ImageFile objects by RawImageUploadSession from a client\n**Is your feature request related to a problem? Please describe.**\r\nI would like to know which ImageFile was generated by a specific RawImageUploadSession from gcapi\r\n**Describe the solution you'd like**\r\nAdd an additional item to the existing set of filters in ImageViewSet.get_queryset()\r\n\r\n\n", "before_files": [{"content": "from django.contrib import messages\nfrom django.http import Http404\nfrom django.views.generic import DetailView\nfrom guardian.mixins import (\n    LoginRequiredMixin,\n    PermissionRequiredMixin as ObjectPermissionRequiredMixin,\n)\nfrom rest_framework import status\nfrom rest_framework.decorators import action\nfrom rest_framework.mixins import (\n    CreateModelMixin,\n    ListModelMixin,\n    RetrieveModelMixin,\n)\nfrom rest_framework.permissions import DjangoObjectPermissions\nfrom rest_framework.response import Response\nfrom rest_framework.viewsets import GenericViewSet, ReadOnlyModelViewSet\nfrom rest_framework_guardian.filters import ObjectPermissionsFilter\n\nfrom grandchallenge.cases.models import (\n    Image,\n    ImageFile,\n    RawImageFile,\n    RawImageUploadSession,\n)\nfrom grandchallenge.cases.serializers import (\n    ImageSerializer,\n    RawImageFileSerializer,\n    RawImageUploadSessionSerializer,\n)\nfrom grandchallenge.core.permissions.rest_framework import (\n    DjangoObjectOnlyWithCustomPostPermissions,\n)\n\n\nclass RawImageUploadSessionDetail(\n    LoginRequiredMixin, ObjectPermissionRequiredMixin, DetailView\n):\n    model = RawImageUploadSession\n    permission_required = f\"{RawImageUploadSession._meta.app_label}.view_{RawImageUploadSession._meta.model_name}\"\n    raise_exception = True\n\n\nclass ImageViewSet(ReadOnlyModelViewSet):\n    serializer_class = ImageSerializer\n    queryset = Image.objects.all()\n    permission_classes = [DjangoObjectPermissions]\n    filter_backends = [ObjectPermissionsFilter]\n\n    def get_queryset(self):\n        filters = {\n            \"worklist\": self.request.query_params.get(\"worklist\", None),\n            \"study\": self.request.query_params.get(\"study\", None),\n        }\n        filters = {k: v for k, v in filters.items() if v is not None}\n\n        queryset = super().get_queryset().filter(**filters)\n\n        return queryset\n\n\ndef show_image(request, *, pk):\n    from django.shortcuts import render\n\n    try:\n        image_file = ImageFile.objects.select_related(\"image\").get(\n            image=pk, image_type=\"DZI\"\n        )\n    except Image.DoesNotExist:\n        raise Http404(\"File not found.\")\n\n    return render(\n        request,\n        \"cases/show_image.html\",\n        {\"image_file\": image_file, \"url\": image_file.file.url},\n    )\n\n\nclass RawImageUploadSessionViewSet(\n    CreateModelMixin, RetrieveModelMixin, ListModelMixin, GenericViewSet\n):\n    serializer_class = RawImageUploadSessionSerializer\n    queryset = RawImageUploadSession.objects.all()\n    permission_classes = [DjangoObjectOnlyWithCustomPostPermissions]\n    filter_backends = [ObjectPermissionsFilter]\n\n    def perform_create(self, serializer):\n        serializer.save(creator=self.request.user)\n\n    @action(detail=True, methods=[\"patch\"])\n    def process_images(self, request, pk=None):\n        upload_session: RawImageUploadSession = self.get_object()\n        if (\n            upload_session.status == upload_session.PENDING\n            and not upload_session.rawimagefile_set.filter(\n                consumed=True\n            ).exists()\n        ):\n            upload_session.process_images()\n            messages.add_message(\n                request, messages.SUCCESS, \"Image processing job queued.\"\n            )\n            return Response(status=status.HTTP_200_OK)\n        else:\n            messages.add_message(\n                request,\n                messages.ERROR,\n                \"Image processing job could not be queued.\",\n            )\n            return Response(status=status.HTTP_400_BAD_REQUEST)\n\n\nclass RawImageFileViewSet(\n    CreateModelMixin, RetrieveModelMixin, ListModelMixin, GenericViewSet\n):\n    serializer_class = RawImageFileSerializer\n    queryset = RawImageFile.objects.all()\n    permission_classes = [DjangoObjectOnlyWithCustomPostPermissions]\n    filter_backends = [ObjectPermissionsFilter]\n", "path": "app/grandchallenge/cases/views.py"}], "after_files": [{"content": "from django.contrib import messages\nfrom django.http import Http404\nfrom django.views.generic import DetailView\nfrom guardian.mixins import (\n    LoginRequiredMixin,\n    PermissionRequiredMixin as ObjectPermissionRequiredMixin,\n)\nfrom rest_framework import status\nfrom rest_framework.decorators import action\nfrom rest_framework.mixins import (\n    CreateModelMixin,\n    ListModelMixin,\n    RetrieveModelMixin,\n)\nfrom rest_framework.permissions import DjangoObjectPermissions\nfrom rest_framework.response import Response\nfrom rest_framework.viewsets import GenericViewSet, ReadOnlyModelViewSet\nfrom rest_framework_guardian.filters import ObjectPermissionsFilter\n\nfrom grandchallenge.cases.models import (\n    Image,\n    ImageFile,\n    RawImageFile,\n    RawImageUploadSession,\n)\nfrom grandchallenge.cases.serializers import (\n    ImageSerializer,\n    RawImageFileSerializer,\n    RawImageUploadSessionSerializer,\n)\nfrom grandchallenge.core.permissions.rest_framework import (\n    DjangoObjectOnlyWithCustomPostPermissions,\n)\n\n\nclass RawImageUploadSessionDetail(\n    LoginRequiredMixin, ObjectPermissionRequiredMixin, DetailView\n):\n    model = RawImageUploadSession\n    permission_required = f\"{RawImageUploadSession._meta.app_label}.view_{RawImageUploadSession._meta.model_name}\"\n    raise_exception = True\n\n\nclass ImageViewSet(ReadOnlyModelViewSet):\n    serializer_class = ImageSerializer\n    queryset = Image.objects.all()\n    permission_classes = [DjangoObjectPermissions]\n    filter_backends = [ObjectPermissionsFilter]\n\n    def get_queryset(self):\n        filters = {\n            \"worklist\": self.request.query_params.get(\"worklist\", None),\n            \"study\": self.request.query_params.get(\"study\", None),\n            \"origin\": self.request.query_params.get(\"origin\", None),\n        }\n        filters = {k: v for k, v in filters.items() if v is not None}\n\n        queryset = super().get_queryset().filter(**filters)\n\n        return queryset\n\n\ndef show_image(request, *, pk):\n    from django.shortcuts import render\n\n    try:\n        image_file = ImageFile.objects.select_related(\"image\").get(\n            image=pk, image_type=\"DZI\"\n        )\n    except Image.DoesNotExist:\n        raise Http404(\"File not found.\")\n\n    return render(\n        request,\n        \"cases/show_image.html\",\n        {\"image_file\": image_file, \"url\": image_file.file.url},\n    )\n\n\nclass RawImageUploadSessionViewSet(\n    CreateModelMixin, RetrieveModelMixin, ListModelMixin, GenericViewSet\n):\n    serializer_class = RawImageUploadSessionSerializer\n    queryset = RawImageUploadSession.objects.all()\n    permission_classes = [DjangoObjectOnlyWithCustomPostPermissions]\n    filter_backends = [ObjectPermissionsFilter]\n\n    def perform_create(self, serializer):\n        serializer.save(creator=self.request.user)\n\n    @action(detail=True, methods=[\"patch\"])\n    def process_images(self, request, pk=None):\n        upload_session: RawImageUploadSession = self.get_object()\n        if (\n            upload_session.status == upload_session.PENDING\n            and not upload_session.rawimagefile_set.filter(\n                consumed=True\n            ).exists()\n        ):\n            upload_session.process_images()\n            messages.add_message(\n                request, messages.SUCCESS, \"Image processing job queued.\"\n            )\n            return Response(status=status.HTTP_200_OK)\n        else:\n            messages.add_message(\n                request,\n                messages.ERROR,\n                \"Image processing job could not be queued.\",\n            )\n            return Response(status=status.HTTP_400_BAD_REQUEST)\n\n\nclass RawImageFileViewSet(\n    CreateModelMixin, RetrieveModelMixin, ListModelMixin, GenericViewSet\n):\n    serializer_class = RawImageFileSerializer\n    queryset = RawImageFile.objects.all()\n    permission_classes = [DjangoObjectOnlyWithCustomPostPermissions]\n    filter_backends = [ObjectPermissionsFilter]\n", "path": "app/grandchallenge/cases/views.py"}]}