From a6474e07e858400c771b706de151de79ab555878 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 26 Oct 2020 12:06:26 +0100 Subject: [PATCH] some reorganisations of models, forms and views --- input/forms.py | 8 +++---- input/migrations/0025_auto_20201026_1048.py | 25 +++++++++++++++++++++ input/models.py | 2 +- input/views.py | 10 ++++----- 4 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 input/migrations/0025_auto_20201026_1048.py diff --git a/input/forms.py b/input/forms.py index 7467ebf..84fc9d0 100644 --- a/input/forms.py +++ b/input/forms.py @@ -3,7 +3,7 @@ from django.forms import ModelForm, DateField, ChoiceField, RadioSelect, Boolean from django.contrib.admin.widgets import AdminDateWidget from django.utils.html import format_html -from .models import Project, Volunteer, IFG, Library, TYPE_CHOICES, HonoraryCertificate, Travel +from .models import Project, Volunteer, Extern, IFG, Library, TYPE_CHOICES, HonoraryCertificate, Travel from .settings import DATAPROTECTION, FOERDERRICHTLINIEN @@ -13,11 +13,11 @@ class ProjectForm(ModelForm): class Meta: model = Project - exclude = ('pid', 'granted', 'granted_date', 'username', 'realname', 'email', 'project_end_mail', 'survey_mail_send') + exclude = ('pid', 'granted', 'granted_date', 'realname', 'email', 'project_end_mail', 'survey_mail_send') widgets = {'start': AdminDateWidget(), 'end': AdminDateWidget(),} -class VolunteerForm(ModelForm): +class ExternForm(ModelForm): choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect, label='Was möchtest Du beantragen?') @@ -27,7 +27,7 @@ class VolunteerForm(ModelForm): DATAPROTECTION, FOERDERRICHTLINIEN)) class Meta: - model = Volunteer + model = Extern exclude = ('granted', 'granted_date', 'survey_mail_send') INTERN_CHOICES = [('PRO', 'Projektsteckbrief'), diff --git a/input/migrations/0025_auto_20201026_1048.py b/input/migrations/0025_auto_20201026_1048.py new file mode 100644 index 0000000..bc2aefb --- /dev/null +++ b/input/migrations/0025_auto_20201026_1048.py @@ -0,0 +1,25 @@ +# Generated by Django 3.1.1 on 2020-10-26 10:48 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('input', '0024_travel'), + ] + + operations = [ + migrations.RemoveField( + model_name='honorarycertificate', + name='username', + ), + migrations.RemoveField( + model_name='project', + name='username', + ), + migrations.RemoveField( + model_name='travel', + name='username', + ), + ] diff --git a/input/models.py b/input/models.py index b96091a..b5ea84a 100644 --- a/input/models.py +++ b/input/models.py @@ -8,7 +8,7 @@ from .settings import ACCOUNTS class Volunteer(models.Model): realname = models.CharField(max_length=200, null=True) email = models.CharField(max_length=200, null=True) - username = models.CharField(max_length=200, null=True) + # username = models.CharField(max_length=200, null=True) # the following Fields are not supposed to be edited by users granted = models.BooleanField(null=True) diff --git a/input/views.py b/input/views.py index 05b085f..eb4dda8 100644 --- a/input/views.py +++ b/input/views.py @@ -7,7 +7,7 @@ from django.conf import settings from django.template.loader import get_template from django.template import Context -from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm,\ +from .forms import ProjectForm, ExternForm, LibraryForm, IFGForm,\ HonoraryCertificateForm, InternForm, TravelForm from .models import Project, TYPE_CHOICES, Library from .settings import URLPREFIX, IF_EMAIL @@ -72,7 +72,7 @@ class InternView(CookieWizardView): return form def done(self, form_list, **kwargs): - print('ExternView.done() reached') + print('InternView.done() reached') # gather data from all forms data = {} for form in form_list: @@ -85,7 +85,7 @@ class InternView(CookieWizardView): # this is 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.username = data['username'] + # form.username = data['username'] form.email = data['email'] form.save() @@ -96,7 +96,7 @@ class ExternView(CookieWizardView): '''This View is for Volunteers''' template_name = "input/extern.html" - form_list = [VolunteerForm, LibraryForm] + form_list = [ExternForm, LibraryForm] def get_form(self, step=None, data=None, files=None): '''this function determines which part of the multipart form is @@ -135,7 +135,7 @@ class ExternView(CookieWizardView): # we have to copy the data from the first form here # this is a bit ugly code. how can we copy this without explicit writing? form.realname = data['realname'] - form.username = data['username'] + # form.username = data['username'] form.email = data['email'] # write type of form in some cases if data['choice'] in ('BIB', 'ELIT', 'SOFT'):