Compare commits
No commits in common. "93d1f2f9d5321f0dcd2fb0fa496240413efff277" and "ce2e84395d61b05d5d72ac1ff0ca0840d12fa192" have entirely different histories.
93d1f2f9d5
...
ce2e84395d
|
@ -3,7 +3,7 @@ from django.forms import ModelForm, DateField, ChoiceField, RadioSelect, Boolean
|
||||||
from django.contrib.admin.widgets import AdminDateWidget
|
from django.contrib.admin.widgets import AdminDateWidget
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
|
|
||||||
from .models import Project, Volunteer, IFG, Library, TYPE_CHOICES, HonoraryCertificate
|
from .models import Project, Volunteer, IFG, Library, TYPE_CHOICES
|
||||||
from .settings import DATAPROTECTION, FOERDERRICHTLINIEN
|
from .settings import DATAPROTECTION, FOERDERRICHTLINIEN
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,20 +29,6 @@ class VolunteerForm(ModelForm):
|
||||||
model = Volunteer
|
model = Volunteer
|
||||||
exclude = ('granted',)
|
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 LibraryForm(ModelForm):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -52,9 +38,4 @@ class LibraryForm(ModelForm):
|
||||||
class IFGForm(ModelForm):
|
class IFGForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = IFG
|
model = IFG
|
||||||
exclude = ('realname', 'email', 'username', 'granted')
|
exclude = ('realname', 'email', 'username')
|
||||||
|
|
||||||
class HonoraryCertificateForm(ModelForm):
|
|
||||||
class Meta:
|
|
||||||
model = HonoraryCertificate
|
|
||||||
exclude = ('realname', 'email', 'username', 'granted')
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from .views import project, accreditation, travel, certificate, ExternView, \
|
from .views import project, accreditation, travel, certificate, ExternView, done, authorize, deny
|
||||||
done, authorize, deny, InternView
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('project', project, name='project'),
|
path('project', project, name='project'),
|
||||||
|
@ -9,7 +8,6 @@ urlpatterns = [
|
||||||
path('travel', travel, name='travel'),
|
path('travel', travel, name='travel'),
|
||||||
path('certificate', certificate, name='certificate'),
|
path('certificate', certificate, name='certificate'),
|
||||||
path('extern', ExternView.as_view(), name='extern'),
|
path('extern', ExternView.as_view(), name='extern'),
|
||||||
path('intern', InternView.as_view(), name='intern'),
|
|
||||||
path('saved', done, name='done'),
|
path('saved', done, name='done'),
|
||||||
path('authorize/<str:choice>/<int:pk>', authorize, name='authorize'),
|
path('authorize/<str:choice>/<int:pk>', authorize, name='authorize'),
|
||||||
path('deny/<str:choice>/<int:pk>', deny, name='deny')
|
path('deny/<str:choice>/<int:pk>', deny, name='deny')
|
||||||
|
|
|
@ -8,15 +8,13 @@ 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 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 .models import Project, TYPE_CHOICES, Library
|
||||||
from .settings import URLPREFIX, IF_EMAIL
|
from .settings import URLPREFIX, IF_EMAIL
|
||||||
|
|
||||||
|
|
||||||
def authorize(request, choice, pk):
|
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
|
# TODO: write a timestamp which is needed to determine time of next mail
|
||||||
|
|
||||||
if choice in ('BIB', 'ELIT', 'SOFT'):
|
if choice in ('BIB', 'ELIT', 'SOFT'):
|
||||||
|
@ -27,8 +25,7 @@ def authorize(request, choice, pk):
|
||||||
|
|
||||||
|
|
||||||
def deny(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'):
|
if choice in ('BIB', 'ELIT', 'SOFT'):
|
||||||
Library.set_granted(pk,False)
|
Library.set_granted(pk,False)
|
||||||
|
@ -71,56 +68,17 @@ def done(request):
|
||||||
def extern(request):
|
def extern(request):
|
||||||
return HttpResponse("The world out there is large and dangerous")
|
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, ProjectForm]
|
|
||||||
|
|
||||||
def get_form(self, step=None, data=None, files=None):
|
|
||||||
if step is None:
|
|
||||||
step = self.steps.current
|
|
||||||
print ("get_form() step " + step)
|
|
||||||
|
|
||||||
if step == '1':
|
|
||||||
prev_data = self.get_cleaned_data_for_step('0')
|
|
||||||
choice = prev_data.get('choice')
|
|
||||||
if choice == 'HON':
|
|
||||||
print ('Ehrenamtsbescheinigung detected!')
|
|
||||||
form = HonoraryCertificateForm(data)
|
|
||||||
else:
|
|
||||||
print('ERROR! UNKNOWN FORMTYPE!')
|
|
||||||
else:
|
|
||||||
form = super().get_form(step, data, files)
|
|
||||||
return form
|
|
||||||
|
|
||||||
def done(self, form_list, **kwargs):
|
|
||||||
print('ExternView.done() reached')
|
|
||||||
# gather data from all forms
|
|
||||||
data = {}
|
|
||||||
for form in form_list:
|
|
||||||
data = {**data, **form.cleaned_data}
|
|
||||||
print(data)
|
|
||||||
|
|
||||||
# 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
|
|
||||||
form.realname = data['realname']
|
|
||||||
form.username = data['username']
|
|
||||||
form.email = data['email']
|
|
||||||
form.save()
|
|
||||||
|
|
||||||
return done(self.request)
|
|
||||||
|
|
||||||
|
|
||||||
class ExternView(CookieWizardView):
|
class ExternView(CookieWizardView):
|
||||||
'''This View is for Volunteers'''
|
|
||||||
|
|
||||||
template_name = "input/extern.html"
|
template_name = "input/extern.html"
|
||||||
form_list = [VolunteerForm, LibraryForm]
|
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):
|
def get_form(self, step=None, data=None, files=None):
|
||||||
if step is None:
|
if step is None:
|
||||||
step = self.steps.current
|
step = self.steps.current
|
||||||
|
@ -196,3 +154,6 @@ class ExternView(CookieWizardView):
|
||||||
return HttpResponse('Invalid header found.')
|
return HttpResponse('Invalid header found.')
|
||||||
|
|
||||||
return done(self.request)
|
return done(self.request)
|
||||||
|
# return render(self.request, 'saved', {
|
||||||
|
# 'form_data': [form.cleaned_data for form in form_list],
|
||||||
|
# })
|
||||||
|
|
Loading…
Reference in New Issue