From c96f195b00b8e85068d4d87fe0f82a13601c7c87 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 20 Oct 2020 08:06:36 +0200 Subject: [PATCH] some preliminary work for authorize/deny links in mail --- input/forms.py | 1 - input/templates/input/if_mail.txt | 14 +++++++------- input/urls.py | 6 ++++-- input/views.py | 9 +++++++++ 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/input/forms.py b/input/forms.py index a243cfe..191aff7 100644 --- a/input/forms.py +++ b/input/forms.py @@ -21,7 +21,6 @@ class VolunteerForm(ModelForm): class Meta: model = Volunteer fields = '__all__' - # labels = {'choice': 'Was möchtest Du beantragen?'} class LibraryForm(ModelForm): diff --git a/input/templates/input/if_mail.txt b/input/templates/input/if_mail.txt index 041a96f..bf11055 100644 --- a/input/templates/input/if_mail.txt +++ b/input/templates/input/if_mail.txt @@ -1,20 +1,20 @@ +{{data}} + + Hallo Team Ideenförderung, es gab einen neuen Antrag von {{data.realname}}. -Username {{data.username}} fragt ein -{% if data.choice == 'LIT' %} Literaturstipendium +Der Nutzer mit dem Username {{data.username}} fragt ein {% if data.choice == 'LIT' %} Literaturstipendium {% elif data.choice == 'BIB' %} Bibliotheksstipendium {% elif data.choice == 'IFG' %} IFG {% elif data.choice == 'ELIT' %} eLiteraturstipendium {% elif data.choice == 'SOFT' %} Softwarestipendium {% elif data.choice == 'VIS' %} Visitenkarten, Mailingliste oder E-Mail-Adresse -{% else %} ERROR UNKNOWN FORMTYPE -{% endif %} -an. +{% else %} ERROR UNKNOWN FORMTYPE {% endif %} an. -Genehmigen: INSERT Link here -Ablehnen: INSERT Link here +Genehmigen: http://127.0.0.1:8000/authorize/{{data.id}} +Ablehnen: http://127.0.0.1:8000/deny/{{data.id}} {% comment %} diff --git a/input/urls.py b/input/urls.py index 3a1410b..c8e0d26 100644 --- a/input/urls.py +++ b/input/urls.py @@ -1,6 +1,6 @@ from django.urls import path -from .views import project, accreditation, travel, certificate, ExternView, done +from .views import project, accreditation, travel, certificate, ExternView, done, authorize, deny urlpatterns = [ path('project', project, name='project'), @@ -8,5 +8,7 @@ urlpatterns = [ path('travel', travel, name='travel'), path('certificate', certificate, name='certificate'), path('extern', ExternView.as_view(), name='extern'), - path('saved', done, name='done') + 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 99a77e9..9e12182 100644 --- a/input/views.py +++ b/input/views.py @@ -10,6 +10,12 @@ from django.template import Context from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm from .models import Project, TYPE_CHOICES +def authorize(request): + print('AUTHORIZE!') + +def deny(request): + print('DENY!') + def project(request): # return HttpResponse("Hello, world. You're at the input form") # ProjectFormSet = modelformset_factory(Project, fields='__all__') @@ -100,6 +106,9 @@ class ExternView(CookieWizardView): form.type = data['choice'] form.save() + # add primary key to context + data['id'] = 100 + # we need to send the following mails here: context = { 'data': data } try: