From c02fd9864a34276290e3e5192942c01333805f2d Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 18 Nov 2020 18:06:00 +0100 Subject: [PATCH] removed code duplication, new basis class CheckForm --- input/forms.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/input/forms.py b/input/forms.py index 5582b06..2272b60 100644 --- a/input/forms.py +++ b/input/forms.py @@ -76,41 +76,29 @@ class IFGForm(FdbForm): fields = ['cost', 'url', 'notes'] -'''TODO: the next four classes could maybe have a common base class for the check field, -but i am not sure about the sequence of fields. check should be always last''' -class LiteratureForm(FdbForm): +class CheckForm(FdbForm): + """Baseclass for all classes which need a check for Nutzungsbedingungen""" check = BooleanField(required=True, label=format_html("Ich stimme den Nutzungsbedingungen zu", NUTZUNGSBEDINGUNGEN)) +class LiteratureForm(CheckForm): class Meta: model = Literature fields = ['cost', 'info', 'source', 'notes'] -class EmailForm(FdbForm): +class EmailForm(CheckForm): # TODO: add some javascript to show/hide other-field - check = BooleanField(required=True, - label=format_html("Ich stimme den Nutzungsbedingungen zu", - NUTZUNGSBEDINGUNGEN)) - class Meta: model = Email fields = ['domain', 'address', 'other'] -class BusinessCardForm(FdbForm): - check = BooleanField(required=True, - label=format_html("Ich stimme den Nutzungsbedingungen zu", - NUTZUNGSBEDINGUNGEN)) - +class BusinessCardForm(CheckForm): class Meta: model = BusinessCard fields = ['project', 'data', 'variant', 'sent_to'] -class ListForm(FdbForm): - check = BooleanField(required=True, - label=format_html("Ich stimme den Nutzungsbedingungen zu", - NUTZUNGSBEDINGUNGEN)) - +class ListForm(CheckForm): class Meta: model = List fields = ['domain', 'address']