We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
It's not possible to delete event relations in django admin
## What kind of an issue is this?

- [x] Bug report


## What is the expected behaviour?

When you mark an event relation for deletion it should be deleted when you save the object.

## What is the current behaviour?

The object is saved, but the relation is not removed.


## How do you reproduce this problem? 

* Create an event
* Add a relation (e.g. Company or Attendance)
* Save
* Go to the admin panel for the event
* Mark the relation for deletion (click the delete checkbox by the relation)
* Save
* The relation is still there


## Other information

This is most likely due to us overwriting the `save_formset()` method in EventAdmin[0] and not taking care of deleting objects marked for deleting in the formset [1].

We're not doing anything custom in the method, so there's really no reason to override it. The code could actually be removed.

[0]: https://github.com/dotkom/onlineweb4/blob/develop/apps/events/admin.py#L160
[1]: https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `apps/events/admin.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 from django.contrib import admin, messages
4 from django.utils.translation import ugettext as _
5 from guardian.admin import GuardedModelAdmin
6 from reversion.admin import VersionAdmin
7 
8 from apps.events.models import (AttendanceEvent, Attendee, CompanyEvent, Event, Extras,
9                                 FieldOfStudyRule, GradeRule, GroupRestriction, Reservation,
10                                 Reservee, RuleBundle, UserGroupRule)
11 from apps.feedback.admin import FeedbackRelationInline
12 
13 
14 class AttendeeInline(admin.TabularInline):
15     model = Attendee
16     extra = 1
17     classes = ('grp-collapse grp-open',)  # style
18     inline_classes = ('grp-collapse grp-open',)  # style
19 
20 
21 class CompanyInline(admin.TabularInline):
22     model = CompanyEvent
23     max_num = 20
24     extra = 0
25     classes = ('grp-collapse grp-open',)  # style
26     inline_classes = ('grp-collapse grp-open',)  # style
27 
28 
29 class RuleBundleInline(admin.TabularInline):
30     model = RuleBundle
31     extra = 1
32     max_num = 20
33     classes = ('grp-collapse grp-open',)  # style
34     inline_classes = ('grp-collapse grp-open',)  # style
35 
36 
37 class ExtrasInline(admin.TabularInline):
38     model = Extras
39     extra = 1
40     max_num = 20
41     classes = ('grp-collapse grp-open',)  # style
42     inline_classes = ('grp-collapse grp-open',)  # style
43 
44 
45 class GroupRestrictionInline(admin.TabularInline):
46     model = GroupRestriction
47     extra = 0
48     max_num = 1
49     classes = ('grp-collapse grp-open',)  # style
50     inline_classes = ('grp-collapse grp-open',)  # style
51     filter_horizontal = ('groups',)
52 
53 
54 def mark_paid(modeladmin, request, queryset):
55     queryset.update(paid=True)
56 
57 
58 mark_paid.short_description = "Merk som betalt"
59 
60 
61 def mark_not_paid(modeladmin, request, queryset):
62     queryset.update(paid=False)
63 
64 
65 mark_not_paid.short_description = "Merk som ikke betalt"
66 
67 
68 def mark_attended(modeladmin, request, queryset):
69     queryset.update(attended=True)
70 
71 
72 mark_attended.short_description = "Merk som møtt"
73 
74 
75 def mark_not_attended(modeladmin, request, queryset):
76     queryset.update(attended=False)
77 
78 
79 mark_not_attended.short_description = "Merk som ikke møtt"
80 
81 
82 class AttendeeAdmin(GuardedModelAdmin, VersionAdmin):
83     model = Attendee
84     ordering = ['-timestamp']
85     list_display = ('user', 'event', 'timestamp', 'paid', 'attended', 'note', 'extras')
86     list_filter = ('attended', 'paid', 'event__event')
87     search_fields = (
88         'event__event__title', '=event__event__id', 'user__first_name', 'user__last_name', 'user__username',
89     )
90     actions = [mark_paid, mark_attended, mark_not_paid, mark_not_attended]
91     group_owned_objects_field = 'event__event__organizer'
92     user_can_access_owned_by_group_objects_only = True
93 
94     # Disable delete_selected http://bit.ly/1o4nleN
95     def get_actions(self, request):
96         actions = super(AttendeeAdmin, self).get_actions(request)
97         if 'delete_selected' in actions:
98             del actions['delete_selected']
99         return actions
100 
101 
102 class CompanyEventAdmin(VersionAdmin):
103     model = CompanyEvent
104     inlines = (CompanyInline,)
105 
106 
107 class ExtrasAdmin(VersionAdmin):
108     model = Extras
109     fk_name = 'choice'
110     # inlines = (ExtrasInline,)
111 
112 
113 class RuleBundleAdmin(VersionAdmin):
114     model = RuleBundle
115 
116 
117 class FieldOfStudyRuleAdmin(VersionAdmin):
118     model = FieldOfStudyRule
119 
120 
121 class GradeRuleAdmin(VersionAdmin):
122     model = GradeRule
123 
124 
125 class UserGroupRuleAdmin(VersionAdmin):
126     model = UserGroupRule
127 
128 
129 class AttendanceEventInline(admin.StackedInline):
130     model = AttendanceEvent
131     max_num = 1
132     extra = 0
133     filter_horizontal = ('rule_bundles',)
134     classes = ('grp-collapse grp-open',)  # style
135     inline_classes = ('grp-collapse grp-open',)  # style
136     exclude = ("marks_has_been_set",)
137 
138 
139 class EventAdmin(GuardedModelAdmin, VersionAdmin):
140     inlines = (AttendanceEventInline, FeedbackRelationInline, CompanyInline, GroupRestrictionInline)
141     exclude = ("author", )
142     list_display = ['__str__', 'event_type', 'organizer']
143     list_filter = ['event_type', 'organizer']
144     search_fields = ('title',)
145 
146     group_owned_objects_field = 'organizer'
147     user_can_access_owned_by_group_objects_only = True
148 
149     def save_model(self, request, obj, form, change):
150         if not change:  # created
151             obj.author = request.user
152         obj.save()
153 
154     def save_formset(self, request, form, formset, change):
155         instances = formset.save(commit=False)
156         for instance in instances:
157             instance.save()
158         formset.save_m2m()
159 
160 
161 class ReserveeInline(admin.TabularInline):
162     model = Reservee
163     extra = 1
164     classes = ('grp-collapse grp-open',)  # style
165     inline_classes = ('grp-collapse grp-open',)  # style
166 
167 
168 class ReservationAdmin(GuardedModelAdmin, VersionAdmin):
169     model = Reservation
170     inlines = (ReserveeInline,)
171     max_num = 1
172     extra = 0
173     list_display = ('attendance_event', '_number_of_seats_taken', 'seats', '_attendees', '_max_capacity')
174     classes = ('grp-collapse grp-open',)  # style
175     inline_classes = ('grp-collapse grp-open',)  # style
176     user_can_access_owned_by_group_objects_only = True
177     group_owned_objects_field = 'attendance_event__event__organizer'
178 
179     def _number_of_seats_taken(self, obj):
180         return obj.number_of_seats_taken
181     _number_of_seats_taken.short_description = _("Fylte reservasjoner")
182 
183     def _attendees(self, obj):
184         return obj.attendance_event.number_of_attendees
185     _attendees.short_description = _("Antall deltakere")
186 
187     def _max_capacity(self, obj):
188         return obj.attendance_event.max_capacity
189     _max_capacity.short_description = _("Arrangementets maks-kapasitet")
190 
191     def save_model(self, request, obj, form, change):
192         attendance_event = AttendanceEvent.objects.get(pk=obj.attendance_event.event)
193         number_of_free_seats = attendance_event.max_capacity - attendance_event.number_of_attendees
194         if number_of_free_seats < obj.seats:
195             obj.seats = number_of_free_seats
196             self.message_user(request, _(
197                 "Du har valgt et antall reserverte plasser som overskrider antallet ledige plasser for dette "
198                 "arrangementet. Antallet ble automatisk justert til %d (alle ledige plasser)."
199             ) % number_of_free_seats, messages.WARNING)
200         obj.save()
201 
202 
203 admin.site.register(Event, EventAdmin)
204 admin.site.register(Attendee, AttendeeAdmin)
205 admin.site.register(RuleBundle, RuleBundleAdmin)
206 admin.site.register(Extras, ExtrasAdmin)
207 admin.site.register(GradeRule, GradeRuleAdmin)
208 admin.site.register(UserGroupRule, UserGroupRuleAdmin)
209 admin.site.register(FieldOfStudyRule, FieldOfStudyRuleAdmin)
210 admin.site.register(Reservation, ReservationAdmin)
211
```
--- 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/apps/events/admin.py b/apps/events/admin.py
--- a/apps/events/admin.py
+++ b/apps/events/admin.py
@@ -151,12 +151,6 @@
             obj.author = request.user
         obj.save()
 
