From a7e8b9a19a13c03095c08c6848df54ebd502dc28 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 21 Oct 2020 09:54:12 +0200 Subject: [PATCH] some work towards InternView --- input/forms.py | 23 +++++++++++++++++++++-- input/urls.py | 4 +++- input/views.py | 26 +++++++++++++++----------- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/input/forms.py b/input/forms.py index b1250d5..87fdd9c 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 +from .models import Project, Volunteer, IFG, Library, TYPE_CHOICES, HonoraryCertificate from .settings import DATAPROTECTION, FOERDERRICHTLINIEN @@ -29,6 +29,20 @@ class VolunteerForm(ModelForm): model = Volunteer exclude = ('granted',) +INTERN_CHOICES = [('PRO', 'Projektsteckbrief'), + ('HON', 'Eherenamtsbescheinigung'), + ('AKK', 'Akkreditierung oder Redaktionsbestätigung'), + ('TRAV', 'Reisekostenerstattung')] + +class InternForm(ModelForm): + choice = ChoiceField(choices = INTERN_CHOICES, widget=RadioSelect, + label = 'Was möchtest Du eingeben?') + + class Meta: + model = Volunteer + exclude = ('granted',) + + class LibraryForm(ModelForm): class Meta: @@ -38,4 +52,9 @@ class LibraryForm(ModelForm): class IFGForm(ModelForm): class Meta: model = IFG - exclude = ('realname', 'email', 'username') + exclude = ('realname', 'email', 'username', 'granted') + +class HonoraryCertificateForm(ModelForm): + class Meta: + model = HonoraryCertificate + exclude = ('realname', 'email', 'username', 'granted') diff --git a/input/urls.py b/input/urls.py index 263d809..9f59f52 100644 --- a/input/urls.py +++ b/input/urls.py @@ -1,6 +1,7 @@ from django.urls import path -from .views import project, accreditation, travel, certificate, ExternView, done, authorize, deny +from .views import project, accreditation, travel, certificate, ExternView, \ + done, authorize, deny, InternView urlpatterns = [ path('project', project, name='project'), @@ -8,6 +9,7 @@ urlpatterns = [ path('travel', travel, name='travel'), path('certificate', certificate, name='certificate'), path('extern', ExternView.as_view(), name='extern'), + path('intern', InternView.as_view(), name='intern'), path('saved', done, name='done'), path('authorize//', authorize, name='authorize'), path('deny//', deny, name='deny') diff --git a/input/views.py b/input/views.py index bf3226d..2b11577 100644 --- a/input/views.py +++ b/input/views.py @@ -8,15 +8,17 @@ 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 +from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm,\ + HonoraryCertificateForm, InternForm from .models import Project, TYPE_CHOICES, Library from .settings import URLPREFIX, IF_EMAIL def authorize(request, choice, pk): - '''If IF grant a support they click a link in a mail which leads here''' + '''If IF grant a support they click a link in a mail which leads here. + We write the granted field in the database here and set a timestamp.''' # TODO: write a timestamp which is needed to determine time of next mail - + if choice in ('BIB', 'ELIT', 'SOFT'): Library.set_granted(pk,True) return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}") @@ -25,7 +27,8 @@ def authorize(request, choice, pk): def deny(request, choice, pk): - '''If IF denies a support they click a link in a mail which leads here''' + '''If IF denies a support they click a link in a mail which leads here + We write the granted field in the database here.''' if choice in ('BIB', 'ELIT', 'SOFT'): Library.set_granted(pk,False) @@ -68,17 +71,18 @@ def done(request): def extern(request): return HttpResponse("The world out there is large and dangerous") +class InternView(CookieWizardView): + '''This View is for the WMDE-employees only''' + + template_name = 'input/extern.html' + form_list = [InternForm, HonoraryCertificateForm] + class ExternView(CookieWizardView): + '''This View is for Volunteers''' + template_name = "input/extern.html" form_list = [VolunteerForm, LibraryForm] - # def process_step(self, form): - # if form.cleaned_data.get('choice') == 'IFG': - # print ('IFG detected!') - # self.form_list = [VolunteerForm, IFGForm] - # print('leaving process_step()') - # return self.get_form_step_data(form) - def get_form(self, step=None, data=None, files=None): if step is None: step = self.steps.current