From a0c57c7d4d03376eafb80ffa272a68fefceeee88 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 28 Oct 2020 15:04:53 +0100 Subject: [PATCH] work on intern/PRO, korrekt pid implemented --- input/forms.py | 10 +++++----- input/migrations/0031_auto_20201028_1402.py | 18 ++++++++++++++++++ input/models.py | 4 ++-- input/views.py | 4 ++-- 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 input/migrations/0031_auto_20201028_1402.py diff --git a/input/forms.py b/input/forms.py index 16da3a3..43d0b1c 100644 --- a/input/forms.py +++ b/input/forms.py @@ -15,7 +15,7 @@ class ProjectForm(ModelForm): class Meta: model = Project - exclude = ('pid', 'granted', 'granted_date', 'realname', 'email', 'project_end_mail', 'survey_mail_send') + exclude = ('pid', 'granted', 'granted_date', 'realname', 'email', 'end_mail_send', 'survey_mail_send') widgets = {'start': AdminDateWidget(), 'end': AdminDateWidget(),} @@ -32,12 +32,12 @@ class ExternForm(ModelForm): model = Extern exclude = ('granted', 'granted_date', 'survey_mail_send') -INTERN_CHOICES = [('PRO', 'Projektsteckbrief'), - ('HON', 'Ehrenamtsbescheinigung, Akkreditierung oder Redaktionsbestätigung'), - ('TRAV', 'Reisekostenerstattung')] +INTERN_CHOICES = {'PRO': 'Projektsteckbrief', + 'HON': 'Ehrenamtsbescheinigung, Akkreditierung oder Redaktionsbestätigung', + 'TRAV': 'Reisekostenerstattung'} class InternForm(ModelForm): - choice = ChoiceField(choices = INTERN_CHOICES, widget=RadioSelect, + choice = ChoiceField(choices = INTERN_CHOICES.items(), widget=RadioSelect, label = 'Was möchtest Du eingeben?') class Meta: diff --git a/input/migrations/0031_auto_20201028_1402.py b/input/migrations/0031_auto_20201028_1402.py new file mode 100644 index 0000000..63733d2 --- /dev/null +++ b/input/migrations/0031_auto_20201028_1402.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-10-28 14:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0030_auto_20201027_1337'), + ] + + operations = [ + migrations.AlterField( + model_name='project', + name='pid', + field=models.CharField(blank=True, max_length=15, null=True), + ), + ] diff --git a/input/models.py b/input/models.py index 7dc1bed..4062515 100644 --- a/input/models.py +++ b/input/models.py @@ -41,13 +41,13 @@ class Project(Volunteer): choices=ACCOUNTS.items(), null=True,) # the following Fields are not supposed to be edited by users - pid = models.IntegerField(null=True, blank=True) + pid = models.CharField(max_length=15, null=True, blank=True) end_mail_send = models.BooleanField(null=True) def save(self,*args,**kwargs): # is there a way to call super().save() only once? super().save(*args,*kwargs) - self.pid = 10000 + self.pk + self.pid = self.account + str(self.pk) super().save(*args,*kwargs) def __str__(self): diff --git a/input/views.py b/input/views.py index 824a5b0..3bc78a9 100644 --- a/input/views.py +++ b/input/views.py @@ -11,7 +11,7 @@ from django.template import Context from .forms import ProjectForm, ExternForm, LibraryForm, IFGForm, LiteratureForm,\ HonoraryCertificateForm, InternForm, TravelForm, EmailForm,\ - ListForm, BusinessCardForm + ListForm, BusinessCardForm, INTERN_CHOICES from .models import Project, TYPE_CHOICES, Library, Literature from .settings import URLPREFIX, IF_EMAIL @@ -70,7 +70,7 @@ class InternView(CookieWizardView): if step == '1': prev_data = self.get_cleaned_data_for_step('0') choice = prev_data.get('choice') - print(f'choice detection: {TYPE_CHOICES[choice]}') + print(f'choice detection: {INTERN_CHOICES[choice]}') if choice == 'HON': form = HonoraryCertificateForm(data) elif choice == 'PRO':