forked from beba/foerderbarometer
removed intern view
This commit is contained in:
parent
165ad050ad
commit
6306567ebd
|
|
@ -152,8 +152,6 @@ OAUTH_URL_WHITELISTS = ['/admin']
|
|||
|
||||
OAUTH_COOKIE_SESSION_ID = 'sso_session_id'
|
||||
|
||||
INTERN_VIEW_ENABLED = env('INTERN_VIEW_ENABLED', False)
|
||||
|
||||
IF_EMAIL = env('IF_EMAIL', 'community@wikimedia.de')
|
||||
|
||||
SURVEY_EMAIL = env('SURVEY_EMAIL', 'sandro.halank@wikimedia.de')
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from datetime import date
|
||||
from unittest import skipUnless
|
||||
|
||||
from django.test import TestCase, Client
|
||||
from django.conf import settings
|
||||
|
|
@ -33,12 +32,6 @@ class TestWithoutLogin(TestCase):
|
|||
#print (response.content)
|
||||
self.assertContains(response,'<a href="https://srcsrv.wikimedia.de/beba/foerderbarometer">Sourcecode</a>')
|
||||
|
||||
@skipUnless(settings.INTERN_VIEW_ENABLED, 'Intern view is disabled.')
|
||||
def test_access_denied(self):
|
||||
'''test if /intern redirects to login page if not logged in'''
|
||||
response = self.client.get('/intern', follow=True)
|
||||
self.assertContains(response,'password')
|
||||
|
||||
def _postform(self, data, expected_form):
|
||||
'''helper function to manage the Wizzard'''
|
||||
response = self.client.post('/', data, follow=False)
|
||||
|
|
@ -98,13 +91,6 @@ class TestWithLogin(TestCase):
|
|||
self.client = Client()
|
||||
self.user = User.objects.create_user('vladimir', 'vladimir@reiherzehe.com', 'reiherzehe')
|
||||
|
||||
@skipUnless(settings.INTERN_VIEW_ENABLED, 'Intern view is disabled.')
|
||||
def test_access(self):
|
||||
'''test if /intern gives an answer'''
|
||||
self.assertEqual(self.client.login(username='testuser', password='testpasswd'), True)
|
||||
response = self.client.get('/intern')
|
||||
self.assertContains(response,'Übersicht aller Förderangebote')
|
||||
|
||||
def test_project_of_year(self):
|
||||
''' test if the finance id is resettet ad start of year'''
|
||||
acc = Account.objects.create()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from django.conf import settings
|
||||
from django.urls import path
|
||||
|
||||
from .views import ExternView, index, done, authorize, deny, InternView, export
|
||||
from .views import ExternView, index, done, authorize, deny, export
|
||||
|
||||
urlpatterns = [
|
||||
path('', index, name='index'),
|
||||
|
|
@ -11,6 +10,3 @@ urlpatterns = [
|
|||
path('authorize/<str:choice>/<int:pk>', authorize, name='authorize'),
|
||||
path('deny/<str:choice>/<int:pk>', deny, name='deny'),
|
||||
]
|
||||
|
||||
if settings.INTERN_VIEW_ENABLED: # pragma: no cover
|
||||
urlpatterns.insert(2, path('intern', InternView.as_view(), name='intern'))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
from datetime import date
|
||||
from smtplib import SMTPException
|
||||
|
||||
from django.shortcuts import render
|
||||
|
|
@ -9,19 +8,14 @@ from django.core.mail import BadHeaderError, EmailMultiAlternatives
|
|||
from django.template.loader import get_template
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
|
||||
from .forms import (
|
||||
INTERN_CHOICES,
|
||||
ProjectForm,
|
||||
ExternForm,
|
||||
LibraryForm,
|
||||
ELiteratureForm,
|
||||
SoftwareForm,
|
||||
IFGForm,
|
||||
LiteratureForm,
|
||||
HonoraryCertificateForm,
|
||||
InternForm,
|
||||
TravelForm,
|
||||
EmailForm,
|
||||
ListForm,
|
||||
|
|
@ -75,78 +69,10 @@ def deny(request, choice, pk):
|
|||
def done(request):
|
||||
return HttpResponse("Deine Anfrage wurde gesendet. Du erhältst in Kürze eine E-Mail-Benachrichtigung mit deinen Angaben. Für alle Fragen kontaktiere bitte das Team Communitys und Engagement unter community@wikimedia.de.")
|
||||
|
||||
|
||||
def index(request):
|
||||
return render(request, 'input/index.html')
|
||||
|
||||
class InternView(LoginRequiredMixin, CookieWizardView): # pragma: no cover
|
||||
'''This View is for WMDE-employees only'''
|
||||
|
||||
template_name = 'input/extern.html'
|
||||
form_list = [InternForm, ProjectForm]
|
||||
|
||||
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:
|
||||
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')
|
||||
print(f'choice detection: {INTERN_CHOICES[choice]}')
|
||||
if choice == 'HON':
|
||||
form = HonoraryCertificateForm(data)
|
||||
elif choice == 'PRO':
|
||||
form = ProjectForm(data)
|
||||
elif choice == 'TRAV':
|
||||
form = TravelForm(data)
|
||||
else:
|
||||
raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice} in InternView')
|
||||
self.choice = choice
|
||||
else:
|
||||
form = super().get_form(step, data, files)
|
||||
form.fields['realname'].help_text = mark_safe("Vor- und Zuname (Realname), Wer hat das Projekt beantragt?<br>\
|
||||
Wer ist Hauptansprechperson? Bei WMDE-MAs immer „(WMDE)“,<br>\
|
||||
bei externen Partnern „(PART)“ hinzufügen.")
|
||||
return form
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
if hasattr(self, 'choice'):
|
||||
context["choice"] = INTERN_CHOICES[self.choice]
|
||||
return context
|
||||
|
||||
def done(self, form_list, **kwargs):
|
||||
print('InternView.done() reached')
|
||||
# gather data from all forms
|
||||
data = {}
|
||||
for form in form_list:
|
||||
data = {**data, **form.cleaned_data}
|
||||
|
||||
if data['choice'] == 'LIT':
|
||||
if data['selfbuy'] == 'TRUE':
|
||||
data['selfbuy_give_data'] = 'False'
|
||||
|
||||
# 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.granted = True
|
||||
form.granted_date = date.today()
|
||||
|
||||
if data['choice'] == 'LIT':
|
||||
form.selfbuy_give_data = data['selfbuy_give_data']
|
||||
|
||||
form.save()
|
||||
|
||||
return done(self.request)
|
||||
|
||||
|
||||
class ExternView(CookieWizardView):
|
||||
'''This View is for Volunteers'''
|
||||
|
|
|
|||
Loading…
Reference in New Issue