From ec062df5f45b6fe623ca94669c3817fbb6149c97 Mon Sep 17 00:00:00 2001 From: Oliver Zander Date: Wed, 15 Oct 2025 12:20:47 +0200 Subject: [PATCH] fixed and unified project funding & services --- input/templates/input/forms/extern.html | 6 +++--- input/tests/views.py | 6 +++--- input/urls.py | 4 ++-- input/views.py | 18 +++++++++++------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/input/templates/input/forms/extern.html b/input/templates/input/forms/extern.html index 7ccc443..0e99a75 100755 --- a/input/templates/input/forms/extern.html +++ b/input/templates/input/forms/extern.html @@ -10,18 +10,18 @@ Projektförderung Serviceleistungen diff --git a/input/tests/views.py b/input/tests/views.py index e6a8d01..14d721e 100644 --- a/input/tests/views.py +++ b/input/tests/views.py @@ -5,6 +5,8 @@ from input.models import Library from input.utils.testing import create_superuser, login, request from input.views import TYPES +PATHS = {TYPES[path].code: path for path in TYPES} + class AnonymousViewTestCase(TestCase): @@ -28,9 +30,7 @@ class AnonymousViewTestCase(TestCase): @staticmethod def helper_url(code): - info = next(info for info in TYPES if info.code == code) - - return resolve_url('extern', type=info.path) + return resolve_url('extern', type=PATHS[code]) def helper_extern_base(self, choice, text, data): url = self.helper_url(choice) diff --git a/input/urls.py b/input/urls.py index da24dc8..cc431c6 100755 --- a/input/urls.py +++ b/input/urls.py @@ -9,7 +9,7 @@ from .views import ( deny, ApplicationView, ApplicationStartView, - ProjectInfoView, + ProjectFundingInfoView, ) urlpatterns = [ @@ -20,7 +20,7 @@ urlpatterns = [ path('deny//', deny, name='deny'), path('extern/', include([ path('', ApplicationStartView.as_view(), name='extern'), - path('info/projektfoerderung-ab-1000/', ProjectInfoView.as_view(), name='info-foerderprojekt-ab-1000'), + path('projektfoerderung-ab-1000/', ProjectFundingInfoView.as_view(), name='projektfoerderung-ab-1000'), path('/', ApplicationView.as_view(), name='extern'), ])), # JavaScript translations for date widgets, etc. diff --git a/input/views.py b/input/views.py index f9d0328..2ee5a66 100755 --- a/input/views.py +++ b/input/views.py @@ -80,7 +80,11 @@ class ApplicationType(NamedTuple): return HELP_TEXTS.get(self.code) -TYPES = [ +PROJECT_FUNDING = [ + ApplicationType(TYPE_PROJ_LT_1000, 'projektfoerderung-unter-1000', ProjectRequestForm), +] + +SERVICES = [ ApplicationType(TYPE_BIB, 'bibliotheksstipendium', LibraryForm), ApplicationType(TYPE_ELIT, 'eliteraturstipendium', ELiteratureForm), ApplicationType(TYPE_MAIL, 'email', EmailForm), @@ -90,9 +94,10 @@ TYPES = [ ApplicationType(TYPE_TRAV, 'reisekosten', TravelForm), ApplicationType(TYPE_SOFT, 'softwarestipendium', SoftwareForm), ApplicationType(TYPE_VIS, 'visitenkarten', BusinessCardForm), - ApplicationType(TYPE_PROJ_LT_1000, 'projektfoerderung-unter-1000', ProjectRequestForm), ] +TYPES = {info.path: info for info in PROJECT_FUNDING + SERVICES} + def auth_deny(choice, pk, auth): if choice not in MODELS: @@ -140,10 +145,10 @@ def index(request): class ApplicationStartView(TemplateView): template_name = 'input/forms/extern.html' - extra_context = {'types': TYPES} + extra_context = {'services': SERVICES} -class ProjectInfoView(TemplateView): +class ProjectFundingInfoView(TemplateView): template_name = 'input/info_project_funding_gt_1000.html' @@ -166,9 +171,8 @@ class ApplicationView(FormView): def type_info(self) -> ApplicationType: type_path = self.kwargs['type'] - for type_info in TYPES: - if type_path == type_info.path: - return type_info + if type_info := TYPES.get(type_path): + return type_info raise Http404(f'"{type_path}" existiert nicht.')