From 71117b8e63e12cb8ff34fa9a127c9d76038459ca Mon Sep 17 00:00:00 2001 From: Patrick Mayr Date: Wed, 15 Nov 2023 17:54:06 +0000 Subject: [PATCH] created primary keys are not editable --- fet2020/finance/forms.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/fet2020/finance/forms.py b/fet2020/finance/forms.py index 50edde15..32f67107 100644 --- a/fet2020/finance/forms.py +++ b/fet2020/finance/forms.py @@ -312,18 +312,7 @@ class ResolutionAdminForm(forms.ModelForm): class Meta: model = Resolution - fields = [ - "name", - "id", - "date", - "option", - "is_visible", - "budget", - "total", - "budget_remaining", - "voting", - "voting_text", - ] + fields = "__all__" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # to get the self.fields set @@ -348,6 +337,12 @@ class ResolutionAdminForm(forms.ModelForm): self.fields["budget_remaining"].label = "Restbudget (EUR)" self.fields["budget_remaining"].required = False + self.fields["budget"].required = False + + if resolution is not None: + self.fields["id"].disabled = True + self.fields["id"].required = False + class WirefAdminForm(forms.ModelForm): total = forms.CharField()