We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add search parameter to event registrations admin api
### Is your feature request related to a problem? Please describe.
I'm always frustrated when I can't search for a registration in the event admin.

### Describe the solution you'd like
A search parameter (by member.name or name) on `api/v2/admin/events/<id>/registrations/`.

### Motivation
Then we can search for registrations. A parameter is desirable for consistency in making pagination available.

### Describe alternatives you've considered
Local search.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `website/events/api/v2/admin/views.py`
Content:
```
1 from django.http import Http404
2 from oauth2_provider.contrib.rest_framework import IsAuthenticatedOrTokenHasScope
3 from rest_framework import status
4 from rest_framework.exceptions import ValidationError, PermissionDenied
5 from rest_framework.generics import get_object_or_404
6 from rest_framework.response import Response
7 from rest_framework.views import APIView
8 from rest_framework import filters as framework_filters
9 
10 from events import services
11 from events.api.v2.admin import filters
12 from events.api.v2.admin.permissions import IsOrganiser
13 from events.api.v2.admin.serializers.event import (
14     EventListAdminSerializer,
15     EventAdminSerializer,
16 )
17 from events.api.v2.admin.serializers.event_registration import (
18     EventRegistrationAdminSerializer,
19 )
20 from events.exceptions import RegistrationError
21 from events.models import Event, EventRegistration
22 from thaliawebsite.api.v2.admin.views import (
23     AdminListAPIView,
24     AdminRetrieveAPIView,
25     AdminCreateAPIView,
26     AdminUpdateAPIView,
27     AdminDestroyAPIView,
28     AdminPermissionsMixin,
29 )
30 import events.api.v2.filters as normal_filters
31 
32 
33 class EventAdminListCreateAPIView(AdminListAPIView, AdminCreateAPIView):
34     queryset = Event.objects.prefetch_related("organiser")
35     permission_classes = [IsAuthenticatedOrTokenHasScope]
36     required_scopes = ["events:admin"]
37     filter_backends = [
38         framework_filters.OrderingFilter,
39         normal_filters.CategoryFilter,
40         normal_filters.OrganiserFilter,
41         normal_filters.EventDateFilter,
42         filters.PublishedFilter,
43     ]
44     ordering_fields = (
45         "start",
46         "end",
47         "published",
48         "registration_start",
49         "registration_end",
50     )
51 
52     def get_serializer_class(self):
53         if self.request.method.lower() == "post":
54             return EventAdminSerializer
55         return EventListAdminSerializer
56 
57 
58 class EventAdminDetailAPIView(
59     AdminRetrieveAPIView, AdminUpdateAPIView, AdminDestroyAPIView
60 ):
61     queryset = Event.objects.all()
62     serializer_class = EventAdminSerializer
63     permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]
64     required_scopes = ["events:admin"]
65 
66 
67 class EventRegistrationAdminListView(AdminListAPIView, AdminCreateAPIView):
68     """Returns a list of registrations."""
69 
70     serializer_class = EventRegistrationAdminSerializer
71     permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]
72     required_scopes = ["events:admin"]
73     filter_backends = (
74         framework_filters.OrderingFilter,
75         filters.EventRegistrationCancelledFilter,
76     )
77     ordering_fields = ("queue_position", "date", "date_cancelled")
78 
79     def get_queryset(self):
80         event = get_object_or_404(Event, pk=self.kwargs.get("pk"))
81         if event:
82             return EventRegistration.objects.filter(event_id=event).prefetch_related(
83                 "member", "member__profile"
84             )
85         return EventRegistration.objects.none()
86 
87 
88 class EventRegistrationAdminDetailView(
89     AdminRetrieveAPIView, AdminUpdateAPIView, AdminDestroyAPIView
90 ):
91     """Returns details of an event registration."""
92 
93     serializer_class = EventRegistrationAdminSerializer
94     queryset = EventRegistration.objects.all()
95     permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]
96     required_scopes = ["events:admin"]
97     event_lookup_field = "event_id"
98 
99     def get_queryset(self):
100         return super().get_queryset().filter(event=self.kwargs["event_id"])
101 
102 
103 class EventRegistrationAdminFieldsView(AdminPermissionsMixin, APIView):
104     """Returns details of an event registration."""
105 
106     permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]
107     required_scopes = ["events:admin"]
108 
109     def get_queryset(self):
110         return EventRegistration.objects.filter(event=self.kwargs["event_id"])
111 
112     def get_object(self):
113         event_registration = get_object_or_404(
114             EventRegistration,
115             event=self.kwargs["event_id"],
116             pk=self.kwargs["registration_id"],
117         )
118 
119         if not event_registration.event.has_fields:
120             raise Http404
121 
122         return event_registration
123 
124     def get(self, request, *args, **kwargs):
125         return Response(
126             data=services.registration_fields(request, registration=self.get_object()),
127             status=status.HTTP_200_OK,
128         )
129 
130     def put(self, request, *args, **kwargs):
131         original = services.registration_fields(request, registration=self.get_object())
132         required_keys = set(original.keys()) - set(request.data.keys())
133         if len(required_keys) > 0:
134             raise ValidationError(
135                 f"Missing keys '{', '.join(required_keys)}' in request",
136                 status.HTTP_400_BAD_REQUEST,
137             )
138 
139         services.update_registration(
140             registration=self.get_object(), field_values=request.data.items()
141         )
142 
143         return Response(
144             data=services.registration_fields(request, registration=self.get_object()),
145             status=status.HTTP_200_OK,
146         )
147 
148     def patch(self, request, *args, **kwargs):
149         services.update_registration(
150             registration=self.get_object(), field_values=request.data.items()
151         )
152 
153         return Response(
154             data=services.registration_fields(request, registration=self.get_object()),
155             status=status.HTTP_200_OK,
156         )
157
```
--- 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/website/events/api/v2/admin/views.py b/website/events/api/v2/admin/views.py
--- a/website/events/api/v2/admin/views.py
+++ b/website/events/api/v2/admin/views.py
@@ -72,9 +72,15 @@
     required_scopes = ["events:admin"]
     filter_backends = (
         framework_filters.OrderingFilter,
+        framework_filters.SearchFilter,
         filters.EventRegistrationCancelledFilter,
     )
     ordering_fields = ("queue_position", "date", "date_cancelled")
