From 2cd2d9f110d09c8877ecffe13a2953b129d44835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benni=20B=C3=A4rmann?= Date: Thu, 8 Dec 2022 20:21:36 +0000 Subject: [PATCH] fixed literature selfbuy variables in admin view --- input/admin.py | 2 -- input/forms.py | 2 +- input/models.py | 2 +- input/views.py | 3 ++- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/input/admin.py b/input/admin.py index 59746a0..82d1bfc 100755 --- a/input/admin.py +++ b/input/admin.py @@ -53,8 +53,6 @@ class LiteratureAdmin(admin.ModelAdmin): list_display = ('realname', 'service_id', 'granted', 'granted_date') list_display_links = ('realname', 'service_id') date_hierarchy = 'granted_date' - class Media: - js = ('dropdown/js/base.js',) @admin.register(Account) diff --git a/input/forms.py b/input/forms.py index 262f376..152cc97 100755 --- a/input/forms.py +++ b/input/forms.py @@ -111,7 +111,7 @@ class CheckForm(FdbForm): class LiteratureForm(CheckForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields['selfbuy_give_data'].required = True + self.fields['selfbuy_give_data'].required = False class Meta: model = Literature fields = ['cost', 'info', 'source', 'notes', 'selfbuy', 'selfbuy_data', 'selfbuy_give_data'] diff --git a/input/models.py b/input/models.py index 96ce900..4b45457 100755 --- a/input/models.py +++ b/input/models.py @@ -264,7 +264,7 @@ class Literature(Grant): help_text="Bitte gib an, wo du das Werk kaufen möchtest.") selfbuy = models.CharField( max_length=10, verbose_name='Selbstkauf?', choices=SELFBUY_CHOICES.items(), default='TRUE') selfbuy_give_data = models.BooleanField(verbose_name=format_html('Datenweitergabe erlauben'), help_text=format_html('Ich stimme der Weitergabe meiner Daten (Name, Postadresse) an den von mir angegebenen Anbieter/Dienstleister zu.')) - selfbuy_data = models.TextField(max_length=1000, verbose_name='Persönliche Daten sowie Adresse', default='', + selfbuy_data = models.TextField(max_length=1000, verbose_name='Persönliche Daten sowie Adresse', default='',\ help_text=format_html("Bitte gib hier alle persönlichen Daten an, die wir benötigen, um das Werk
\ für dich zu kaufen und es dir anschließend zu schicken (z.B. Vorname Nachname, Anschrift,
\ Telefonnummer, E-Mail-Adresse usw.). Trenne die einzelnen Angaben durch Zeilenumbrüche.")) diff --git a/input/views.py b/input/views.py index 4dbff38..281fd52 100755 --- a/input/views.py +++ b/input/views.py @@ -210,10 +210,11 @@ class ExternView(CookieWizardView): data = {} for form in form_list: data = {**data, **form.cleaned_data} + if data['choice'] == 'LIT': if data['selfbuy'] == 'TRUE': data['selfbuy_give_data'] = 'False' - + # write data to database modell = form.save(commit=False) # we have to copy the data from the first form here