From 7ab8c956b1c5e636414f9f7d9553544de65e7aef Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 19 Oct 2020 11:56:10 +0200 Subject: [PATCH] new type field for Library/Software/eLit, finetuning mail conditions --- input/forms.py | 4 ++-- input/migrations/0013_library_type.py | 18 ++++++++++++++++++ input/models.py | 13 +++++++++++-- input/templates/input/if_mail.txt | 15 ++++++++------- 4 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 input/migrations/0013_library_type.py diff --git a/input/forms.py b/input/forms.py index c9a85a7..b8fb181 100644 --- a/input/forms.py +++ b/input/forms.py @@ -20,7 +20,7 @@ class VolunteerForm(ModelForm): ('SOFT', 'Softwarestipendium'), ('VIS', 'Visitenkarten, Mailingliste oder E-Mail-Adresse'), ('IFG', 'Kostenübernahme IFG-Anfrage'), - ('LIB', 'library'),] + ('LIT', 'Literaturstipendium'),] choice = ChoiceField(choices=CHOICES, widget=RadioSelect) class Meta: @@ -30,7 +30,7 @@ class VolunteerForm(ModelForm): class LibraryForm(ModelForm): class Meta: model = Library - exclude = ('realname', 'email', 'username') + exclude = ('realname', 'email', 'username', 'type') class IFGForm(ModelForm): class Meta: diff --git a/input/migrations/0013_library_type.py b/input/migrations/0013_library_type.py new file mode 100644 index 0000000..8e89232 --- /dev/null +++ b/input/migrations/0013_library_type.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-10-19 09:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0012_auto_20201007_0754'), + ] + + operations = [ + migrations.AddField( + model_name='library', + name='type', + field=models.CharField(choices=[('LIB', 'Bibliotheksstipendium'), ('ELIT', 'eLiteraturstipendium'), ('SOFT', 'Softwarestipendium')], default='LIB', max_length=4), + ), + ] diff --git a/input/models.py b/input/models.py index 7c1af11..59efd1e 100644 --- a/input/models.py +++ b/input/models.py @@ -39,16 +39,25 @@ class Grant(Volunteer): class Meta: abstract = True -# should be identical for ELitStip and Software? +# same model is used for Library, ELitStip and Software! class Library(Grant): + TYPE_CHOICES = [('LIB', 'Bibliotheksstipendium'), + ('ELIT', 'eLiteraturstipendium'), + ('SOFT', 'Softwarestipendium')] + type = models.CharField( + max_length=4, + choices=TYPE_CHOICES, + default='LIB', + ) library = models.CharField(max_length=200) duration = models.CharField(max_length=100) + def __str__(self): return self.library class IFG(Grant): - url = models.CharField(max_length=2000) + url = models.CharField(max_length=2000) def __str__(self): return "IFG-Anfrage von " + self.realname diff --git a/input/templates/input/if_mail.txt b/input/templates/input/if_mail.txt index 535a444..041a96f 100644 --- a/input/templates/input/if_mail.txt +++ b/input/templates/input/if_mail.txt @@ -3,13 +3,14 @@ Hallo Team Ideenförderung, es gab einen neuen Antrag von {{data.realname}}. Username {{data.username}} fragt ein -{% if data.choice == 'LIB' %} Literaturstipendium {% endif %} -{% if data.choice == 'BIB' %} Bibliotheksstipendium {% endif %} -{% if data.choice == 'IFG' %} IFG {% endif %} -{% if data.choice == 'ELIT' %} eLiteraturstipendium {% endif %} -{% if data.choice == 'SOFT' %} Softwarestipendium {% endif %} -{% if data.choice == 'VIS' %} Visitenkarten, Mailingliste oder E-Mail-Adresse {% endif %} - +{% if data.choice == 'LIT' %} Literaturstipendium +{% elif data.choice == 'BIB' %} Bibliotheksstipendium +{% elif data.choice == 'IFG' %} IFG +{% elif data.choice == 'ELIT' %} eLiteraturstipendium +{% elif data.choice == 'SOFT' %} Softwarestipendium +{% elif data.choice == 'VIS' %} Visitenkarten, Mailingliste oder E-Mail-Adresse +{% else %} ERROR UNKNOWN FORMTYPE +{% endif %} an. Genehmigen: INSERT Link here