From be3958af4067e92ade4971b83b6f533d81a8d4e0 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Thu, 19 Aug 2021 11:13:44 +0200 Subject: [PATCH] Fixed special Student edition case where inlines differ between GET and POST --- stages/admin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stages/admin.py b/stages/admin.py index b435082..aebef3d 100644 --- a/stages/admin.py +++ b/stages/admin.py @@ -207,6 +207,12 @@ class StudentAdmin(admin.ModelAdmin): inlines = [inl for inl in inlines if inl != SupervisionBillInline] if not obj.is_ede() and not obj.is_eds(): inlines = [inl for inl in inlines if inl != ExaminationInline] + if request.method == 'POST': + # Special case where inlines would be different before and after POST + if SupervisionBillInline in inlines and not 'supervisionbill_set-TOTAL_FORMS' in request.POST: + inlines.remove(SupervisionBillInline) + if ExaminationInline in inlines and not 'examination_set-TOTAL_FORMS' in request.POST: + inlines.remove(ExaminationInline) return inlines def get_fieldsets(self, request, obj=None):