forked from beba/foerderbarometer
WM-11: switch service list to radios with info links
This commit is contained in:
parent
4d7058f460
commit
864eb031ed
|
|
@ -6,6 +6,12 @@
|
|||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.wm-table.start {
|
||||
td, th {
|
||||
border: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.col-request {
|
||||
width: 40%;
|
||||
}
|
||||
|
|
@ -2,31 +2,38 @@
|
|||
|
||||
{% load i18n %}
|
||||
{% block content %}
|
||||
<div class="page-centered">
|
||||
<table class="wm-table">
|
||||
<tr>
|
||||
<th class="col-request">Was möchtest du beantragen?</th>
|
||||
<td>
|
||||
<strong>Projektförderung</strong>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{% url 'extern' type='projektfoerderung' %}">Projektförderung</a>
|
||||
mit einer Gesamtsumme unter 1.000,— EUR
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'projektfoerderung-ab-1000' %}">Projektförderung</a>
|
||||
mit einer Gesamtsumme ab 1.000,— EUR
|
||||
</li>
|
||||
</ul>
|
||||
<form class="page-centered" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
<strong>Serviceleistungen</strong>
|
||||
<ul>
|
||||
{% for info in services %}
|
||||
<li><a href="{% url 'extern' type=info.path %}">{{ info.label|striptags }}</a></li>
|
||||
<table class="wm-table start">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="col-request">Was möchtest du beantragen?</th>
|
||||
<td>
|
||||
{% for title, services in blocks %}
|
||||
<strong>{{ title }}</strong>
|
||||
<ul>
|
||||
{% for service in services %}
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="url" value="{% url 'extern' type=service.path %}" />
|
||||
<span>{{ service.label|striptags }}</span>
|
||||
</label>
|
||||
<span>(<a href="{{ service.url }}" target="_blank">mehr erfahren</a>)</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<button type="submit">Beantragen</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue