new Project Field end date. some cleanup in ProjectForm and Project

This commit is contained in:
Benni Bärmann 2020-10-21 13:53:39 +02:00
parent 9e0903ca0e
commit a78c10c043
6 changed files with 78 additions and 6 deletions

View File

@ -9,11 +9,13 @@ from .settings import DATAPROTECTION, FOERDERRICHTLINIEN
class ProjectForm(ModelForm): class ProjectForm(ModelForm):
start = DateField(widget=AdminDateWidget()) # start = DateField(widget=AdminDateWidget())
class Meta: class Meta:
model = Project model = Project
exclude = ('pid', 'granted', 'username', 'realname', 'email') exclude = ('pid', 'granted', 'username', 'realname', 'email')
widgets = {'start': AdminDateWidget(),
'end': AdminDateWidget(),}
class VolunteerForm(ModelForm): class VolunteerForm(ModelForm):

View File

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

View File

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

View File

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

View File

@ -19,8 +19,10 @@ class Volunteer(models.Model):
class Project(Volunteer): class Project(Volunteer):
name = models.CharField(max_length=200) name = models.CharField(max_length=200)
start = models.DateField('start date') start = models.DateField('Startdatum', null=True)
account = models.CharField(max_length=5, choices=ACCOUNTS.items(), 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 pid = models.IntegerField(null=True, blank=True) # automaticly generated

View File

@ -6,7 +6,6 @@ from django.core.mail import send_mail, BadHeaderError
from django.conf import settings from django.conf import settings
from django.template.loader import get_template from django.template.loader import get_template
from django.template import Context from django.template import Context
# from django.contrib.sites.models import Site
from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm,\ from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm,\
HonoraryCertificateForm, InternForm HonoraryCertificateForm, InternForm
@ -47,6 +46,9 @@ class InternView(CookieWizardView):
form_list = [InternForm, ProjectForm] form_list = [InternForm, ProjectForm]
def get_form(self, step=None, data=None, files=None): 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: if step is None:
step = self.steps.current step = self.steps.current
print ("get_form() step " + step) print ("get_form() step " + step)
@ -94,6 +96,9 @@ class ExternView(CookieWizardView):
form_list = [VolunteerForm, LibraryForm] form_list = [VolunteerForm, LibraryForm]
def get_form(self, step=None, data=None, files=None): 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: if step is None:
step = self.steps.current step = self.steps.current
print ("get_form() step " + step) print ("get_form() step " + step)
@ -125,8 +130,7 @@ class ExternView(CookieWizardView):
# write data to database # write data to database
form = form.save(commit=False) form = form.save(commit=False)
# we have to copy the data from the first form here # we have to copy the data from the first form here
# this is ugly code. how can we copy this without explicit writing? # this is a bit ugly code. how can we copy this without explicit writing?
# i found no way to access the ModelForm.Meta.exclude-tupel
form.realname = data['realname'] form.realname = data['realname']
form.username = data['username'] form.username = data['username']
form.email = data['email'] form.email = data['email']