fixed and unified project funding & services

This commit is contained in:
Oliver Zander 2025-10-15 12:20:47 +02:00
parent c27e4c5183
commit ec062df5f4
4 changed files with 19 additions and 15 deletions

View File

@ -10,18 +10,18 @@
<strong>Projektförderung</strong> <strong>Projektförderung</strong>
<ul> <ul>
<li> <li>
<a href="{% url 'projektfoerderung-unter-1000' %}">Projektförderung</a> <a href="{% url 'extern' type='projektfoerderung-unter-1000' %}">Projektförderung</a>
mit einer Gesamtsumme unter 1.000,— EUR mit einer Gesamtsumme unter 1.000,— EUR
</li> </li>
<li> <li>
<a href="{% url 'extern' type='projektfoerderung-unter-1000' %}">Projektförderung</a> <a href="{% url 'projektfoerderung-ab-1000' %}">Projektförderung</a>
mit einer Gesamtsumme ab 1.000,— EUR mit einer Gesamtsumme ab 1.000,— EUR
</li> </li>
</ul> </ul>
<strong>Serviceleistungen</strong> <strong>Serviceleistungen</strong>
<ul> <ul>
{% for info in types %} {% for info in services %}
<li><a href="{% url 'extern' type=info.path %}">{{ info.label|striptags }}</a></li> <li><a href="{% url 'extern' type=info.path %}">{{ info.label|striptags }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -5,6 +5,8 @@ from input.models import Library
from input.utils.testing import create_superuser, login, request from input.utils.testing import create_superuser, login, request
from input.views import TYPES from input.views import TYPES
PATHS = {TYPES[path].code: path for path in TYPES}
class AnonymousViewTestCase(TestCase): class AnonymousViewTestCase(TestCase):
@ -28,9 +30,7 @@ class AnonymousViewTestCase(TestCase):
@staticmethod @staticmethod
def helper_url(code): def helper_url(code):
info = next(info for info in TYPES if info.code == code) return resolve_url('extern', type=PATHS[code])
return resolve_url('extern', type=info.path)
def helper_extern_base(self, choice, text, data): def helper_extern_base(self, choice, text, data):
url = self.helper_url(choice) url = self.helper_url(choice)

View File

@ -9,7 +9,7 @@ from .views import (
deny, deny,
ApplicationView, ApplicationView,
ApplicationStartView, ApplicationStartView,
ProjectInfoView, ProjectFundingInfoView,
) )
urlpatterns = [ urlpatterns = [
@ -20,7 +20,7 @@ urlpatterns = [
path('deny/<str:choice>/<int:pk>', deny, name='deny'), path('deny/<str:choice>/<int:pk>', deny, name='deny'),
path('extern/', include([ path('extern/', include([
path('', ApplicationStartView.as_view(), name='extern'), 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('<slug:type>/', ApplicationView.as_view(), name='extern'), path('<slug:type>/', ApplicationView.as_view(), name='extern'),
])), ])),
# JavaScript translations for date widgets, etc. # JavaScript translations for date widgets, etc.

View File

@ -80,7 +80,11 @@ class ApplicationType(NamedTuple):
return HELP_TEXTS.get(self.code) 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_BIB, 'bibliotheksstipendium', LibraryForm),
ApplicationType(TYPE_ELIT, 'eliteraturstipendium', ELiteratureForm), ApplicationType(TYPE_ELIT, 'eliteraturstipendium', ELiteratureForm),
ApplicationType(TYPE_MAIL, 'email', EmailForm), ApplicationType(TYPE_MAIL, 'email', EmailForm),
@ -90,9 +94,10 @@ TYPES = [
ApplicationType(TYPE_TRAV, 'reisekosten', TravelForm), ApplicationType(TYPE_TRAV, 'reisekosten', TravelForm),
ApplicationType(TYPE_SOFT, 'softwarestipendium', SoftwareForm), ApplicationType(TYPE_SOFT, 'softwarestipendium', SoftwareForm),
ApplicationType(TYPE_VIS, 'visitenkarten', BusinessCardForm), 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): def auth_deny(choice, pk, auth):
if choice not in MODELS: if choice not in MODELS:
@ -140,10 +145,10 @@ def index(request):
class ApplicationStartView(TemplateView): class ApplicationStartView(TemplateView):
template_name = 'input/forms/extern.html' 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' template_name = 'input/info_project_funding_gt_1000.html'
@ -166,9 +171,8 @@ class ApplicationView(FormView):
def type_info(self) -> ApplicationType: def type_info(self) -> ApplicationType:
type_path = self.kwargs['type'] type_path = self.kwargs['type']
for type_info in TYPES: if type_info := TYPES.get(type_path):
if type_path == type_info.path: return type_info
return type_info
raise Http404(f'"{type_path}" existiert nicht.') raise Http404(f'"{type_path}" existiert nicht.')