We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add organisers back to event admin list
### Is your feature request related to a problem? Please describe.
The organiser column was removed #2459. 

### Describe the solution you'd like
A comma-separated list of organisers, optionally as links to the organiser's admin pages.

### Motivation
Then you get a nice overview of who does which events.

### Describe alternatives you've considered
Leave it.


--- 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/admin/event.py`
Content:
```
1 """Registers admin interfaces for the event model."""
2 
3 from django.contrib import admin, messages
4 from django.template.defaultfilters import date as _date
5 from django.urls import path, reverse
6 from django.utils import timezone
7 from django.utils.html import format_html
8 from django.utils.translation import gettext_lazy as _
9 
10 from events import emails, models, services
11 from events.admin.filters import LectureYearFilter
12 from events.admin.forms import EventAdminForm, RegistrationInformationFieldForm
13 from events.admin.inlines import (
14     PizzaEventInline,
15     PromotionRequestInline,
16     RegistrationInformationFieldInline,
17 )
18 from events.admin.views import (
19     EventAdminDetails,
20     EventMarkPresentQR,
21     EventRegistrationsExport,
22 )
23 from utils.admin import DoNextModelAdmin
24 
25 
26 @admin.register(models.Event)
27 class EventAdmin(DoNextModelAdmin):
28     """Manage the events."""
29 
30     form = EventAdminForm
31 
32     inlines = (
33         RegistrationInformationFieldInline,
34         PizzaEventInline,
35         PromotionRequestInline,
36     )
37 
38     list_display = (
39         "overview_link",
40         "event_date",
41         "registration_date",
42         "num_participants",
43         "category",
44         "published",
45         "edit_link",
46     )
47     list_display_links = ("edit_link",)
48     list_filter = (LectureYearFilter, "start", "published", "category")
49     actions = ("make_published", "make_unpublished")
50     date_hierarchy = "start"
51     search_fields = ("title", "description")
52     prepopulated_fields = {
53         "map_location": ("location",),
54     }
55 
56     filter_horizontal = ("documents", "organisers")
57 
58     fieldsets = (
59         (
60             _("General"),
61             {
62                 "fields": (
63                     "title",
64                     "slug",
65                     "published",
66                     "organisers",
67                 )
68             },
69         ),
70         (
71             _("Detail"),
72             {
73                 "fields": (
74                     "category",
75                     "start",
76                     "end",
77                     "description",
78                     "caption",
79                     "location",
80                     "map_location",
81                 ),
82                 "classes": ("collapse", "start-open"),
83             },
84         ),
85         (
86             _("Registrations"),
87             {
88                 "fields": (
89                     "price",
90                     "fine",
91                     "tpay_allowed",
92                     "max_participants",
93                     "registration_without_membership",
94                     "registration_start",
95                     "registration_end",
96                     "cancel_deadline",
97                     "send_cancel_email",
98                     "optional_registrations",
99                     "no_registration_message",
100                 ),
101                 "classes": ("collapse",),
102             },
103         ),
104         (
105             _("Extra"),
106             {"fields": ("documents", "shift"), "classes": ("collapse",)},
107         ),
108     )
109 
110     def get_queryset(self, request):
111         return super().get_queryset(request).select_properties("participant_count")
112 
113     def get_form(self, request, obj=None, change=False, **kwargs):
114         form = super().get_form(request, obj, change, **kwargs)
115         form.clean = lambda form: form.instance.clean_changes(form.changed_data)
116         form.request = request
117         return form
118 
119     def overview_link(self, obj):
120         return format_html(
121             '<a href="{link}">{title}</a>',
122             link=reverse("admin:events_event_details", kwargs={"pk": obj.pk}),
123             title=obj.title,
124         )
125 
126     def has_change_permission(self, request, obj=None):
127         """Only allow access to the change form if the user is an organiser."""
128         if obj is not None and not services.is_organiser(request.member, obj):
129             return False
130         return super().has_change_permission(request, obj)
131 
132     def event_date(self, obj):
133         event_date = timezone.make_naive(obj.start)
134         return _date(event_date, "l d b Y, G:i")
135 
136     event_date.short_description = _("Event Date")
137     event_date.admin_order_field = "start"
138 
139     def registration_date(self, obj):
140         if obj.registration_start is not None:
141             start_date = timezone.make_naive(obj.registration_start)
142         else:
143             start_date = obj.registration_start
144 
145         return _date(start_date, "l d b Y, G:i")
146 
147     registration_date.short_description = _("Registration Start")
148     registration_date.admin_order_field = "registration_start"
149 
150     def edit_link(self, obj):
151         return _("Edit")
152 
153     edit_link.short_description = ""
154 
155     def num_participants(self, obj):
156         """Pretty-print the number of participants."""
157         num = obj.participant_count  # prefetched aggregateproperty
158         if not obj.max_participants:
159             return f"{num}/∞"
160         return f"{num}/{obj.max_participants}"
161 
162     num_participants.short_description = _("Number of participants")
163 
164     def make_published(self, request, queryset):
165         """Change the status of the event to published."""
166         self._change_published(request, queryset, True)
167 
168     make_published.short_description = _("Publish selected events")
169 
170     def make_unpublished(self, request, queryset):
171         """Change the status of the event to unpublished."""
172         self._change_published(request, queryset, False)
173 
174     make_unpublished.short_description = _("Unpublish selected events")
175 
176     @staticmethod
177     def _change_published(request, queryset, published):
178         if not request.user.is_superuser:
179             queryset = queryset.filter(
180                 organisers__in=request.member.get_member_groups()
181             )
182         queryset.update(published=published)
183 
184     def save_formset(self, request, form, formset, change):
185         """Save formsets with their order."""
186         formset.save()
187 
188         informationfield_forms = (
189             x
190             for x in formset.forms
191             if isinstance(x, RegistrationInformationFieldForm)
192             and "DELETE" not in x.changed_data
193         )
194         form.instance.set_registrationinformationfield_order(
195             [
196                 f.instance.pk
197                 for f in sorted(
198                     informationfield_forms,
199                     key=lambda x: (x.cleaned_data["order"], x.instance.pk),
200                 )
201             ]
202         )
203         form.instance.save()
204 
205     def save_model(self, request, obj, form, change):
206         if change and "max_participants" in form.changed_data:
207             prev = self.model.objects.get(id=obj.id)
208             prev_limit = prev.max_participants
209             self_limit = obj.max_participants
210             if prev_limit is None:
211                 prev_limit = prev.participant_count
212             if self_limit is None:
213                 self_limit = obj.participant_count
214 
215             if prev_limit < self_limit and prev_limit < obj.participant_count:
216                 diff = self_limit - prev_limit
217                 joiners = prev.queue[:diff]
218                 for registration in joiners:
219                     emails.notify_waiting(obj, registration)
220                 messages.info(
221                     request,
222                     "The maximum number of participants was increased. Any members that moved from the waiting list to the participants list have been notified.",
223                 )
224             elif self_limit < prev_limit and self_limit < obj.participant_count:
225                 diff = self_limit - prev_limit
226                 leavers = prev.registrations[self_limit:]
227                 address = map(lambda r: r.email, leavers)
228                 link = "mailto:?bcc=" + ",".join(address)
229                 messages.warning(
230                     request,
231                     format_html(
232                         "The maximum number of participants was decreased and some members moved to the waiting list. <a href='{}' style='text-decoration: underline;'>Use this link to send them an email.</a>",
233                         link,
234                     ),
235                 )
236         super().save_model(request, obj, form, change)
237 
238     def get_actions(self, request):
239         actions = super().get_actions(request)
240         if "delete_selected" in actions:
241             del actions["delete_selected"]
242         return actions
243 
244     def get_formsets_with_inlines(self, request, obj=None):
245         for inline in self.get_inline_instances(request, obj):
246             if self.has_change_permission(request, obj) or obj is None:
247                 yield inline.get_formset(request, obj), inline
248 
249     def get_urls(self):
250         urls = super().get_urls()
251         custom_urls = [
252             path(
253                 "<int:pk>/details/",
254                 self.admin_site.admin_view(EventAdminDetails.as_view()),
255                 name="events_event_details",
256             ),
257             path(
258                 "<int:pk>/export/",
259                 self.admin_site.admin_view(EventRegistrationsExport.as_view()),
260                 name="events_event_export",
261             ),
262             path(
263                 "<int:pk>/mark-present-qr/",
264                 self.admin_site.admin_view(EventMarkPresentQR.as_view()),
265                 name="events_event_mark_present_qr",
266             ),
267         ]
268         return custom_urls + urls
269
```
--- 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/admin/event.py b/website/events/admin/event.py
--- a/website/events/admin/event.py
+++ b/website/events/admin/event.py
@@ -40,6 +40,7 @@
         "event_date",
         "registration_date",
         "num_participants",
+        "get_organisers",
         "category",
         "published",
         "edit_link",
@@ -108,7 +109,12 @@
     )
 
     def get_queryset(self, request):
-        return super().get_queryset(request).select_properties("participant_count")
+        return (
+            super()
+            .get_queryset(request)
+            .select_properties("participant_count")
+            .prefetch_related("organisers")
+        )
 
     def get_form(self, request, obj=None, change=False, **kwargs):
         form = super().get_form(request, obj, change, **kwargs)
@@ -161,6 +167,11 @@
 
     num_participants.short_description = _("Number of participants")
 
+    def get_organisers(self, obj):
+        return ", ".join(str(o) for o in obj.organisers.all())
+
+    get_organisers.short_description = _("Organisers")
+
     def make_published(self, request, queryset):
         """Change the status of the event to published."""
         self._change_published(request, queryset, True)

{"golden_diff": "diff --git a/website/events/admin/event.py b/website/events/admin/event.py\n--- a/website/events/admin/event.py\n+++ b/website/events/admin/event.py\n@@ -40,6 +40,7 @@\n         \"event_date\",\n         \"registration_date\",\n         \"num_participants\",\n+        \"get_organisers\",\n         \"category\",\n         \"published\",\n         \"edit_link\",\n@@ -108,7 +109,12 @@\n     )\n \n     def get_queryset(self, request):\n-        return super().get_queryset(request).select_properties(\"participant_count\")\n+        return (\n+            super()\n+            .get_queryset(request)\n+            .select_properties(\"participant_count\")\n+            .prefetch_related(\"organisers\")\n+        )\n \n     def get_form(self, request, obj=None, change=False, **kwargs):\n         form = super().get_form(request, obj, change, **kwargs)\n@@ -161,6 +167,11 @@\n \n     num_participants.short_description = _(\"Number of participants\")\n \n+    def get_organisers(self, obj):\n+        return \", \".join(str(o) for o in obj.organisers.all())\n+\n+    get_organisers.short_description = _(\"Organisers\")\n+\n     def make_published(self, request, queryset):\n         \"\"\"Change the status of the event to published.\"\"\"\n         self._change_published(request, queryset, True)\n", "issue": "Add organisers back to event admin list\n### Is your feature request related to a problem? Please describe.\r\nThe organiser column was removed #2459. \r\n\r\n### Describe the solution you'd like\r\nA comma-separated list of organisers, optionally as links to the organiser's admin pages.\r\n\r\n### Motivation\r\nThen you get a nice overview of who does which events.\r\n\r\n### Describe alternatives you've considered\r\nLeave it.\r\n\n", "before_files": [{"content": "\"\"\"Registers admin interfaces for the event model.\"\"\"\n\nfrom django.contrib import admin, messages\nfrom django.template.defaultfilters import date as _date\nfrom django.urls import path, reverse\nfrom django.utils import timezone\nfrom django.utils.html import format_html\nfrom django.utils.translation import gettext_lazy as _\n\nfrom events import emails, models, services\nfrom events.admin.filters import LectureYearFilter\nfrom events.admin.forms import EventAdminForm, RegistrationInformationFieldForm\nfrom events.admin.inlines import (\n    PizzaEventInline,\n    PromotionRequestInline,\n    RegistrationInformationFieldInline,\n)\nfrom events.admin.views import (\n    EventAdminDetails,\n    EventMarkPresentQR,\n    EventRegistrationsExport,\n)\nfrom utils.admin import DoNextModelAdmin\n\n\n@admin.register(models.Event)\nclass EventAdmin(DoNextModelAdmin):\n    \"\"\"Manage the events.\"\"\"\n\n    form = EventAdminForm\n\n    inlines = (\n        RegistrationInformationFieldInline,\n        PizzaEventInline,\n        PromotionRequestInline,\n    )\n\n    list_display = (\n        \"overview_link\",\n        \"event_date\",\n        \"registration_date\",\n        \"num_participants\",\n        \"category\",\n        \"published\",\n        \"edit_link\",\n    )\n    list_display_links = (\"edit_link\",)\n    list_filter = (LectureYearFilter, \"start\", \"published\", \"category\")\n    actions = (\"make_published\", \"make_unpublished\")\n    date_hierarchy = \"start\"\n    search_fields = (\"title\", \"description\")\n    prepopulated_fields = {\n        \"map_location\": (\"location\",),\n    }\n\n    filter_horizontal = (\"documents\", \"organisers\")\n\n    fieldsets = (\n        (\n            _(\"General\"),\n            {\n                \"fields\": (\n                    \"title\",\n                    \"slug\",\n                    \"published\",\n                    \"organisers\",\n                )\n            },\n        ),\n        (\n            _(\"Detail\"),\n            {\n                \"fields\": (\n                    \"category\",\n                    \"start\",\n                    \"end\",\n                    \"description\",\n                    \"caption\",\n                    \"location\",\n                    \"map_location\",\n                ),\n                \"classes\": (\"collapse\", \"start-open\"),\n            },\n        ),\n        (\n            _(\"Registrations\"),\n            {\n                \"fields\": (\n                    \"price\",\n                    \"fine\",\n                    \"tpay_allowed\",\n                    \"max_participants\",\n                    \"registration_without_membership\",\n                    \"registration_start\",\n                    \"registration_end\",\n                    \"cancel_deadline\",\n                    \"send_cancel_email\",\n                    \"optional_registrations\",\n                    \"no_registration_message\",\n                ),\n                \"classes\": (\"collapse\",),\n            },\n        ),\n        (\n            _(\"Extra\"),\n            {\"fields\": (\"documents\", \"shift\"), \"classes\": (\"collapse\",)},\n        ),\n    )\n\n    def get_queryset(self, request):\n        return super().get_queryset(request).select_properties(\"participant_count\")\n\n    def get_form(self, request, obj=None, change=False, **kwargs):\n        form = super().get_form(request, obj, change, **kwargs)\n        form.clean = lambda form: form.instance.clean_changes(form.changed_data)\n        form.request = request\n        return form\n\n    def overview_link(self, obj):\n        return format_html(\n            '<a href=\"{link}\">{title}</a>',\n            link=reverse(\"admin:events_event_details\", kwargs={\"pk\": obj.pk}),\n            title=obj.title,\n        )\n\n    def has_change_permission(self, request, obj=None):\n        \"\"\"Only allow access to the change form if the user is an organiser.\"\"\"\n        if obj is not None and not services.is_organiser(request.member, obj):\n            return False\n        return super().has_change_permission(request, obj)\n\n    def event_date(self, obj):\n        event_date = timezone.make_naive(obj.start)\n        return _date(event_date, \"l d b Y, G:i\")\n\n    event_date.short_description = _(\"Event Date\")\n    event_date.admin_order_field = \"start\"\n\n    def registration_date(self, obj):\n        if obj.registration_start is not None:\n            start_date = timezone.make_naive(obj.registration_start)\n        else:\n            start_date = obj.registration_start\n\n        return _date(start_date, \"l d b Y, G:i\")\n\n    registration_date.short_description = _(\"Registration Start\")\n    registration_date.admin_order_field = \"registration_start\"\n\n    def edit_link(self, obj):\n        return _(\"Edit\")\n\n    edit_link.short_description = \"\"\n\n    def num_participants(self, obj):\n        \"\"\"Pretty-print the number of participants.\"\"\"\n        num = obj.participant_count  # prefetched aggregateproperty\n        if not obj.max_participants:\n            return f\"{num}/\u221e\"\n        return f\"{num}/{obj.max_participants}\"\n\n    num_participants.short_description = _(\"Number of participants\")\n\n    def make_published(self, request, queryset):\n        \"\"\"Change the status of the event to published.\"\"\"\n        self._change_published(request, queryset, True)\n\n    make_published.short_description = _(\"Publish selected events\")\n\n    def make_unpublished(self, request, queryset):\n        \"\"\"Change the status of the event to unpublished.\"\"\"\n        self._change_published(request, queryset, False)\n\n    make_unpublished.short_description = _(\"Unpublish selected events\")\n\n    @staticmethod\n    def _change_published(request, queryset, published):\n        if not request.user.is_superuser:\n            queryset = queryset.filter(\n                organisers__in=request.member.get_member_groups()\n            )\n        queryset.update(published=published)\n\n    def save_formset(self, request, form, formset, change):\n        \"\"\"Save formsets with their order.\"\"\"\n        formset.save()\n\n        informationfield_forms = (\n            x\n            for x in formset.forms\n            if isinstance(x, RegistrationInformationFieldForm)\n            and \"DELETE\" not in x.changed_data\n        )\n        form.instance.set_registrationinformationfield_order(\n            [\n                f.instance.pk\n                for f in sorted(\n                    informationfield_forms,\n                    key=lambda x: (x.cleaned_data[\"order\"], x.instance.pk),\n                )\n            ]\n        )\n        form.instance.save()\n\n    def save_model(self, request, obj, form, change):\n        if change and \"max_participants\" in form.changed_data:\n            prev = self.model.objects.get(id=obj.id)\n            prev_limit = prev.max_participants\n            self_limit = obj.max_participants\n            if prev_limit is None:\n                prev_limit = prev.participant_count\n            if self_limit is None:\n                self_limit = obj.participant_count\n\n            if prev_limit < self_limit and prev_limit < obj.participant_count:\n                diff = self_limit - prev_limit\n                joiners = prev.queue[:diff]\n                for registration in joiners:\n                    emails.notify_waiting(obj, registration)\n                messages.info(\n                    request,\n                    \"The maximum number of participants was increased. Any members that moved from the waiting list to the participants list have been notified.\",\n                )\n            elif self_limit < prev_limit and self_limit < obj.participant_count:\n                diff = self_limit - prev_limit\n                leavers = prev.registrations[self_limit:]\n                address = map(lambda r: r.email, leavers)\n                link = \"mailto:?bcc=\" + \",\".join(address)\n                messages.warning(\n                    request,\n                    format_html(\n                        \"The maximum number of participants was decreased and some members moved to the waiting list. <a href='{}' style='text-decoration: underline;'>Use this link to send them an email.</a>\",\n                        link,\n                    ),\n                )\n        super().save_model(request, obj, form, change)\n\n    def get_actions(self, request):\n        actions = super().get_actions(request)\n        if \"delete_selected\" in actions:\n            del actions[\"delete_selected\"]\n        return actions\n\n    def get_formsets_with_inlines(self, request, obj=None):\n        for inline in self.get_inline_instances(request, obj):\n            if self.has_change_permission(request, obj) or obj is None:\n                yield inline.get_formset(request, obj), inline\n\n    def get_urls(self):\n        urls = super().get_urls()\n        custom_urls = [\n            path(\n                \"<int:pk>/details/\",\n                self.admin_site.admin_view(EventAdminDetails.as_view()),\n                name=\"events_event_details\",\n            ),\n            path(\n                \"<int:pk>/export/\",\n                self.admin_site.admin_view(EventRegistrationsExport.as_view()),\n                name=\"events_event_export\",\n            ),\n            path(\n                \"<int:pk>/mark-present-qr/\",\n                self.admin_site.admin_view(EventMarkPresentQR.as_view()),\n                name=\"events_event_mark_present_qr\",\n            ),\n        ]\n        return custom_urls + urls\n", "path": "website/events/admin/event.py"}], "after_files": [{"content": "\"\"\"Registers admin interfaces for the event model.\"\"\"\n\nfrom django.contrib import admin, messages\nfrom django.template.defaultfilters import date as _date\nfrom django.urls import path, reverse\nfrom django.utils import timezone\nfrom django.utils.html import format_html\nfrom django.utils.translation import gettext_lazy as _\n\nfrom events import emails, models, services\nfrom events.admin.filters import LectureYearFilter\nfrom events.admin.forms import EventAdminForm, RegistrationInformationFieldForm\nfrom events.admin.inlines import (\n    PizzaEventInline,\n    PromotionRequestInline,\n    RegistrationInformationFieldInline,\n)\nfrom events.admin.views import (\n    EventAdminDetails,\n    EventMarkPresentQR,\n    EventRegistrationsExport,\n)\nfrom utils.admin import DoNextModelAdmin\n\n\n@admin.register(models.Event)\nclass EventAdmin(DoNextModelAdmin):\n    \"\"\"Manage the events.\"\"\"\n\n    form = EventAdminForm\n\n    inlines = (\n        RegistrationInformationFieldInline,\n        PizzaEventInline,\n        PromotionRequestInline,\n    )\n\n    list_display = (\n        \"overview_link\",\n        \"event_date\",\n        \"registration_date\",\n        \"num_participants\",\n        \"get_organisers\",\n        \"category\",\n        \"published\",\n        \"edit_link\",\n    )\n    list_display_links = (\"edit_link\",)\n    list_filter = (LectureYearFilter, \"start\", \"published\", \"category\")\n    actions = (\"make_published\", \"make_unpublished\")\n    date_hierarchy = \"start\"\n    search_fields = (\"title\", \"description\")\n    prepopulated_fields = {\n        \"map_location\": (\"location\",),\n    }\n\n    filter_horizontal = (\"documents\", \"organisers\")\n\n    fieldsets = (\n        (\n            _(\"General\"),\n            {\n                \"fields\": (\n                    \"title\",\n                    \"slug\",\n                    \"published\",\n                    \"organisers\",\n                )\n            },\n        ),\n        (\n            _(\"Detail\"),\n            {\n                \"fields\": (\n                    \"category\",\n                    \"start\",\n                    \"end\",\n                    \"description\",\n                    \"caption\",\n                    \"location\",\n                    \"map_location\",\n                ),\n                \"classes\": (\"collapse\", \"start-open\"),\n            },\n        ),\n        (\n            _(\"Registrations\"),\n            {\n                \"fields\": (\n                    \"price\",\n                    \"fine\",\n                    \"tpay_allowed\",\n                    \"max_participants\",\n                    \"registration_without_membership\",\n                    \"registration_start\",\n                    \"registration_end\",\n                    \"cancel_deadline\",\n                    \"send_cancel_email\",\n                    \"optional_registrations\",\n                    \"no_registration_message\",\n                ),\n                \"classes\": (\"collapse\",),\n            },\n        ),\n        (\n            _(\"Extra\"),\n            {\"fields\": (\"documents\", \"shift\"), \"classes\": (\"collapse\",)},\n        ),\n    )\n\n    def get_queryset(self, request):\n        return (\n            super()\n            .get_queryset(request)\n            .select_properties(\"participant_count\")\n            .prefetch_related(\"organisers\")\n        )\n\n    def get_form(self, request, obj=None, change=False, **kwargs):\n        form = super().get_form(request, obj, change, **kwargs)\n        form.clean = lambda form: form.instance.clean_changes(form.changed_data)\n        form.request = request\n        return form\n\n    def overview_link(self, obj):\n        return format_html(\n            '<a href=\"{link}\">{title}</a>',\n            link=reverse(\"admin:events_event_details\", kwargs={\"pk\": obj.pk}),\n            title=obj.title,\n        )\n\n    def has_change_permission(self, request, obj=None):\n        \"\"\"Only allow access to the change form if the user is an organiser.\"\"\"\n        if obj is not None and not services.is_organiser(request.member, obj):\n            return False\n        return super().has_change_permission(request, obj)\n\n    def event_date(self, obj):\n        event_date = timezone.make_naive(obj.start)\n        return _date(event_date, \"l d b Y, G:i\")\n\n    event_date.short_description = _(\"Event Date\")\n    event_date.admin_order_field = \"start\"\n\n    def registration_date(self, obj):\n        if obj.registration_start is not None:\n            start_date = timezone.make_naive(obj.registration_start)\n        else:\n            start_date = obj.registration_start\n\n        return _date(start_date, \"l d b Y, G:i\")\n\n    registration_date.short_description = _(\"Registration Start\")\n    registration_date.admin_order_field = \"registration_start\"\n\n    def edit_link(self, obj):\n        return _(\"Edit\")\n\n    edit_link.short_description = \"\"\n\n    def num_participants(self, obj):\n        \"\"\"Pretty-print the number of participants.\"\"\"\n        num = obj.participant_count  # prefetched aggregateproperty\n        if not obj.max_participants:\n            return f\"{num}/\u221e\"\n        return f\"{num}/{obj.max_participants}\"\n\n    num_participants.short_description = _(\"Number of participants\")\n\n    def get_organisers(self, obj):\n        return \", \".join(str(o) for o in obj.organisers.all())\n\n    get_organisers.short_description = _(\"Organisers\")\n\n    def make_published(self, request, queryset):\n        \"\"\"Change the status of the event to published.\"\"\"\n        self._change_published(request, queryset, True)\n\n    make_published.short_description = _(\"Publish selected events\")\n\n    def make_unpublished(self, request, queryset):\n        \"\"\"Change the status of the event to unpublished.\"\"\"\n        self._change_published(request, queryset, False)\n\n    make_unpublished.short_description = _(\"Unpublish selected events\")\n\n    @staticmethod\n    def _change_published(request, queryset, published):\n        if not request.user.is_superuser:\n            queryset = queryset.filter(\n                organisers__in=request.member.get_member_groups()\n            )\n        queryset.update(published=published)\n\n    def save_formset(self, request, form, formset, change):\n        \"\"\"Save formsets with their order.\"\"\"\n        formset.save()\n\n        informationfield_forms = (\n            x\n            for x in formset.forms\n            if isinstance(x, RegistrationInformationFieldForm)\n            and \"DELETE\" not in x.changed_data\n        )\n        form.instance.set_registrationinformationfield_order(\n            [\n                f.instance.pk\n                for f in sorted(\n                    informationfield_forms,\n                    key=lambda x: (x.cleaned_data[\"order\"], x.instance.pk),\n                )\n            ]\n        )\n        form.instance.save()\n\n    def save_model(self, request, obj, form, change):\n        if change and \"max_participants\" in form.changed_data:\n            prev = self.model.objects.get(id=obj.id)\n            prev_limit = prev.max_participants\n            self_limit = obj.max_participants\n            if prev_limit is None:\n                prev_limit = prev.participant_count\n            if self_limit is None:\n                self_limit = obj.participant_count\n\n            if prev_limit < self_limit and prev_limit < obj.participant_count:\n                diff = self_limit - prev_limit\n                joiners = prev.queue[:diff]\n                for registration in joiners:\n                    emails.notify_waiting(obj, registration)\n                messages.info(\n                    request,\n                    \"The maximum number of participants was increased. Any members that moved from the waiting list to the participants list have been notified.\",\n                )\n            elif self_limit < prev_limit and self_limit < obj.participant_count:\n                diff = self_limit - prev_limit\n                leavers = prev.registrations[self_limit:]\n                address = map(lambda r: r.email, leavers)\n                link = \"mailto:?bcc=\" + \",\".join(address)\n                messages.warning(\n                    request,\n                    format_html(\n                        \"The maximum number of participants was decreased and some members moved to the waiting list. <a href='{}' style='text-decoration: underline;'>Use this link to send them an email.</a>\",\n                        link,\n                    ),\n                )\n        super().save_model(request, obj, form, change)\n\n    def get_actions(self, request):\n        actions = super().get_actions(request)\n        if \"delete_selected\" in actions:\n            del actions[\"delete_selected\"]\n        return actions\n\n    def get_formsets_with_inlines(self, request, obj=None):\n        for inline in self.get_inline_instances(request, obj):\n            if self.has_change_permission(request, obj) or obj is None:\n                yield inline.get_formset(request, obj), inline\n\n    def get_urls(self):\n        urls = super().get_urls()\n        custom_urls = [\n            path(\n                \"<int:pk>/details/\",\n                self.admin_site.admin_view(EventAdminDetails.as_view()),\n                name=\"events_event_details\",\n            ),\n            path(\n                \"<int:pk>/export/\",\n                self.admin_site.admin_view(EventRegistrationsExport.as_view()),\n                name=\"events_event_export\",\n            ),\n            path(\n                \"<int:pk>/mark-present-qr/\",\n                self.admin_site.admin_view(EventMarkPresentQR.as_view()),\n                name=\"events_event_mark_present_qr\",\n            ),\n        ]\n        return custom_urls + urls\n", "path": "website/events/admin/event.py"}]}