We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add event organizer info to the API
Compute Canada would like to be able to use the API to pull all the events it is hosting and then use this information to populate website.

Might be nice to have the EventBrite IDs there too.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `api/serializers.py`
Content:
```
1 from rest_framework import serializers
2 
3 from workshops.models import Badge, Airport, Person, Event
4 
5 
6 class PersonUsernameSerializer(serializers.ModelSerializer):
7     name = serializers.CharField(source='get_full_name')
8     user = serializers.CharField(source='username')
9 
10     class Meta:
11         model = Person
12         fields = ('name', 'user', )
13 
14 
15 class ExportBadgesSerializer(serializers.ModelSerializer):
16     persons = PersonUsernameSerializer(many=True, source='person_set')
17 
18     class Meta:
19         model = Badge
20         fields = ('name', 'persons')
21 
22 
23 class ExportInstructorLocationsSerializer(serializers.ModelSerializer):
24     name = serializers.CharField(source='fullname')
25     instructors = PersonUsernameSerializer(many=True, source='person_set')
26 
27     class Meta:
28         model = Airport
29         fields = ('name', 'latitude', 'longitude', 'instructors', 'country')
30 
31 
32 class EventSerializer(serializers.ModelSerializer):
33     humandate = serializers.SerializerMethodField()
34     country = serializers.CharField()
35     start = serializers.DateField(format=None)
36     end = serializers.DateField(format=None)
37     url = serializers.URLField(source='website_url')
38 
39     def get_humandate(self, obj):
40         """Render start and end dates as human-readable short date."""
41         return EventSerializer.human_readable_date(obj.start, obj.end)
42 
43     @staticmethod
44     def human_readable_date(date1, date2):
45         """Render start and end dates as human-readable short date."""
46         if date1 and not date2:
47             return '{:%b %d, %Y}-???'.format(date1)
48         elif date2 and not date1:
49             return '???-{:%b %d, %Y}'.format(date2)
50         elif not date2 and not date1:
51             return '???-???'
52 
53         if date1.year == date2.year:
54             if date1.month == date2.month:
55                 return '{:%b %d}-{:%d, %Y}'.format(date1, date2)
56             else:
57                 return '{:%b %d}-{:%b %d, %Y}'.format(date1, date2)
58         else:
59             return '{:%b %d, %Y}-{:%b %d, %Y}'.format(date1, date2)
60 
61     class Meta:
62         model = Event
63         fields = (
64             'slug', 'start', 'end', 'url', 'humandate', 'contact', 'country',
65             'venue', 'address', 'latitude', 'longitude',
66         )
67
```

Path: `api/views.py`
Content:
```
1 from django.db.models import Q
2 from rest_framework.generics import ListAPIView
3 from rest_framework.permissions import IsAuthenticatedOrReadOnly
4 from rest_framework.response import Response
5 from rest_framework.reverse import reverse
6 from rest_framework.views import APIView
7 
8 from workshops.models import Badge, Airport, Event
9 
10 from .serializers import (
11     ExportBadgesSerializer,
12     ExportInstructorLocationsSerializer,
13     EventSerializer,
14 )
15 
16 
17 class ApiRoot(APIView):
18     def get(self, request, format=None):
19         return Response({
20             'export-badges': reverse('api:export-badges', request=request,
21                                      format=format),
22             'export-instructors': reverse('api:export-instructors',
23                                           request=request, format=format),
24             'events-published': reverse('api:events-published',
25                                         request=request, format=format),
26         })
27 
28 
29 class ExportBadgesView(ListAPIView):
30     """List all badges and people who have them."""
31     permission_classes = (IsAuthenticatedOrReadOnly, )
32     paginator = None  # disable pagination
33 
34     queryset = Badge.objects.prefetch_related('person_set')
35     serializer_class = ExportBadgesSerializer
36 
37 
38 class ExportInstructorLocationsView(ListAPIView):
39     """List all airports and instructors located near them."""
40     permission_classes = (IsAuthenticatedOrReadOnly, )
41     paginator = None  # disable pagination
42 
43     queryset = Airport.objects.exclude(person=None) \
44                               .prefetch_related('person_set')
45     serializer_class = ExportInstructorLocationsSerializer
46 
47 
48 class PublishedEvents(ListAPIView):
49     # only events that have both a starting date and a URL
50     permission_classes = (IsAuthenticatedOrReadOnly, )
51     paginator = None  # disable pagination
52 
53     serializer_class = EventSerializer
54     queryset = Event.objects.published_events()
55
```
--- 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/api/serializers.py b/api/serializers.py
--- a/api/serializers.py
+++ b/api/serializers.py
@@ -35,6 +35,7 @@
     start = serializers.DateField(format=None)
     end = serializers.DateField(format=None)
     url = serializers.URLField(source='website_url')
+    eventbrite_id = serializers.CharField(source='reg_key')
 
     def get_humandate(self, obj):
         """Render start and end dates as human-readable short date."""
@@ -62,5 +63,5 @@
         model = Event
         fields = (
             'slug', 'start', 'end', 'url', 'humandate', 'contact', 'country',
-            'venue', 'address', 'latitude', 'longitude',
+            'venue', 'address', 'latitude', 'longitude', 'eventbrite_id',
         )
diff --git a/api/views.py b/api/views.py
--- a/api/views.py
+++ b/api/views.py
@@ -1,5 +1,6 @@
 from django.db.models import Q
 from rest_framework.generics import ListAPIView
+from rest_framework.metadata import SimpleMetadata
 from rest_framework.permissions import IsAuthenticatedOrReadOnly
 from rest_framework.response import Response
 from rest_framework.reverse import reverse
@@ -14,6 +15,21 @@
 )
 
 
+class QueryMetadata(SimpleMetadata):
+    """Additionally include info about query parameters."""
+
+    def determine_metadata(self, request, view):
+        print('doing something')
+        data = super().determine_metadata(request, view)
+
+        try:
+            data['query_params'] = view.get_query_params_description()
+        except AttributeError:
+            pass
+
+        return data
+
+
 class ApiRoot(APIView):
     def get(self, request, format=None):
         return Response({
@@ -46,9 +62,34 @@
 
 
 class PublishedEvents(ListAPIView):
+    """List published events."""
+
     # only events that have both a starting date and a URL
     permission_classes = (IsAuthenticatedOrReadOnly, )
     paginator = None  # disable pagination
 
     serializer_class = EventSerializer
-    queryset = Event.objects.published_events()
+
+    metadata_class = QueryMetadata
+
+    def get_queryset(self):
+        """Optionally restrict the returned event set to events hosted by
+        specific host or administered by specific admin."""
+        queryset = Event.objects.published_events()
+
+        administrator = self.request.query_params.get('administrator', None)
+        if administrator is not None:
+            queryset = queryset.filter(administrator__pk=administrator)
+
+        host = self.request.query_params.get('host', None)
+        if host is not None:
+            queryset = queryset.filter(host__pk=host)
+
+        return queryset
+
+    def get_query_params_description(self):
+        return {
+            'administrator': 'ID of the organization responsible for admin '
+                             'work on events.',
+            'host': 'ID of the organization hosting the event.',
+        }

{"golden_diff": "diff --git a/api/serializers.py b/api/serializers.py\n--- a/api/serializers.py\n+++ b/api/serializers.py\n@@ -35,6 +35,7 @@\n     start = serializers.DateField(format=None)\n     end = serializers.DateField(format=None)\n     url = serializers.URLField(source='website_url')\n+    eventbrite_id = serializers.CharField(source='reg_key')\n \n     def get_humandate(self, obj):\n         \"\"\"Render start and end dates as human-readable short date.\"\"\"\n@@ -62,5 +63,5 @@\n         model = Event\n         fields = (\n             'slug', 'start', 'end', 'url', 'humandate', 'contact', 'country',\n-            'venue', 'address', 'latitude', 'longitude',\n+            'venue', 'address', 'latitude', 'longitude', 'eventbrite_id',\n         )\ndiff --git a/api/views.py b/api/views.py\n--- a/api/views.py\n+++ b/api/views.py\n@@ -1,5 +1,6 @@\n from django.db.models import Q\n from rest_framework.generics import ListAPIView\n+from rest_framework.metadata import SimpleMetadata\n from rest_framework.permissions import IsAuthenticatedOrReadOnly\n from rest_framework.response import Response\n from rest_framework.reverse import reverse\n@@ -14,6 +15,21 @@\n )\n \n \n+class QueryMetadata(SimpleMetadata):\n+    \"\"\"Additionally include info about query parameters.\"\"\"\n+\n+    def determine_metadata(self, request, view):\n+        print('doing something')\n+        data = super().determine_metadata(request, view)\n+\n+        try:\n+            data['query_params'] = view.get_query_params_description()\n+        except AttributeError:\n+            pass\n+\n+        return data\n+\n+\n class ApiRoot(APIView):\n     def get(self, request, format=None):\n         return Response({\n@@ -46,9 +62,34 @@\n \n \n class PublishedEvents(ListAPIView):\n+    \"\"\"List published events.\"\"\"\n+\n     # only events that have both a starting date and a URL\n     permission_classes = (IsAuthenticatedOrReadOnly, )\n     paginator = None  # disable pagination\n \n     serializer_class = EventSerializer\n-    queryset = Event.objects.published_events()\n+\n+    metadata_class = QueryMetadata\n+\n+    def get_queryset(self):\n+        \"\"\"Optionally restrict the returned event set to events hosted by\n+        specific host or administered by specific admin.\"\"\"\n+        queryset = Event.objects.published_events()\n+\n+        administrator = self.request.query_params.get('administrator', None)\n+        if administrator is not None:\n+            queryset = queryset.filter(administrator__pk=administrator)\n+\n+        host = self.request.query_params.get('host', None)\n+        if host is not None:\n+            queryset = queryset.filter(host__pk=host)\n+\n+        return queryset\n+\n+    def get_query_params_description(self):\n+        return {\n+            'administrator': 'ID of the organization responsible for admin '\n+                             'work on events.',\n+            'host': 'ID of the organization hosting the event.',\n+        }\n", "issue": "Add event organizer info to the API\nCompute Canada would like to be able to use the API to pull all the events it is hosting and then use this information to populate website.\n\nMight be nice to have the EventBrite IDs there too.\n\n", "before_files": [{"content": "from rest_framework import serializers\n\nfrom workshops.models import Badge, Airport, Person, Event\n\n\nclass PersonUsernameSerializer(serializers.ModelSerializer):\n    name = serializers.CharField(source='get_full_name')\n    user = serializers.CharField(source='username')\n\n    class Meta:\n        model = Person\n        fields = ('name', 'user', )\n\n\nclass ExportBadgesSerializer(serializers.ModelSerializer):\n    persons = PersonUsernameSerializer(many=True, source='person_set')\n\n    class Meta:\n        model = Badge\n        fields = ('name', 'persons')\n\n\nclass ExportInstructorLocationsSerializer(serializers.ModelSerializer):\n    name = serializers.CharField(source='fullname')\n    instructors = PersonUsernameSerializer(many=True, source='person_set')\n\n    class Meta:\n        model = Airport\n        fields = ('name', 'latitude', 'longitude', 'instructors', 'country')\n\n\nclass EventSerializer(serializers.ModelSerializer):\n    humandate = serializers.SerializerMethodField()\n    country = serializers.CharField()\n    start = serializers.DateField(format=None)\n    end = serializers.DateField(format=None)\n    url = serializers.URLField(source='website_url')\n\n    def get_humandate(self, obj):\n        \"\"\"Render start and end dates as human-readable short date.\"\"\"\n        return EventSerializer.human_readable_date(obj.start, obj.end)\n\n    @staticmethod\n    def human_readable_date(date1, date2):\n        \"\"\"Render start and end dates as human-readable short date.\"\"\"\n        if date1 and not date2:\n            return '{:%b %d, %Y}-???'.format(date1)\n        elif date2 and not date1:\n            return '???-{:%b %d, %Y}'.format(date2)\n        elif not date2 and not date1:\n            return '???-???'\n\n        if date1.year == date2.year:\n            if date1.month == date2.month:\n                return '{:%b %d}-{:%d, %Y}'.format(date1, date2)\n            else:\n                return '{:%b %d}-{:%b %d, %Y}'.format(date1, date2)\n        else:\n            return '{:%b %d, %Y}-{:%b %d, %Y}'.format(date1, date2)\n\n    class Meta:\n        model = Event\n        fields = (\n            'slug', 'start', 'end', 'url', 'humandate', 'contact', 'country',\n            'venue', 'address', 'latitude', 'longitude',\n        )\n", "path": "api/serializers.py"}, {"content": "from django.db.models import Q\nfrom rest_framework.generics import ListAPIView\nfrom rest_framework.permissions import IsAuthenticatedOrReadOnly\nfrom rest_framework.response import Response\nfrom rest_framework.reverse import reverse\nfrom rest_framework.views import APIView\n\nfrom workshops.models import Badge, Airport, Event\n\nfrom .serializers import (\n    ExportBadgesSerializer,\n    ExportInstructorLocationsSerializer,\n    EventSerializer,\n)\n\n\nclass ApiRoot(APIView):\n    def get(self, request, format=None):\n        return Response({\n            'export-badges': reverse('api:export-badges', request=request,\n                                     format=format),\n            'export-instructors': reverse('api:export-instructors',\n                                          request=request, format=format),\n            'events-published': reverse('api:events-published',\n                                        request=request, format=format),\n        })\n\n\nclass ExportBadgesView(ListAPIView):\n    \"\"\"List all badges and people who have them.\"\"\"\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n    paginator = None  # disable pagination\n\n    queryset = Badge.objects.prefetch_related('person_set')\n    serializer_class = ExportBadgesSerializer\n\n\nclass ExportInstructorLocationsView(ListAPIView):\n    \"\"\"List all airports and instructors located near them.\"\"\"\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n    paginator = None  # disable pagination\n\n    queryset = Airport.objects.exclude(person=None) \\\n                              .prefetch_related('person_set')\n    serializer_class = ExportInstructorLocationsSerializer\n\n\nclass PublishedEvents(ListAPIView):\n    # only events that have both a starting date and a URL\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n    paginator = None  # disable pagination\n\n    serializer_class = EventSerializer\n    queryset = Event.objects.published_events()\n", "path": "api/views.py"}], "after_files": [{"content": "from rest_framework import serializers\n\nfrom workshops.models import Badge, Airport, Person, Event\n\n\nclass PersonUsernameSerializer(serializers.ModelSerializer):\n    name = serializers.CharField(source='get_full_name')\n    user = serializers.CharField(source='username')\n\n    class Meta:\n        model = Person\n        fields = ('name', 'user', )\n\n\nclass ExportBadgesSerializer(serializers.ModelSerializer):\n    persons = PersonUsernameSerializer(many=True, source='person_set')\n\n    class Meta:\n        model = Badge\n        fields = ('name', 'persons')\n\n\nclass ExportInstructorLocationsSerializer(serializers.ModelSerializer):\n    name = serializers.CharField(source='fullname')\n    instructors = PersonUsernameSerializer(many=True, source='person_set')\n\n    class Meta:\n        model = Airport\n        fields = ('name', 'latitude', 'longitude', 'instructors', 'country')\n\n\nclass EventSerializer(serializers.ModelSerializer):\n    humandate = serializers.SerializerMethodField()\n    country = serializers.CharField()\n    start = serializers.DateField(format=None)\n    end = serializers.DateField(format=None)\n    url = serializers.URLField(source='website_url')\n    eventbrite_id = serializers.CharField(source='reg_key')\n\n    def get_humandate(self, obj):\n        \"\"\"Render start and end dates as human-readable short date.\"\"\"\n        return EventSerializer.human_readable_date(obj.start, obj.end)\n\n    @staticmethod\n    def human_readable_date(date1, date2):\n        \"\"\"Render start and end dates as human-readable short date.\"\"\"\n        if date1 and not date2:\n            return '{:%b %d, %Y}-???'.format(date1)\n        elif date2 and not date1:\n            return '???-{:%b %d, %Y}'.format(date2)\n        elif not date2 and not date1:\n            return '???-???'\n\n        if date1.year == date2.year:\n            if date1.month == date2.month:\n                return '{:%b %d}-{:%d, %Y}'.format(date1, date2)\n            else:\n                return '{:%b %d}-{:%b %d, %Y}'.format(date1, date2)\n        else:\n            return '{:%b %d, %Y}-{:%b %d, %Y}'.format(date1, date2)\n\n    class Meta:\n        model = Event\n        fields = (\n            'slug', 'start', 'end', 'url', 'humandate', 'contact', 'country',\n            'venue', 'address', 'latitude', 'longitude', 'eventbrite_id',\n        )\n", "path": "api/serializers.py"}, {"content": "from django.db.models import Q\nfrom rest_framework.generics import ListAPIView\nfrom rest_framework.metadata import SimpleMetadata\nfrom rest_framework.permissions import IsAuthenticatedOrReadOnly\nfrom rest_framework.response import Response\nfrom rest_framework.reverse import reverse\nfrom rest_framework.views import APIView\n\nfrom workshops.models import Badge, Airport, Event\n\nfrom .serializers import (\n    ExportBadgesSerializer,\n    ExportInstructorLocationsSerializer,\n    EventSerializer,\n)\n\n\nclass QueryMetadata(SimpleMetadata):\n    \"\"\"Additionally include info about query parameters.\"\"\"\n\n    def determine_metadata(self, request, view):\n        print('doing something')\n        data = super().determine_metadata(request, view)\n\n        try:\n            data['query_params'] = view.get_query_params_description()\n        except AttributeError:\n            pass\n\n        return data\n\n\nclass ApiRoot(APIView):\n    def get(self, request, format=None):\n        return Response({\n            'export-badges': reverse('api:export-badges', request=request,\n                                     format=format),\n            'export-instructors': reverse('api:export-instructors',\n                                          request=request, format=format),\n            'events-published': reverse('api:events-published',\n                                        request=request, format=format),\n        })\n\n\nclass ExportBadgesView(ListAPIView):\n    \"\"\"List all badges and people who have them.\"\"\"\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n    paginator = None  # disable pagination\n\n    queryset = Badge.objects.prefetch_related('person_set')\n    serializer_class = ExportBadgesSerializer\n\n\nclass ExportInstructorLocationsView(ListAPIView):\n    \"\"\"List all airports and instructors located near them.\"\"\"\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n    paginator = None  # disable pagination\n\n    queryset = Airport.objects.exclude(person=None) \\\n                              .prefetch_related('person_set')\n    serializer_class = ExportInstructorLocationsSerializer\n\n\nclass PublishedEvents(ListAPIView):\n    \"\"\"List published events.\"\"\"\n\n    # only events that have both a starting date and a URL\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n    paginator = None  # disable pagination\n\n    serializer_class = EventSerializer\n\n    metadata_class = QueryMetadata\n\n    def get_queryset(self):\n        \"\"\"Optionally restrict the returned event set to events hosted by\n        specific host or administered by specific admin.\"\"\"\n        queryset = Event.objects.published_events()\n\n        administrator = self.request.query_params.get('administrator', None)\n        if administrator is not None:\n            queryset = queryset.filter(administrator__pk=administrator)\n\n        host = self.request.query_params.get('host', None)\n        if host is not None:\n            queryset = queryset.filter(host__pk=host)\n\n        return queryset\n\n    def get_query_params_description(self):\n        return {\n            'administrator': 'ID of the organization responsible for admin '\n                             'work on events.',\n            'host': 'ID of the organization hosting the event.',\n        }\n", "path": "api/views.py"}]}