-    def save_formset(self, request, form, formset, change):
-        instances = formset.save(commit=False)
-        for instance in instances:
-            instance.save()
-        formset.save_m2m()
-
 
 class ReserveeInline(admin.TabularInline):
     model = Reservee

{"golden_diff": "diff --git a/apps/events/admin.py b/apps/events/admin.py\n--- a/apps/events/admin.py\n+++ b/apps/events/admin.py\n@@ -151,12 +151,6 @@\n             obj.author = request.user\n         obj.save()\n \n-    def save_formset(self, request, form, formset, change):\n-        instances = formset.save(commit=False)\n-        for instance in instances:\n-            instance.save()\n-        formset.save_m2m()\n-\n \n class ReserveeInline(admin.TabularInline):\n     model = Reservee\n", "issue": "It's not possible to delete event relations in django admin\n## What kind of an issue is this?\r\n\r\n- [x] Bug report\r\n\r\n\r\n## What is the expected behaviour?\r\n\r\nWhen you mark an event relation for deletion it should be deleted when you save the object.\r\n\r\n## What is the current behaviour?\r\n\r\nThe object is saved, but the relation is not removed.\r\n\r\n\r\n## How do you reproduce this problem? \r\n\r\n* Create an event\r\n* Add a relation (e.g. Company or Attendance)\r\n* Save\r\n* Go to the admin panel for the event\r\n* Mark the relation for deletion (click the delete checkbox by the relation)\r\n* Save\r\n* The relation is still there\r\n\r\n\r\n## Other information\r\n\r\nThis is most likely due to us overwriting the `save_formset()` method in EventAdmin[0] and not taking care of deleting objects marked for deleting in the formset [1].\r\n\r\nWe're not doing anything custom in the method, so there's really no reason to override it. The code could actually be removed.\r\n\r\n[0]: https://github.com/dotkom/onlineweb4/blob/develop/apps/events/admin.py#L160\r\n[1]: https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\nfrom django.contrib import admin, messages\nfrom django.utils.translation import ugettext as _\nfrom guardian.admin import GuardedModelAdmin\nfrom reversion.admin import VersionAdmin\n\nfrom apps.events.models import (AttendanceEvent, Attendee, CompanyEvent, Event, Extras,\n                                FieldOfStudyRule, GradeRule, GroupRestriction, Reservation,\n                                Reservee, RuleBundle, UserGroupRule)\nfrom apps.feedback.admin import FeedbackRelationInline\n\n\nclass AttendeeInline(admin.TabularInline):\n    model = Attendee\n    extra = 1\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n\n\nclass CompanyInline(admin.TabularInline):\n    model = CompanyEvent\n    max_num = 20\n    extra = 0\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n\n\nclass RuleBundleInline(admin.TabularInline):\n    model = RuleBundle\n    extra = 1\n    max_num = 20\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n\n\nclass ExtrasInline(admin.TabularInline):\n    model = Extras\n    extra = 1\n    max_num = 20\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n\n\nclass GroupRestrictionInline(admin.TabularInline):\n    model = GroupRestriction\n    extra = 0\n    max_num = 1\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n    filter_horizontal = ('groups',)\n\n\ndef mark_paid(modeladmin, request, queryset):\n    queryset.update(paid=True)\n\n\nmark_paid.short_description = \"Merk som betalt\"\n\n\ndef mark_not_paid(modeladmin, request, queryset):\n    queryset.update(paid=False)\n\n\nmark_not_paid.short_description = \"Merk som ikke betalt\"\n\n\ndef mark_attended(modeladmin, request, queryset):\n    queryset.update(attended=True)\n\n\nmark_attended.short_description = \"Merk som m\u00f8tt\"\n\n\ndef mark_not_attended(modeladmin, request, queryset):\n    queryset.update(attended=False)\n\n\nmark_not_attended.short_description = \"Merk som ikke m\u00f8tt\"\n\n\nclass AttendeeAdmin(GuardedModelAdmin, VersionAdmin):\n    model = Attendee\n    ordering = ['-timestamp']\n    list_display = ('user', 'event', 'timestamp', 'paid', 'attended', 'note', 'extras')\n    list_filter = ('attended', 'paid', 'event__event')\n    search_fields = (\n        'event__event__title', '=event__event__id', 'user__first_name', 'user__last_name', 'user__username',\n    )\n    actions = [mark_paid, mark_attended, mark_not_paid, mark_not_attended]\n    group_owned_objects_field = 'event__event__organizer'\n    user_can_access_owned_by_group_objects_only = True\n\n    # Disable delete_selected http://bit.ly/1o4nleN\n    def get_actions(self, request):\n        actions = super(AttendeeAdmin, self).get_actions(request)\n        if 'delete_selected' in actions:\n            del actions['delete_selected']\n        return actions\n\n\nclass CompanyEventAdmin(VersionAdmin):\n    model = CompanyEvent\n    inlines = (CompanyInline,)\n\n\nclass ExtrasAdmin(VersionAdmin):\n    model = Extras\n    fk_name = 'choice'\n    # inlines = (ExtrasInline,)\n\n\nclass RuleBundleAdmin(VersionAdmin):\n    model = RuleBundle\n\n\nclass FieldOfStudyRuleAdmin(VersionAdmin):\n    model = FieldOfStudyRule\n\n\nclass GradeRuleAdmin(VersionAdmin):\n    model = GradeRule\n\n\nclass UserGroupRuleAdmin(VersionAdmin):\n    model = UserGroupRule\n\n\nclass AttendanceEventInline(admin.StackedInline):\n    model = AttendanceEvent\n    max_num = 1\n    extra = 0\n    filter_horizontal = ('rule_bundles',)\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n    exclude = (\"marks_has_been_set\",)\n\n\nclass EventAdmin(GuardedModelAdmin, VersionAdmin):\n    inlines = (AttendanceEventInline, FeedbackRelationInline, CompanyInline, GroupRestrictionInline)\n    exclude = (\"author\", )\n    list_display = ['__str__', 'event_type', 'organizer']\n    list_filter = ['event_type', 'organizer']\n    search_fields = ('title',)\n\n    group_owned_objects_field = 'organizer'\n    user_can_access_owned_by_group_objects_only = True\n\n    def save_model(self, request, obj, form, change):\n        if not change:  # created\n            obj.author = request.user\n        obj.save()\n\n    def save_formset(self, request, form, formset, change):\n        instances = formset.save(commit=False)\n        for instance in instances:\n            instance.save()\n        formset.save_m2m()\n\n\nclass ReserveeInline(admin.TabularInline):\n    model = Reservee\n    extra = 1\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n\n\nclass ReservationAdmin(GuardedModelAdmin, VersionAdmin):\n    model = Reservation\n    inlines = (ReserveeInline,)\n    max_num = 1\n    extra = 0\n    list_display = ('attendance_event', '_number_of_seats_taken', 'seats', '_attendees', '_max_capacity')\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n    user_can_access_owned_by_group_objects_only = True\n    group_owned_objects_field = 'attendance_event__event__organizer'\n\n    def _number_of_seats_taken(self, obj):\n        return obj.number_of_seats_taken\n    _number_of_seats_taken.short_description = _(\"Fylte reservasjoner\")\n\n    def _attendees(self, obj):\n        return obj.attendance_event.number_of_attendees\n    _attendees.short_description = _(\"Antall deltakere\")\n\n    def _max_capacity(self, obj):\n        return obj.attendance_event.max_capacity\n    _max_capacity.short_description = _(\"Arrangementets maks-kapasitet\")\n\n    def save_model(self, request, obj, form, change):\n        attendance_event = AttendanceEvent.objects.get(pk=obj.attendance_event.event)\n        number_of_free_seats = attendance_event.max_capacity - attendance_event.number_of_attendees\n        if number_of_free_seats < obj.seats:\n            obj.seats = number_of_free_seats\n            self.message_user(request, _(\n                \"Du har valgt et antall reserverte plasser som overskrider antallet ledige plasser for dette \"\n                \"arrangementet. Antallet ble automatisk justert til %d (alle ledige plasser).\"\n            ) % number_of_free_seats, messages.WARNING)\n        obj.save()\n\n\nadmin.site.register(Event, EventAdmin)\nadmin.site.register(Attendee, AttendeeAdmin)\nadmin.site.register(RuleBundle, RuleBundleAdmin)\nadmin.site.register(Extras, ExtrasAdmin)\nadmin.site.register(GradeRule, GradeRuleAdmin)\nadmin.site.register(UserGroupRule, UserGroupRuleAdmin)\nadmin.site.register(FieldOfStudyRule, FieldOfStudyRuleAdmin)\nadmin.site.register(Reservation, ReservationAdmin)\n", "path": "apps/events/admin.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\nfrom django.contrib import admin, messages\nfrom django.utils.translation import ugettext as _\nfrom guardian.admin import GuardedModelAdmin\nfrom reversion.admin import VersionAdmin\n\nfrom apps.events.models import (AttendanceEvent, Attendee, CompanyEvent, Event, Extras,\n                                FieldOfStudyRule, GradeRule, GroupRestriction, Reservation,\n                                Reservee, RuleBundle, UserGroupRule)\nfrom apps.feedback.admin import FeedbackRelationInline\n\n\nclass AttendeeInline(admin.TabularInline):\n    model = Attendee\n    extra = 1\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n\n\nclass CompanyInline(admin.TabularInline):\n    model = CompanyEvent\n    max_num = 20\n    extra = 0\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n\n\nclass RuleBundleInline(admin.TabularInline):\n    model = RuleBundle\n    extra = 1\n    max_num = 20\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n\n\nclass ExtrasInline(admin.TabularInline):\n    model = Extras\n    extra = 1\n    max_num = 20\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n\n\nclass GroupRestrictionInline(admin.TabularInline):\n    model = GroupRestriction\n    extra = 0\n    max_num = 1\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n    filter_horizontal = ('groups',)\n\n\ndef mark_paid(modeladmin, request, queryset):\n    queryset.update(paid=True)\n\n\nmark_paid.short_description = \"Merk som betalt\"\n\n\ndef mark_not_paid(modeladmin, request, queryset):\n    queryset.update(paid=False)\n\n\nmark_not_paid.short_description = \"Merk som ikke betalt\"\n\n\ndef mark_attended(modeladmin, request, queryset):\n    queryset.update(attended=True)\n\n\nmark_attended.short_description = \"Merk som m\u00f8tt\"\n\n\ndef mark_not_attended(modeladmin, request, queryset):\n    queryset.update(attended=False)\n\n\nmark_not_attended.short_description = \"Merk som ikke m\u00f8tt\"\n\n\nclass AttendeeAdmin(GuardedModelAdmin, VersionAdmin):\n    model = Attendee\n    ordering = ['-timestamp']\n    list_display = ('user', 'event', 'timestamp', 'paid', 'attended', 'note', 'extras')\n    list_filter = ('attended', 'paid', 'event__event')\n    search_fields = (\n        'event__event__title', '=event__event__id', 'user__first_name', 'user__last_name', 'user__username',\n    )\n    actions = [mark_paid, mark_attended, mark_not_paid, mark_not_attended]\n    group_owned_objects_field = 'event__event__organizer'\n    user_can_access_owned_by_group_objects_only = True\n\n    # Disable delete_selected http://bit.ly/1o4nleN\n    def get_actions(self, request):\n        actions = super(AttendeeAdmin, self).get_actions(request)\n        if 'delete_selected' in actions:\n            del actions['delete_selected']\n        return actions\n\n\nclass CompanyEventAdmin(VersionAdmin):\n    model = CompanyEvent\n    inlines = (CompanyInline,)\n\n\nclass ExtrasAdmin(VersionAdmin):\n    model = Extras\n    fk_name = 'choice'\n    # inlines = (ExtrasInline,)\n\n\nclass RuleBundleAdmin(VersionAdmin):\n    model = RuleBundle\n\n\nclass FieldOfStudyRuleAdmin(VersionAdmin):\n    model = FieldOfStudyRule\n\n\nclass GradeRuleAdmin(VersionAdmin):\n    model = GradeRule\n\n\nclass UserGroupRuleAdmin(VersionAdmin):\n    model = UserGroupRule\n\n\nclass AttendanceEventInline(admin.StackedInline):\n    model = AttendanceEvent\n    max_num = 1\n    extra = 0\n    filter_horizontal = ('rule_bundles',)\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n    exclude = (\"marks_has_been_set\",)\n\n\nclass EventAdmin(GuardedModelAdmin, VersionAdmin):\n    inlines = (AttendanceEventInline, FeedbackRelationInline, CompanyInline, GroupRestrictionInline)\n    exclude = (\"author\", )\n    list_display = ['__str__', 'event_type', 'organizer']\n    list_filter = ['event_type', 'organizer']\n    search_fields = ('title',)\n\n    group_owned_objects_field = 'organizer'\n    user_can_access_owned_by_group_objects_only = True\n\n    def save_model(self, request, obj, form, change):\n        if not change:  # created\n            obj.author = request.user\n        obj.save()\n\n\nclass ReserveeInline(admin.TabularInline):\n    model = Reservee\n    extra = 1\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n\n\nclass ReservationAdmin(GuardedModelAdmin, VersionAdmin):\n    model = Reservation\n    inlines = (ReserveeInline,)\n    max_num = 1\n    extra = 0\n    list_display = ('attendance_event', '_number_of_seats_taken', 'seats', '_attendees', '_max_capacity')\n    classes = ('grp-collapse grp-open',)  # style\n    inline_classes = ('grp-collapse grp-open',)  # style\n    user_can_access_owned_by_group_objects_only = True\n    group_owned_objects_field = 'attendance_event__event__organizer'\n\n    def _number_of_seats_taken(self, obj):\n        return obj.number_of_seats_taken\n    _number_of_seats_taken.short_description = _(\"Fylte reservasjoner\")\n\n    def _attendees(self, obj):\n        return obj.attendance_event.number_of_attendees\n    _attendees.short_description = _(\"Antall deltakere\")\n\n    def _max_capacity(self, obj):\n        return obj.attendance_event.max_capacity\n    _max_capacity.short_description = _(\"Arrangementets maks-kapasitet\")\n\n    def save_model(self, request, obj, form, change):\n        attendance_event = AttendanceEvent.objects.get(pk=obj.attendance_event.event)\n        number_of_free_seats = attendance_event.max_capacity - attendance_event.number_of_attendees\n        if number_of_free_seats < obj.seats:\n            obj.seats = number_of_free_seats\n            self.message_user(request, _(\n                \"Du har valgt et antall reserverte plasser som overskrider antallet ledige plasser for dette \"\n                \"arrangementet. Antallet ble automatisk justert til %d (alle ledige plasser).\"\n            ) % number_of_free_seats, messages.WARNING)\n        obj.save()\n\n\nadmin.site.register(Event, EventAdmin)\nadmin.site.register(Attendee, AttendeeAdmin)\nadmin.site.register(RuleBundle, RuleBundleAdmin)\nadmin.site.register(Extras, ExtrasAdmin)\nadmin.site.register(GradeRule, GradeRuleAdmin)\nadmin.site.register(UserGroupRule, UserGroupRuleAdmin)\nadmin.site.register(FieldOfStudyRule, FieldOfStudyRuleAdmin)\nadmin.site.register(Reservation, ReservationAdmin)\n", "path": "apps/events/admin.py"}]}