|
|
@ -9,33 +9,45 @@ from django.conf import settings |
|
|
|
from django.template.loader import get_template |
|
|
|
from django.template import Context |
|
|
|
|
|
|
|
from .forms import ProjectForm, ExternForm, LibraryForm, IFGForm,\ |
|
|
|
HonoraryCertificateForm, InternForm, TravelForm, EmailForm |
|
|
|
from .models import Project, TYPE_CHOICES, Library |
|
|
|
from .forms import ProjectForm, ExternForm, LibraryForm, IFGForm, LiteratureForm,\ |
|
|
|
HonoraryCertificateForm, InternForm, TravelForm, EmailForm,\ |
|
|
|
ListForm, BusinessCardForm |
|
|
|
from .models import Project, TYPE_CHOICES, Library, Literature |
|
|
|
from .settings import URLPREFIX, IF_EMAIL |
|
|
|
|
|
|
|
|
|
|
|
def auth_deny(choice,pk,auth): |
|
|
|
if choice in ('BIB', 'ELIT', 'SOFT'): |
|
|
|
Library.set_granted(pk,auth) |
|
|
|
if choice == 'LIT': |
|
|
|
Literature.set_granted(pk,auth) |
|
|
|
if choice == 'IFG': |
|
|
|
IFG.set_granted(pk,auth) |
|
|
|
else: |
|
|
|
return HttpResponse(f'ERROR! UNKNWON CHOICE TYPE! {choice}') |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
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.''' |
|
|
|
# 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}") |
|
|
|
ret = auth_deny(choice, pk, True) |
|
|
|
if ret: |
|
|
|
return ret |
|
|
|
else: |
|
|
|
return HttpResponse(f'ERROR! UNKNWON CHOICE TYPE! {choice}') |
|
|
|
return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}") |
|
|
|
|
|
|
|
|
|
|
|
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.''' |
|
|
|
|
|
|
|
if choice in ('BIB', 'ELIT', 'SOFT'): |
|
|
|
Library.set_granted(pk,False) |
|
|
|
return HttpResponse(f"DENIED! choice: {choice}, pk: {pk}") |
|
|
|
ret = auth_deny(choice, pk, False) |
|
|
|
if ret: |
|
|
|
return ret |
|
|
|
else: |
|
|
|
return HttpResponse(f'ERROR! UNKNWON CHOICE TYPE {choice}!') |
|
|
|
return HttpResponse(f"DENIED! choice: {choice}, pk: {pk}") |
|
|
|
|
|
|
|
|
|
|
|
def done(request): |
|
|
@ -119,6 +131,12 @@ class ExternView(CookieWizardView): |
|
|
|
form.fields['library'].label = TYPE_CHOICES[choice] |
|
|
|
elif choice == 'MAIL': |
|
|
|
form = EmailForm(data) |
|
|
|
elif choice == 'LIT': |
|
|
|
form = LiteratureForm(data) |
|
|
|
elif choice == 'VIS': |
|
|
|
form = BusinessCardForm(data) |
|
|
|
elif choice == 'LIST': |
|
|
|
form = ListForm(data) |
|
|
|
else: |
|
|
|
raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice} in ExternView') |
|
|
|
else: |
|
|
|