From 1c6c8506896e18a1ec041825b9eafb17064f4afd Mon Sep 17 00:00:00 2001 From: Patrick Mayr Date: Fri, 27 Oct 2023 09:29:40 +0000 Subject: [PATCH] allow creating a bill without resolution --- fet2020/finance/forms.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fet2020/finance/forms.py b/fet2020/finance/forms.py index 26fd64f3..08441c30 100644 --- a/fet2020/finance/forms.py +++ b/fet2020/finance/forms.py @@ -103,12 +103,13 @@ class BillCreateForm(forms.ModelForm): file_field = cleaned_data.get("file_field") # check if resolution exists - try: - Resolution.objects.get(id=resolution) - except: - raise ValidationError( - f"Es gibt keinen Beschluss mit dieser ID. (Eingegebene ID: {resolution})" - ) + if resolution != "": + try: + Resolution.objects.get(id=resolution) + except: + raise ValidationError( + f"Es gibt keinen Beschluss mit dieser ID. (Eingegebene ID: {resolution})" + ) # check that amount is valid because invalid amount is a NoneType. if amount: