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;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wm-table.start {
|
||||||
|
td, th {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.col-request {
|
.col-request {
|
||||||
width: 40%;
|
width: 40%;
|
||||||
}
|
}
|
||||||
|
|
@ -2,31 +2,38 @@
|
||||||
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="page-centered">
|
<form class="page-centered" method="post">
|
||||||
<table class="wm-table">
|
{% csrf_token %}
|
||||||
|
|
||||||
|
<table class="wm-table start">
|
||||||
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="col-request">Was möchtest du beantragen?</th>
|
<th class="col-request">Was möchtest du beantragen?</th>
|
||||||
<td>
|
<td>
|
||||||
<strong>Projektförderung</strong>
|
{% for title, services in blocks %}
|
||||||
|
<strong>{{ title }}</strong>
|
||||||
<ul>
|
<ul>
|
||||||
|
{% for service in services %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'extern' type='projektfoerderung' %}">Projektförderung</a>
|
<label>
|
||||||
mit einer Gesamtsumme unter 1.000,— EUR
|
<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>
|
</li>
|
||||||
<li>
|
|
||||||
<a href="{% url 'projektfoerderung-ab-1000' %}">Projektförderung</a>
|
|
||||||
mit einer Gesamtsumme ab 1.000,— EUR
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<strong>Serviceleistungen</strong>
|
|
||||||
<ul>
|
|
||||||
{% for info in services %}
|
|
||||||
<li><a href="{% url 'extern' type=info.path %}">{{ info.label|striptags }}</a></li>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<button type="submit">Beantragen</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import random
|
||||||
|
|
||||||
from django.shortcuts import resolve_url
|
from django.shortcuts import resolve_url
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
|
|
@ -6,6 +8,7 @@ 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}
|
PATHS = {TYPES[path].code: path for path in TYPES}
|
||||||
|
CODES = list(PATHS)
|
||||||
|
|
||||||
|
|
||||||
class AnonymousViewTestCase(TestCase):
|
class AnonymousViewTestCase(TestCase):
|
||||||
|
|
@ -18,6 +21,12 @@ class AnonymousViewTestCase(TestCase):
|
||||||
def test_extern(self):
|
def test_extern(self):
|
||||||
request(self, 'extern')
|
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
|
@classmethod
|
||||||
def get_step_data(cls, choice, **data):
|
def get_step_data(cls, choice, **data):
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
|
from dataclasses import dataclass
|
||||||
from smtplib import SMTPException
|
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.http import HttpResponse, Http404
|
||||||
from django.utils.functional import cached_property
|
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.utils.safestring import mark_safe
|
||||||
from django.core.mail import BadHeaderError
|
from django.core.mail import BadHeaderError
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
@ -67,35 +69,49 @@ HELP_TEXTS = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class ApplicationType(NamedTuple):
|
class ApplicationType:
|
||||||
code: str
|
code: str
|
||||||
path: str
|
path: str
|
||||||
form_class: type[BaseApplicationForm]
|
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
|
@property
|
||||||
def label(self):
|
def url(self):
|
||||||
return TYPE_CHOICES[self.code]
|
return f'https://de.wikipedia.org/wiki/Wikipedia:F%C3%B6rderung/{self.link}'
|
||||||
|
|
||||||
@property
|
|
||||||
def help_texts(self):
|
|
||||||
return HELP_TEXTS.get(self.code)
|
|
||||||
|
|
||||||
|
|
||||||
PROJECT_FUNDING = [
|
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 = [
|
SERVICES = [
|
||||||
ApplicationType(TYPE_BIB, 'bibliotheksstipendium', LibraryForm),
|
ApplicationType(TYPE_BIB, 'bibliotheksstipendium', LibraryForm, 'Zugang_zu_Fachliteratur#Bibliotheksstipendium'),
|
||||||
ApplicationType(TYPE_ELIT, 'eliteraturstipendium', ELiteratureForm),
|
ApplicationType(TYPE_ELIT, 'eliteraturstipendium', ELiteratureForm, 'Zugang_zu_Fachliteratur#eLiteraturstipendium'),
|
||||||
ApplicationType(TYPE_MAIL, 'email', EmailForm),
|
ApplicationType(TYPE_MAIL, 'email', EmailForm, 'E-Mail-Adressen_und_Visitenkarten#E-Mail-Adressen'),
|
||||||
ApplicationType(TYPE_IFG, 'ifg', IFGForm),
|
ApplicationType(TYPE_IFG, 'ifg', IFGForm, 'Geb%C3%BChrenerstattungen_f%C3%BCr_Beh%C3%B6rdenanfragen'),
|
||||||
ApplicationType(TYPE_LIT, 'literaturstipendium', LiteratureForm),
|
ApplicationType(TYPE_LIT, 'literaturstipendium', LiteratureForm, 'Zugang_zu_Fachliteratur#Literaturstipendium'),
|
||||||
ApplicationType(TYPE_LIST, 'mailingliste', ListForm),
|
ApplicationType(TYPE_LIST, 'mailingliste', ListForm, 'E-Mail-Adressen_und_Visitenkarten#Mailinglisten'),
|
||||||
ApplicationType(TYPE_TRAV, 'reisekosten', TravelForm),
|
ApplicationType(TYPE_TRAV, 'reisekosten', TravelForm, 'Reisekostenerstattungen'),
|
||||||
ApplicationType(TYPE_SOFT, 'softwarestipendium', SoftwareForm),
|
ApplicationType(TYPE_SOFT, 'softwarestipendium', SoftwareForm, 'Software-Stipendien'),
|
||||||
ApplicationType(TYPE_VIS, 'visitenkarten', BusinessCardForm),
|
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}
|
TYPES = {info.path: info for info in PROJECT_FUNDING + SERVICES}
|
||||||
|
|
@ -147,7 +163,14 @@ def index(request):
|
||||||
|
|
||||||
class ApplicationStartView(TemplateView):
|
class ApplicationStartView(TemplateView):
|
||||||
template_name = 'input/forms/extern.html'
|
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):
|
class ProjectFundingInfoView(TemplateView):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue