From fa41a9332505854a6407d02389079e7183eecce4 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Wed, 28 Oct 2020 15:49:18 +0100 Subject: [PATCH] broken version, still working on authentification --- foerderbarometer/urls.py | 1 + input/views.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/foerderbarometer/urls.py b/foerderbarometer/urls.py index d4bb31b..7f1b85a 100644 --- a/foerderbarometer/urls.py +++ b/foerderbarometer/urls.py @@ -19,4 +19,5 @@ from django.urls import path, include urlpatterns = [ path('', include("input.urls")), path('admin/', admin.site.urls), + path('accounts/', include('django.contrib.auth.urls')), ] diff --git a/input/views.py b/input/views.py index 3bc78a9..85c6c97 100644 --- a/input/views.py +++ b/input/views.py @@ -8,6 +8,8 @@ from django.core.mail import send_mail, BadHeaderError from django.conf import settings from django.template.loader import get_template from django.template import Context +from django.contrib.auth.decorators import login_required +from django.contrib.auth.mixins import LoginRequiredMixin from .forms import ProjectForm, ExternForm, LibraryForm, IFGForm, LiteratureForm,\ HonoraryCertificateForm, InternForm, TravelForm, EmailForm,\ @@ -27,7 +29,7 @@ def auth_deny(choice,pk,auth): return HttpResponse(f'ERROR! UNKNWON CHOICE TYPE! {choice}') return False - +@login_required def authorize(request, choice, pk): '''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.''' @@ -38,7 +40,7 @@ def authorize(request, choice, pk): else: return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}") - +@login_required def deny(request, choice, pk): '''If IF denies a support they click a link in a mail which leads here We write the granted field in the database here.''' @@ -53,7 +55,8 @@ def deny(request, choice, pk): def done(request): return HttpResponse("Your data is save now.") -class InternView(CookieWizardView): + +class InternView(LoginRequiredMixin, CookieWizardView): '''This View is for WMDE-employees only''' template_name = 'input/extern.html'