work on intern/PRO, korrekt pid implemented

This commit is contained in:
Benni Bärmann 2020-10-28 15:04:53 +01:00
parent 4d623f0aa8
commit a0c57c7d4d
4 changed files with 27 additions and 9 deletions

View File

@ -15,7 +15,7 @@ class ProjectForm(ModelForm):
class Meta: class Meta:
model = Project 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(), widgets = {'start': AdminDateWidget(),
'end': AdminDateWidget(),} 'end': AdminDateWidget(),}
@ -32,12 +32,12 @@ class ExternForm(ModelForm):
model = Extern model = Extern
exclude = ('granted', 'granted_date', 'survey_mail_send') exclude = ('granted', 'granted_date', 'survey_mail_send')
INTERN_CHOICES = [('PRO', 'Projektsteckbrief'), INTERN_CHOICES = {'PRO': 'Projektsteckbrief',
('HON', 'Ehrenamtsbescheinigung, Akkreditierung oder Redaktionsbestätigung'), 'HON': 'Ehrenamtsbescheinigung, Akkreditierung oder Redaktionsbestätigung',
('TRAV', 'Reisekostenerstattung')] 'TRAV': 'Reisekostenerstattung'}
class InternForm(ModelForm): class InternForm(ModelForm):
choice = ChoiceField(choices = INTERN_CHOICES, widget=RadioSelect, choice = ChoiceField(choices = INTERN_CHOICES.items(), widget=RadioSelect,
label = 'Was möchtest Du eingeben?') label = 'Was möchtest Du eingeben?')
class Meta: class Meta:

View File

@ -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),
),
]

View File

@ -41,13 +41,13 @@ class Project(Volunteer):
choices=ACCOUNTS.items(), null=True,) choices=ACCOUNTS.items(), null=True,)
# the following Fields are not supposed to be edited by users # 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) end_mail_send = models.BooleanField(null=True)
def save(self,*args,**kwargs): def save(self,*args,**kwargs):
# is there a way to call super().save() only once? # is there a way to call super().save() only once?
super().save(*args,*kwargs) super().save(*args,*kwargs)
self.pid = 10000 + self.pk self.pid = self.account + str(self.pk)
super().save(*args,*kwargs) super().save(*args,*kwargs)
def __str__(self): def __str__(self):

View File

@ -11,7 +11,7 @@ from django.template import Context
from .forms import ProjectForm, ExternForm, LibraryForm, IFGForm, LiteratureForm,\ from .forms import ProjectForm, ExternForm, LibraryForm, IFGForm, LiteratureForm,\
HonoraryCertificateForm, InternForm, TravelForm, EmailForm,\ HonoraryCertificateForm, InternForm, TravelForm, EmailForm,\
ListForm, BusinessCardForm ListForm, BusinessCardForm, INTERN_CHOICES
from .models import Project, TYPE_CHOICES, Library, Literature from .models import Project, TYPE_CHOICES, Library, Literature
from .settings import URLPREFIX, IF_EMAIL from .settings import URLPREFIX, IF_EMAIL
@ -70,7 +70,7 @@ class InternView(CookieWizardView):
if step == '1': if step == '1':
prev_data = self.get_cleaned_data_for_step('0') prev_data = self.get_cleaned_data_for_step('0')
choice = prev_data.get('choice') choice = prev_data.get('choice')
print(f'choice detection: {TYPE_CHOICES[choice]}') print(f'choice detection: {INTERN_CHOICES[choice]}')
if choice == 'HON': if choice == 'HON':
form = HonoraryCertificateForm(data) form = HonoraryCertificateForm(data)
elif choice == 'PRO': elif choice == 'PRO':