+    search_fields = (
+        "member__first_name",
+        "member__last_name",
+        "name",
+    )
 
     def get_queryset(self):
         event = get_object_or_404(Event, pk=self.kwargs.get("pk"))

{"golden_diff": "diff --git a/website/events/api/v2/admin/views.py b/website/events/api/v2/admin/views.py\n--- a/website/events/api/v2/admin/views.py\n+++ b/website/events/api/v2/admin/views.py\n@@ -72,9 +72,15 @@\n     required_scopes = [\"events:admin\"]\n     filter_backends = (\n         framework_filters.OrderingFilter,\n+        framework_filters.SearchFilter,\n         filters.EventRegistrationCancelledFilter,\n     )\n     ordering_fields = (\"queue_position\", \"date\", \"date_cancelled\")\n+    search_fields = (\n+        \"member__first_name\",\n+        \"member__last_name\",\n+        \"name\",\n+    )\n \n     def get_queryset(self):\n         event = get_object_or_404(Event, pk=self.kwargs.get(\"pk\"))\n", "issue": "Add search parameter to event registrations admin api\n### Is your feature request related to a problem? Please describe.\r\nI'm always frustrated when I can't search for a registration in the event admin.\r\n\r\n### Describe the solution you'd like\r\nA search parameter (by member.name or name) on `api/v2/admin/events/<id>/registrations/`.\r\n\r\n### Motivation\r\nThen we can search for registrations. A parameter is desirable for consistency in making pagination available.\r\n\r\n### Describe alternatives you've considered\r\nLocal search.\r\n\n", "before_files": [{"content": "from django.http import Http404\nfrom oauth2_provider.contrib.rest_framework import IsAuthenticatedOrTokenHasScope\nfrom rest_framework import status\nfrom rest_framework.exceptions import ValidationError, PermissionDenied\nfrom rest_framework.generics import get_object_or_404\nfrom rest_framework.response import Response\nfrom rest_framework.views import APIView\nfrom rest_framework import filters as framework_filters\n\nfrom events import services\nfrom events.api.v2.admin import filters\nfrom events.api.v2.admin.permissions import IsOrganiser\nfrom events.api.v2.admin.serializers.event import (\n    EventListAdminSerializer,\n    EventAdminSerializer,\n)\nfrom events.api.v2.admin.serializers.event_registration import (\n    EventRegistrationAdminSerializer,\n)\nfrom events.exceptions import RegistrationError\nfrom events.models import Event, EventRegistration\nfrom thaliawebsite.api.v2.admin.views import (\n    AdminListAPIView,\n    AdminRetrieveAPIView,\n    AdminCreateAPIView,\n    AdminUpdateAPIView,\n    AdminDestroyAPIView,\n    AdminPermissionsMixin,\n)\nimport events.api.v2.filters as normal_filters\n\n\nclass EventAdminListCreateAPIView(AdminListAPIView, AdminCreateAPIView):\n    queryset = Event.objects.prefetch_related(\"organiser\")\n    permission_classes = [IsAuthenticatedOrTokenHasScope]\n    required_scopes = [\"events:admin\"]\n    filter_backends = [\n        framework_filters.OrderingFilter,\n        normal_filters.CategoryFilter,\n        normal_filters.OrganiserFilter,\n        normal_filters.EventDateFilter,\n        filters.PublishedFilter,\n    ]\n    ordering_fields = (\n        \"start\",\n        \"end\",\n        \"published\",\n        \"registration_start\",\n        \"registration_end\",\n    )\n\n    def get_serializer_class(self):\n        if self.request.method.lower() == \"post\":\n            return EventAdminSerializer\n        return EventListAdminSerializer\n\n\nclass EventAdminDetailAPIView(\n    AdminRetrieveAPIView, AdminUpdateAPIView, AdminDestroyAPIView\n):\n    queryset = Event.objects.all()\n    serializer_class = EventAdminSerializer\n    permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]\n    required_scopes = [\"events:admin\"]\n\n\nclass EventRegistrationAdminListView(AdminListAPIView, AdminCreateAPIView):\n    \"\"\"Returns a list of registrations.\"\"\"\n\n    serializer_class = EventRegistrationAdminSerializer\n    permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]\n    required_scopes = [\"events:admin\"]\n    filter_backends = (\n        framework_filters.OrderingFilter,\n        filters.EventRegistrationCancelledFilter,\n    )\n    ordering_fields = (\"queue_position\", \"date\", \"date_cancelled\")\n\n    def get_queryset(self):\n        event = get_object_or_404(Event, pk=self.kwargs.get(\"pk\"))\n        if event:\n            return EventRegistration.objects.filter(event_id=event).prefetch_related(\n                \"member\", \"member__profile\"\n            )\n        return EventRegistration.objects.none()\n\n\nclass EventRegistrationAdminDetailView(\n    AdminRetrieveAPIView, AdminUpdateAPIView, AdminDestroyAPIView\n):\n    \"\"\"Returns details of an event registration.\"\"\"\n\n    serializer_class = EventRegistrationAdminSerializer\n    queryset = EventRegistration.objects.all()\n    permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]\n    required_scopes = [\"events:admin\"]\n    event_lookup_field = \"event_id\"\n\n    def get_queryset(self):\n        return super().get_queryset().filter(event=self.kwargs[\"event_id\"])\n\n\nclass EventRegistrationAdminFieldsView(AdminPermissionsMixin, APIView):\n    \"\"\"Returns details of an event registration.\"\"\"\n\n    permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]\n    required_scopes = [\"events:admin\"]\n\n    def get_queryset(self):\n        return EventRegistration.objects.filter(event=self.kwargs[\"event_id\"])\n\n    def get_object(self):\n        event_registration = get_object_or_404(\n            EventRegistration,\n            event=self.kwargs[\"event_id\"],\n            pk=self.kwargs[\"registration_id\"],\n        )\n\n        if not event_registration.event.has_fields:\n            raise Http404\n\n        return event_registration\n\n    def get(self, request, *args, **kwargs):\n        return Response(\n            data=services.registration_fields(request, registration=self.get_object()),\n            status=status.HTTP_200_OK,\n        )\n\n    def put(self, request, *args, **kwargs):\n        original = services.registration_fields(request, registration=self.get_object())\n        required_keys = set(original.keys()) - set(request.data.keys())\n        if len(required_keys) > 0:\n            raise ValidationError(\n                f\"Missing keys '{', '.join(required_keys)}' in request\",\n                status.HTTP_400_BAD_REQUEST,\n            )\n\n        services.update_registration(\n            registration=self.get_object(), field_values=request.data.items()\n        )\n\n        return Response(\n            data=services.registration_fields(request, registration=self.get_object()),\n            status=status.HTTP_200_OK,\n        )\n\n    def patch(self, request, *args, **kwargs):\n        services.update_registration(\n            registration=self.get_object(), field_values=request.data.items()\n        )\n\n        return Response(\n            data=services.registration_fields(request, registration=self.get_object()),\n            status=status.HTTP_200_OK,\n        )\n", "path": "website/events/api/v2/admin/views.py"}], "after_files": [{"content": "from django.http import Http404\nfrom oauth2_provider.contrib.rest_framework import IsAuthenticatedOrTokenHasScope\nfrom rest_framework import status\nfrom rest_framework.exceptions import ValidationError, PermissionDenied\nfrom rest_framework.generics import get_object_or_404\nfrom rest_framework.response import Response\nfrom rest_framework.views import APIView\nfrom rest_framework import filters as framework_filters\n\nfrom events import services\nfrom events.api.v2.admin import filters\nfrom events.api.v2.admin.permissions import IsOrganiser\nfrom events.api.v2.admin.serializers.event import (\n    EventListAdminSerializer,\n    EventAdminSerializer,\n)\nfrom events.api.v2.admin.serializers.event_registration import (\n    EventRegistrationAdminSerializer,\n)\nfrom events.exceptions import RegistrationError\nfrom events.models import Event, EventRegistration\nfrom thaliawebsite.api.v2.admin.views import (\n    AdminListAPIView,\n    AdminRetrieveAPIView,\n    AdminCreateAPIView,\n    AdminUpdateAPIView,\n    AdminDestroyAPIView,\n    AdminPermissionsMixin,\n)\nimport events.api.v2.filters as normal_filters\n\n\nclass EventAdminListCreateAPIView(AdminListAPIView, AdminCreateAPIView):\n    queryset = Event.objects.prefetch_related(\"organiser\")\n    permission_classes = [IsAuthenticatedOrTokenHasScope]\n    required_scopes = [\"events:admin\"]\n    filter_backends = [\n        framework_filters.OrderingFilter,\n        normal_filters.CategoryFilter,\n        normal_filters.OrganiserFilter,\n        normal_filters.EventDateFilter,\n        filters.PublishedFilter,\n    ]\n    ordering_fields = (\n        \"start\",\n        \"end\",\n        \"published\",\n        \"registration_start\",\n        \"registration_end\",\n    )\n\n    def get_serializer_class(self):\n        if self.request.method.lower() == \"post\":\n            return EventAdminSerializer\n        return EventListAdminSerializer\n\n\nclass EventAdminDetailAPIView(\n    AdminRetrieveAPIView, AdminUpdateAPIView, AdminDestroyAPIView\n):\n    queryset = Event.objects.all()\n    serializer_class = EventAdminSerializer\n    permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]\n    required_scopes = [\"events:admin\"]\n\n\nclass EventRegistrationAdminListView(AdminListAPIView, AdminCreateAPIView):\n    \"\"\"Returns a list of registrations.\"\"\"\n\n    serializer_class = EventRegistrationAdminSerializer\n    permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]\n    required_scopes = [\"events:admin\"]\n    filter_backends = (\n        framework_filters.OrderingFilter,\n        framework_filters.SearchFilter,\n        filters.EventRegistrationCancelledFilter,\n    )\n    ordering_fields = (\"queue_position\", \"date\", \"date_cancelled\")\n    search_fields = (\n        \"member__first_name\",\n        \"member__last_name\",\n        \"name\",\n    )\n\n    def get_queryset(self):\n        event = get_object_or_404(Event, pk=self.kwargs.get(\"pk\"))\n        if event:\n            return EventRegistration.objects.filter(event_id=event).prefetch_related(\n                \"member\", \"member__profile\"\n            )\n        return EventRegistration.objects.none()\n\n\nclass EventRegistrationAdminDetailView(\n    AdminRetrieveAPIView, AdminUpdateAPIView, AdminDestroyAPIView\n):\n    \"\"\"Returns details of an event registration.\"\"\"\n\n    serializer_class = EventRegistrationAdminSerializer\n    queryset = EventRegistration.objects.all()\n    permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]\n    required_scopes = [\"events:admin\"]\n    event_lookup_field = \"event_id\"\n\n    def get_queryset(self):\n        return super().get_queryset().filter(event=self.kwargs[\"event_id\"])\n\n\nclass EventRegistrationAdminFieldsView(AdminPermissionsMixin, APIView):\n    \"\"\"Returns details of an event registration.\"\"\"\n\n    permission_classes = [IsOrganiser, IsAuthenticatedOrTokenHasScope]\n    required_scopes = [\"events:admin\"]\n\n    def get_queryset(self):\n        return EventRegistration.objects.filter(event=self.kwargs[\"event_id\"])\n\n    def get_object(self):\n        event_registration = get_object_or_404(\n            EventRegistration,\n            event=self.kwargs[\"event_id\"],\n            pk=self.kwargs[\"registration_id\"],\n        )\n\n        if not event_registration.event.has_fields:\n            raise Http404\n\n        return event_registration\n\n    def get(self, request, *args, **kwargs):\n        return Response(\n            data=services.registration_fields(request, registration=self.get_object()),\n            status=status.HTTP_200_OK,\n        )\n\n    def put(self, request, *args, **kwargs):\n        original = services.registration_fields(request, registration=self.get_object())\n        required_keys = set(original.keys()) - set(request.data.keys())\n        if len(required_keys) > 0:\n            raise ValidationError(\n                f\"Missing keys '{', '.join(required_keys)}' in request\",\n                status.HTTP_400_BAD_REQUEST,\n            )\n\n        services.update_registration(\n            registration=self.get_object(), field_values=request.data.items()\n        )\n\n        return Response(\n            data=services.registration_fields(request, registration=self.get_object()),\n            status=status.HTTP_200_OK,\n        )\n\n    def patch(self, request, *args, **kwargs):\n        services.update_registration(\n            registration=self.get_object(), field_values=request.data.items()\n        )\n\n        return Response(\n            data=services.registration_fields(request, registration=self.get_object()),\n            status=status.HTTP_200_OK,\n        )\n", "path": "website/events/api/v2/admin/views.py"}]}