From a78c10c0438da8fee98babef566740b1e2ca4d85 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 21 Oct 2020 13:53:39 +0200 Subject: [PATCH] new Project Field end date. some cleanup in ProjectForm and Project --- input/forms.py | 4 ++- input/migrations/0017_auto_20201021_1145.py | 28 +++++++++++++++++++++ input/migrations/0018_auto_20201021_1147.py | 18 +++++++++++++ input/migrations/0019_auto_20201021_1148.py | 18 +++++++++++++ input/models.py | 6 +++-- input/views.py | 10 +++++--- 6 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 input/migrations/0017_auto_20201021_1145.py create mode 100644 input/migrations/0018_auto_20201021_1147.py create mode 100644 input/migrations/0019_auto_20201021_1148.py diff --git a/input/forms.py b/input/forms.py index 990e1e5..c7d71e3 100644 --- a/input/forms.py +++ b/input/forms.py @@ -9,11 +9,13 @@ from .settings import DATAPROTECTION, FOERDERRICHTLINIEN class ProjectForm(ModelForm): - start = DateField(widget=AdminDateWidget()) + # start = DateField(widget=AdminDateWidget()) class Meta: model = Project exclude = ('pid', 'granted', 'username', 'realname', 'email') + widgets = {'start': AdminDateWidget(), + 'end': AdminDateWidget(),} class VolunteerForm(ModelForm): diff --git a/input/migrations/0017_auto_20201021_1145.py b/input/migrations/0017_auto_20201021_1145.py new file mode 100644 index 0000000..72d5901 --- /dev/null +++ b/input/migrations/0017_auto_20201021_1145.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.1 on 2020-10-21 11:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0016_project_account'), + ] + + operations = [ + migrations.AddField( + model_name='project', + name='end', + field=models.DateField(null=True, verbose_name='Erwartetes Projektende'), + ), + migrations.AlterField( + model_name='project', + name='account', + field=models.CharField(choices=[('21103', '21103 Willkommen'), ('21111', '21111 Förderung'), ('21112', '21112 WikiCon'), ('21113', '21113 Wikimania/Unterstützung Ehrenamtliche'), ('21115', '21115 Lokale Räume, Berlin'), ('21116', '21116 Lokale Räume, Hamburg'), ('21117', '21117 Lokale Räume, Hannover'), ('21118', '21118 Lokale Räume, Köln'), ('21119', '21119 Lokale Räume, München'), ('21120', '21120 Lokale Räume, Fürth'), ('21125', '21125 Lokale Räume, allgemein'), ('21134', '21134 Größe'), ('21137', '21137 Beitragen'), ('21138', '21138 Vermittlung')], max_length=5, null=True, verbose_name='Kostenstelle'), + ), + migrations.AlterField( + model_name='project', + name='start', + field=models.DateField(verbose_name='Start Datum'), + ), + ] diff --git a/input/migrations/0018_auto_20201021_1147.py b/input/migrations/0018_auto_20201021_1147.py new file mode 100644 index 0000000..b1bf32e --- /dev/null +++ b/input/migrations/0018_auto_20201021_1147.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-10-21 11:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0017_auto_20201021_1145'), + ] + + operations = [ + migrations.AlterField( + model_name='project', + name='start', + field=models.DateField(verbose_name='Startdatum'), + ), + ] diff --git a/input/migrations/0019_auto_20201021_1148.py b/input/migrations/0019_auto_20201021_1148.py new file mode 100644 index 0000000..6ef4311 --- /dev/null +++ b/input/migrations/0019_auto_20201021_1148.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-10-21 11:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0018_auto_20201021_1147'), + ] + + operations = [ + migrations.AlterField( + model_name='project', + name='start', + field=models.DateField(null=True, verbose_name='Startdatum'), + ), + ] diff --git a/input/models.py b/input/models.py index 2f504ee..dfa3145 100644 --- a/input/models.py +++ b/input/models.py @@ -19,8 +19,10 @@ class Volunteer(models.Model): class Project(Volunteer): name = models.CharField(max_length=200) - start = models.DateField('start date') - account = models.CharField(max_length=5, choices=ACCOUNTS.items(), null=True) + start = models.DateField('Startdatum', null=True) + end = models.DateField('Erwartetes Projektende', null=True) + account = models.CharField('Kostenstelle', max_length=5, + choices=ACCOUNTS.items(), null=True,) pid = models.IntegerField(null=True, blank=True) # automaticly generated diff --git a/input/views.py b/input/views.py index dfac4f2..13094bb 100644 --- a/input/views.py +++ b/input/views.py @@ -6,7 +6,6 @@ from django.core.mail import send_mail, BadHeaderError from django.conf import settings from django.template.loader import get_template from django.template import Context -# from django.contrib.sites.models import Site from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm,\ HonoraryCertificateForm, InternForm @@ -47,6 +46,9 @@ class InternView(CookieWizardView): form_list = [InternForm, ProjectForm] def get_form(self, step=None, data=None, files=None): + '''this function determines which part of the multipart form is + displayed next''' + if step is None: step = self.steps.current print ("get_form() step " + step) @@ -94,6 +96,9 @@ class ExternView(CookieWizardView): form_list = [VolunteerForm, LibraryForm] def get_form(self, step=None, data=None, files=None): + '''this function determines which part of the multipart form is + displayed next''' + if step is None: step = self.steps.current print ("get_form() step " + step) @@ -125,8 +130,7 @@ class ExternView(CookieWizardView): # write data to database form = form.save(commit=False) # we have to copy the data from the first form here - # this is ugly code. how can we copy this without explicit writing? - # i found no way to access the ModelForm.Meta.exclude-tupel + # this is a bit ugly code. how can we copy this without explicit writing? form.realname = data['realname'] form.username = data['username'] form.email = data['email']