some work towards InternView

This commit is contained in:
Benni Bärmann 2020-10-21 09:54:12 +02:00
parent ce2e84395d
commit a7e8b9a19a
3 changed files with 39 additions and 14 deletions

View File

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

View File

@ -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/<str:choice>/<int:pk>', authorize, name='authorize'),
path('deny/<str:choice>/<int:pk>', deny, name='deny')

View File

@ -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