- | Was möchtest du beantragen? |
-
- Projektförderung
-
+
{% endblock %}
diff --git a/input/tests/views.py b/input/tests/views.py
index 4cf1bab..723391c 100644
--- a/input/tests/views.py
+++ b/input/tests/views.py
@@ -1,3 +1,5 @@
+import random
+
from django.shortcuts import resolve_url
from django.test import TestCase
@@ -6,6 +8,7 @@ from input.utils.testing import create_superuser, login, request
from input.views import TYPES
PATHS = {TYPES[path].code: path for path in TYPES}
+CODES = list(PATHS)
class AnonymousViewTestCase(TestCase):
@@ -18,6 +21,12 @@ class AnonymousViewTestCase(TestCase):
def test_extern(self):
request(self, 'extern')
+ def test_extern_post(self):
+ code = random.choice(CODES)
+ url = self.helper_url(code)
+
+ request(self, 'extern', expected_url=url, data={'url': url})
+
@classmethod
def get_step_data(cls, choice, **data):
return {
diff --git a/input/views.py b/input/views.py
index 10424b1..8035507 100755
--- a/input/views.py
+++ b/input/views.py
@@ -1,9 +1,11 @@
+from dataclasses import dataclass
from smtplib import SMTPException
-from typing import NamedTuple
+from typing import Optional
-from django.shortcuts import render
+from django.shortcuts import render, redirect
from django.http import HttpResponse, Http404
from django.utils.functional import cached_property
+from django.utils.http import url_has_allowed_host_and_scheme
from django.utils.safestring import mark_safe
from django.core.mail import BadHeaderError
from django.conf import settings
@@ -67,35 +69,49 @@ HELP_TEXTS = {
},
}
-
-class ApplicationType(NamedTuple):
+@dataclass
+class ApplicationType:
code: str
path: str
form_class: type[BaseApplicationForm]
+ link: str
+ label: Optional[str] = None
+ help_texts: Optional[str] = None
+
+ def __post_init__(self):
+ if self.label is None:
+ self.label = TYPE_CHOICES[self.code]
+
+ if self.help_texts is None:
+ self.help_texts = HELP_TEXTS.get(self.code)
@property
- def label(self):
- return TYPE_CHOICES[self.code]
-
- @property
- def help_texts(self):
- return HELP_TEXTS.get(self.code)
+ def url(self):
+ return f'https://de.wikipedia.org/wiki/Wikipedia:F%C3%B6rderung/{self.link}'
PROJECT_FUNDING = [
- ApplicationType(TYPE_PROJ, 'projektfoerderung', ProjectForm),
+ ApplicationType(TYPE_PROJ, 'projektfoerderung', ProjectForm, 'Projektplanung',
+ 'Projektförderung mit einer Gesamtsumme unter 1.000,— EUR'),
+ ApplicationType(TYPE_PROJ, 'projektfoerderung-ab-1000', ProjectForm, 'Projektplanung',
+ 'Projektförderung mit einer Gesamtsumme ab 1.000,— EUR'),
]
SERVICES = [
- ApplicationType(TYPE_BIB, 'bibliotheksstipendium', LibraryForm),
- ApplicationType(TYPE_ELIT, 'eliteraturstipendium', ELiteratureForm),
- ApplicationType(TYPE_MAIL, 'email', EmailForm),
- ApplicationType(TYPE_IFG, 'ifg', IFGForm),
- ApplicationType(TYPE_LIT, 'literaturstipendium', LiteratureForm),
- ApplicationType(TYPE_LIST, 'mailingliste', ListForm),
- ApplicationType(TYPE_TRAV, 'reisekosten', TravelForm),
- ApplicationType(TYPE_SOFT, 'softwarestipendium', SoftwareForm),
- ApplicationType(TYPE_VIS, 'visitenkarten', BusinessCardForm),
+ ApplicationType(TYPE_BIB, 'bibliotheksstipendium', LibraryForm, 'Zugang_zu_Fachliteratur#Bibliotheksstipendium'),
+ ApplicationType(TYPE_ELIT, 'eliteraturstipendium', ELiteratureForm, 'Zugang_zu_Fachliteratur#eLiteraturstipendium'),
+ ApplicationType(TYPE_MAIL, 'email', EmailForm, 'E-Mail-Adressen_und_Visitenkarten#E-Mail-Adressen'),
+ ApplicationType(TYPE_IFG, 'ifg', IFGForm, 'Geb%C3%BChrenerstattungen_f%C3%BCr_Beh%C3%B6rdenanfragen'),
+ ApplicationType(TYPE_LIT, 'literaturstipendium', LiteratureForm, 'Zugang_zu_Fachliteratur#Literaturstipendium'),
+ ApplicationType(TYPE_LIST, 'mailingliste', ListForm, 'E-Mail-Adressen_und_Visitenkarten#Mailinglisten'),
+ ApplicationType(TYPE_TRAV, 'reisekosten', TravelForm, 'Reisekostenerstattungen'),
+ ApplicationType(TYPE_SOFT, 'softwarestipendium', SoftwareForm, 'Software-Stipendien'),
+ ApplicationType(TYPE_VIS, 'visitenkarten', BusinessCardForm, 'E-Mail-Adressen_und_Visitenkarten#Visitenkarten'),
+]
+
+BLOCKS = [
+ ('Projektförderung', PROJECT_FUNDING),
+ ('Serviceleistungen', SERVICES),
]
TYPES = {info.path: info for info in PROJECT_FUNDING + SERVICES}
@@ -147,7 +163,14 @@ def index(request):
class ApplicationStartView(TemplateView):
template_name = 'input/forms/extern.html'
- extra_context = {'services': SERVICES}
+ extra_context = {'blocks': BLOCKS}
+
+ def post(self, request, *args, **kwargs):
+ if url := request.POST.get('url'):
+ if url_has_allowed_host_and_scheme(url, None):
+ return redirect(url)
+
+ return self.get(request, *args, **kwargs)
class ProjectFundingInfoView(TemplateView):
|