From 864eb031ed239c1efeb8e0324d0a9b6e7c9b011b Mon Sep 17 00:00:00 2001 From: Oliver Zander Date: Fri, 7 Nov 2025 14:48:54 +0100 Subject: [PATCH] WM-11: switch service list to radios with info links --- input/static/css/forms.css | 8 ++- input/templates/input/forms/extern.html | 55 ++++++++++++--------- input/tests/views.py | 9 ++++ input/views.py | 65 +++++++++++++++++-------- 4 files changed, 91 insertions(+), 46 deletions(-) diff --git a/input/static/css/forms.css b/input/static/css/forms.css index 548ddc7..59e759e 100644 --- a/input/static/css/forms.css +++ b/input/static/css/forms.css @@ -6,6 +6,12 @@ margin: 0 auto; } +.wm-table.start { + td, th { + border: 0; + } +} + .col-request { width: 40%; -} \ No newline at end of file +} diff --git a/input/templates/input/forms/extern.html b/input/templates/input/forms/extern.html index 5a6ec9c..46c079d 100755 --- a/input/templates/input/forms/extern.html +++ b/input/templates/input/forms/extern.html @@ -2,31 +2,38 @@ {% load i18n %} {% block content %} -
- - - -
Was möchtest du beantragen? - Projektförderung - +
+ {% csrf_token %} - Serviceleistungen -
    - {% for info in services %} -
  • {{ info.label|striptags }}
  • + + + + + - + + + + + + + +
    Was möchtest du beantragen? + {% for title, services in blocks %} + {{ title }} +
      + {% for service in services %} +
    • + + (mehr erfahren) +
    • + {% endfor %} +
    {% endfor %} - -
    + +
    - + {% 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):