removed code duplication, new basis class CheckForm

This commit is contained in:
Benni Bärmann 2020-11-18 18:06:00 +01:00
parent 2a182215c5
commit c02fd9864a
1 changed files with 6 additions and 18 deletions

View File

@ -76,41 +76,29 @@ class IFGForm(FdbForm):
fields = ['cost', 'url', 'notes'] fields = ['cost', 'url', 'notes']
'''TODO: the next four classes could maybe have a common base class for the check field, class CheckForm(FdbForm):
but i am not sure about the sequence of fields. check should be always last''' """Baseclass for all classes which need a check for Nutzungsbedingungen"""
class LiteratureForm(FdbForm):
check = BooleanField(required=True, check = BooleanField(required=True,
label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu", label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
NUTZUNGSBEDINGUNGEN)) NUTZUNGSBEDINGUNGEN))
class LiteratureForm(CheckForm):
class Meta: class Meta:
model = Literature model = Literature
fields = ['cost', 'info', 'source', 'notes'] fields = ['cost', 'info', 'source', 'notes']
class EmailForm(FdbForm): class EmailForm(CheckForm):
# TODO: add some javascript to show/hide other-field # TODO: add some javascript to show/hide other-field
check = BooleanField(required=True,
label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
NUTZUNGSBEDINGUNGEN))
class Meta: class Meta:
model = Email model = Email
fields = ['domain', 'address', 'other'] fields = ['domain', 'address', 'other']
class BusinessCardForm(FdbForm): class BusinessCardForm(CheckForm):
check = BooleanField(required=True,
label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
NUTZUNGSBEDINGUNGEN))
class Meta: class Meta:
model = BusinessCard model = BusinessCard
fields = ['project', 'data', 'variant', 'sent_to'] fields = ['project', 'data', 'variant', 'sent_to']
class ListForm(FdbForm): class ListForm(CheckForm):
check = BooleanField(required=True,
label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
NUTZUNGSBEDINGUNGEN))
class Meta: class Meta:
model = List model = List
fields = ['domain', 'address'] fields = ['domain', 'address']