prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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()
  
  
  
  </issue>
  <code>
  [start of app/grandchallenge/cases/views.py]
  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 of app/grandchallenge/cases/views.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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}
  
verification_info: {"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"}]}