forked from beba/foerderbarometer
Compare commits
No commits in common. "8abc051a59fb8f94d5e26aa06058fa7d6b32c2a0" and "35627d2764cd9cbc5d22cd65f8c1e2a708a25d71" have entirely different histories.
8abc051a59
...
35627d2764
|
|
@ -157,9 +157,6 @@ class BaseProjectAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
class Media:
|
class Media:
|
||||||
js = ('dropdown/js/otrs_link.js',)
|
js = ('dropdown/js/otrs_link.js',)
|
||||||
css = {
|
|
||||||
'all': ['css/full-width-related-labels.css'],
|
|
||||||
}
|
|
||||||
|
|
||||||
granted: bool
|
granted: bool
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ from django.forms import ModelForm
|
||||||
from django.forms.renderers import DjangoTemplates
|
from django.forms.renderers import DjangoTemplates
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import gettext_lazy as trans
|
|
||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
Project,
|
Project,
|
||||||
|
|
@ -264,6 +263,10 @@ class TermsForm(BaseApplicationForm):
|
||||||
class LiteratureForm(TermsForm):
|
class LiteratureForm(TermsForm):
|
||||||
terms_accepted_url = settings.NUTZUNGSBEDINGUNGEN_LITERATURSTIPENDIUM
|
terms_accepted_url = settings.NUTZUNGSBEDINGUNGEN_LITERATURSTIPENDIUM
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['selfbuy_give_data'].required = True
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Literature
|
model = Literature
|
||||||
fields = [
|
fields = [
|
||||||
|
|
@ -282,24 +285,6 @@ class LiteratureForm(TermsForm):
|
||||||
class Media:
|
class Media:
|
||||||
js = ('dropdown/js/literature.js',)
|
js = ('dropdown/js/literature.js',)
|
||||||
|
|
||||||
def clean(self):
|
|
||||||
cleaned_data = TermsForm.clean(self)
|
|
||||||
|
|
||||||
if self.errors:
|
|
||||||
return cleaned_data
|
|
||||||
|
|
||||||
if cleaned_data['selfbuy'] == 'TRUE':
|
|
||||||
cleaned_data['selfbuy_data'] = ''
|
|
||||||
cleaned_data['selfbuy_give_data'] = False
|
|
||||||
|
|
||||||
return cleaned_data
|
|
||||||
|
|
||||||
for field in 'selfbuy_data', 'selfbuy_give_data':
|
|
||||||
if not cleaned_data.get(field):
|
|
||||||
self.add_error(field, trans('This field is required.'))
|
|
||||||
|
|
||||||
return cleaned_data
|
|
||||||
|
|
||||||
|
|
||||||
ADULT_CHOICES = {
|
ADULT_CHOICES = {
|
||||||
'TRUE': mark_safe('Ich bin volljährig.'),
|
'TRUE': mark_safe('Ich bin volljährig.'),
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
.related-widget-wrapper div label {
|
|
||||||
width: auto;
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{% extends 'admin/change_form.html' %}
|
||||||
|
|
||||||
|
{% block extrastyle %}
|
||||||
|
{{ block.super }}
|
||||||
|
<style>
|
||||||
|
.related-widget-wrapper div label {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -1,26 +1,60 @@
|
||||||
<html lang="de">
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<p>Hallo Team Community-Konferenzen & Förderung,</p>
|
<p>Hallo Team Community-Konferenzen & Förderung,</p>
|
||||||
|
|
||||||
<p>es gibt eine neue Anfrage von {{ data.realname }}.</p>
|
<p>es gibt eine neue Anfrage von {{ data.realname }}.</p>
|
||||||
|
|
||||||
<p>{{ data.username|default:data.realname }} ({{ data.email }}) fragt an: {{ type_label }}</p>
|
<p>{{ data.username|default:data.realname }} ({{ data.email }}) fragt an: {{ data.type_label|striptags }}</p>
|
||||||
|
|
||||||
<p>
|
{% if data.choice in data.grant %}<br>
|
||||||
{% for label, value in form_data.items %}
|
Vorraussichtliche Kosten: {{data.cost}}<br>
|
||||||
{{ label }}: {{ value }} <br />
|
Anmerkungen: {{data.notes}} {% endif %} {% if data.choice in data.domain %}<br>
|
||||||
{% endfor %}
|
Domain: <a href="{{data.domain}}">{{data.domain}}</a><br>
|
||||||
|
Adressenbestandteil: {{data.address}} <br> {% endif %} {% if data.choice == 'BIB' %}
|
||||||
|
Bibliothek: {{data.library}}<br>
|
||||||
|
Dauer: {{data.duration}} <br> {% elif data.choice == 'ELIT' %}
|
||||||
|
Datenbank: {{data.library}}<br>
|
||||||
|
Dauer: {{data.duration}} <br> {% elif data.choice == 'SOFT' %}
|
||||||
|
Software: {{data.library}}<br>
|
||||||
|
Dauer: {{data.duration}} <br> {% elif data.choice == 'IFG'%}
|
||||||
|
Anfrage-URL: <a href="{{data.url}}">{{data.url}}</a> <br> {% elif data.choice == 'LIT'%}
|
||||||
|
Info zum Werk: {{data.info}}<br>
|
||||||
|
Bezugsquelle: {{data.source}} <br> {% elif data.choice == 'MAIL'%}
|
||||||
|
Adressenbestandteil frei gewählt: {{data.other}} <br> {% elif data.choice == 'VIS'%}
|
||||||
|
Wikimedia-Projekt: {{data.project}}<br>
|
||||||
|
Persönliche Daten: {{data.data}}<br>
|
||||||
|
Variante: {{data.variant}}<br>
|
||||||
|
Sendungsadrese: {{data.send_to}} <br> {% endif %}
|
||||||
|
|
||||||
|
<p>Zum Eintrag in der Förderdatenbank:
|
||||||
|
{% if data.choice == 'BIB' %}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/library/{{data.pk}}/change">{{data.url_prefix}}/admin/input/library/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'ELIT'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/library/{{data.pk}}/change">{{data.url_prefix}}/admin/input/library/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'LIT'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/literature/{{data.pk}}/change">{{data.url_prefix}}/admin/input/literature/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'MAIL'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/email/{{data.pk}}/change">{{data.url_prefix}}/admin/input/email/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'IFG'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/ifg/{{data.pk}}/change">{{data.url_prefix}}/admin/input/ifg/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'LIST'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/list/{{data.pk}}/change">{{data.url_prefix}}/admin/input/list/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'TRAV'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/travel/{{data.pk}}/change">{{data.url_prefix}}/admin/input/travel/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'SOFT'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/library/{{data.pk}}/change">{{data.url_prefix}}/admin/input/library/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'VIS'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/businesscard/{{data.pk}}/change">{{data.url_prefix}}/admin/input/businesscard/{{data.pk}}/change</a>
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>Zum Eintrag in der Förderdatenbank: <a href="{{ urls.admin }}">{{ urls.admin }}</a></p>
|
<p>Zum Genehmigen hier klicken:
|
||||||
|
<a href="{{data.url_prefix}}{% url 'authorize' data.choice data.pk %}">{{data.url_prefix}}{% url 'authorize' data.choice data.pk %}</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
{% if urls.authorize %}
|
<p>Zum Ablehnen hier klicken:
|
||||||
<p>Zum Genehmigen hier klicken: <a href="{{ urls.authorize }}">{{ urls.authorize }}</a></p>
|
<a href="{{data.url_prefix}}{% url 'deny' data.choice data.pk %}">{{data.url_prefix}}{% url 'deny' data.choice data.pk %}</a>
|
||||||
{% endif %}
|
</p>
|
||||||
|
|
||||||
{% if urls.deny %}
|
|
||||||
<p>Zum Ablehnen hier klicken: <a href="{{ urls.deny }}">{{ urls.deny }}</a></p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,52 @@
|
||||||
Hallo Team Community-Konferenzen & Förderung,
|
Hallo Team Communitys und Engagement,
|
||||||
|
|
||||||
es gibt eine neue Anfrage von {{ data.realname }}.
|
es gab einen neuen Antrag von {{data.realname}}.
|
||||||
|
|
||||||
{{ data.username|default:data.realname }} ({{ data.email }}) fragt an: {{ type_label }}
|
Der Nutzer mit dem Username {{data.username}} ({{data.email}}) fragt ein_e {{data.type_label|striptags}} an.
|
||||||
|
{% if data.choice in data.grant %}
|
||||||
|
Vorraussichtliche Kosten: {{data.cost}}
|
||||||
|
Anmerkungen: {{data.notes}} {% endif %} {% if data.choice in data.domain %}
|
||||||
|
Domain: {{data.domain}}
|
||||||
|
Adressenbestandteil: {{data.address}} {% endif %} {% if data.choice == 'BIB' %}
|
||||||
|
Bibliothek: {{data.library}}
|
||||||
|
Dauer: {{data.duration}} {% elif data.choice == 'ELIT' %}
|
||||||
|
Datenbank: {{data.library}}
|
||||||
|
Dauer: {{data.duration}} {% elif data.choice == 'SOFT' %}
|
||||||
|
Software: {{data.library}}
|
||||||
|
Dauer: {{data.duration}} {% elif data.choice == 'IFG'%}
|
||||||
|
Anfrage-URL: {{data.url}} {% elif data.choice == 'LIT'%}
|
||||||
|
Info zum Werk: {{data.info}}
|
||||||
|
Bezugsquelle: {{data.source}} {% elif data.choice == 'MAIL'%}
|
||||||
|
Adressenbestandteil frei gewählt: {{data.other}} {% elif data.choice == 'VIS'%}
|
||||||
|
Wikimedia-Projekt: {{data.project}}
|
||||||
|
Persönliche Daten: {{data.data}}
|
||||||
|
Variante: {{data.variant}}
|
||||||
|
Sendungsadrese: {{data.send_to}} {% endif %}
|
||||||
|
|
||||||
{% for label, value in form_data.items %}{{ label }}: {{ value }}
|
Zum Eintrag in der Förderdatenbank:
|
||||||
{% endfor %}
|
{% if data.choice == 'BIB' %}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/library/{{data.pk}}/change">{{data.url_prefix}}/admin/input/library/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'ELIT'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/library/{{data.pk}}/change">{{data.url_prefix}}/admin/input/library/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'LIT'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/literature/{{data.pk}}/change">{{data.url_prefix}}/admin/input/literature/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'MAIL'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/email/{{data.pk}}/change">{{data.url_prefix}}/admin/input/email/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'IFG'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/ifg/{{data.pk}}/change">{{data.url_prefix}}/admin/input/ifg/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'LIST'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/list/{{data.pk}}/change">{{data.url_prefix}}/admin/input/list/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'TRAV'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/travel/{{data.pk}}/change">{{data.url_prefix}}/admin/input/travel/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'SOFT'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/library/{{data.pk}}/change">{{data.url_prefix}}/admin/input/library/{{data.pk}}/change</a>
|
||||||
|
{% elif data.choice == 'VIS'%}
|
||||||
|
<a href="{{data.url_prefix}}/admin/input/businesscard/{{data.pk}}/change">{{data.url_prefix}}/admin/input/businesscard/{{data.pk}}/change</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
Zum Eintrag in der Förderdatenbank: {{ urls.admin }}
|
|
||||||
{% if urls.authorize %}Zum Genehmigen hier klicken: {{ urls.authorize }}{% endif %}
|
Zum Genehmigen hier klicken: {{data.url_prefix}}{% url 'authorize' data.choice data.pk %}
|
||||||
{% if urls.deny %}Zum Ablehnen hier klicken: {{ urls.deny }}{% endif %}
|
|
||||||
|
Zu Ablehnen hier klicken: {{data.url_prefix}}{% url 'deny' data.choice data.pk %}
|
||||||
|
|
||||||
|
Stets zu Diensten, Deine Förderdatenbank
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,29 @@
|
||||||
<html lang="de">
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<p>Hallo {{ applicant_name }},</p>
|
<p>Hallo {{ data.username|default:data.realname }},</p>
|
||||||
|
|
||||||
<p>vielen Dank für deine Anfrage ({{ type_label }}), die bei uns eingegangen ist.</p>
|
<p>vielen Dank für deine Anfrage ({{ data.type_label|striptags }}), die bei uns eingegangen ist.</p>
|
||||||
|
|
||||||
Dies ist eine automatisch generierte E-Mail. Im Folgenden findest du deine Formulareingaben nochmals zu deiner Übersicht:<br>
|
Dies ist eine automatisch generierte E-Mail. Im Folgenden findest du deine Formulareingaben nochmals zu deiner Übersicht:<br>
|
||||||
|
{% if data.choice in data.grant %}<br>
|
||||||
{% for label, value in form_data.items %}
|
Vorraussichtliche Kosten: {{data.cost}}<br>
|
||||||
{{ label }}: {{ value }} <br />
|
Anmerkungen: {{data.notes}} {% endif %} {% if data.choice in data.domain %}<br>
|
||||||
{% endfor %}
|
Domain: <a href="{{data.domain}}">{{data.domain}}</a><br>
|
||||||
|
Adressenbestandteil: {{data.address}} {% endif %} {% if data.choice == 'BIB' %}<br>
|
||||||
|
Bibliothek: {{data.library}}<br>
|
||||||
|
Dauer: {{data.duration}} {% elif data.choice == 'ELIT' %}<br>
|
||||||
|
Datenbank: {{data.library}}<br>
|
||||||
|
Dauer: {{data.duration}} {% elif data.choice == 'SOFT' %}<br>
|
||||||
|
Software: {{data.library}}<br>
|
||||||
|
Dauer: {{data.duration}} {% elif data.choice == 'IFG'%}<br>
|
||||||
|
Anfrage-URL: <a href="{{data.url}}">{{data.url}}</a> {% elif data.choice == 'LIT'%}<br>
|
||||||
|
Info zum Werk: {{data.info}}<br>
|
||||||
|
Bezugsquelle: {{data.source}} {% elif data.choice == 'MAIL'%}<br>
|
||||||
|
Adressenbestandteil frei gewählt: {{data.other}} {% elif data.choice == 'VIS'%}<br>
|
||||||
|
Wikimedia-Projekt: {{data.project}}<br>
|
||||||
|
Persönliche Daten: {{data.data}}<br>
|
||||||
|
Variante: {{data.variant}}<br>
|
||||||
|
Sendungsadrese: {{data.send_to}} {% endif %}<br>
|
||||||
|
|
||||||
<p>Das Team Community-Konferenzen & Förderung wird sich um deine Anfrage kümmern und sich in den nächsten Tagen bei dir melden. Wenn du Fragen hast, wende dich gern jederzeit an <a href="mailto:community@wikimedia.de">community@wikimedia.de</a>.</p>
|
<p>Das Team Community-Konferenzen & Förderung wird sich um deine Anfrage kümmern und sich in den nächsten Tagen bei dir melden. Wenn du Fragen hast, wende dich gern jederzeit an <a href="mailto:community@wikimedia.de">community@wikimedia.de</a>.</p>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,29 @@
|
||||||
Hallo {{ applicant_name }},
|
Hallo {{data.realname}},
|
||||||
|
|
||||||
vielen Dank für deine Anfrage ({{type_label}}), die bei uns eingegangen ist.
|
wir haben Deine Anfrage ({{data.type_label|striptags}}) erhalten.
|
||||||
|
{% if data.choice in data.grant %}
|
||||||
|
Vorraussichtliche Kosten: {{data.cost}}
|
||||||
|
Anmerkungen: {{data.notes}} {% endif %} {% if data.choice in data.domain %}
|
||||||
|
Domain: {{data.domain}}
|
||||||
|
Adressenbestandteil: {{data.address}} {% endif %} {% if data.choice == 'BIB' %}
|
||||||
|
Bibliothek: {{data.library}}
|
||||||
|
Dauer: {{data.duration}} {% elif data.choice == 'ELIT' %}
|
||||||
|
Datenbank: {{data.library}}
|
||||||
|
Dauer: {{data.duration}} {% elif data.choice == 'SOFT' %}
|
||||||
|
Software: {{data.library}}
|
||||||
|
Dauer: {{data.duration}} {% elif data.choice == 'IFG'%}
|
||||||
|
Anfrage-URL: {{data.url}} {% elif data.choice == 'LIT'%}
|
||||||
|
Info zum Werk: {{data.info}}
|
||||||
|
Bezugsquelle: {{data.source}} {% elif data.choice == 'MAIL'%}
|
||||||
|
Adressenbestandteil frei gewählt: {{data.other}} {% elif data.choice == 'VIS'%}
|
||||||
|
Wikimedia-Projekt: {{data.project}}
|
||||||
|
Persönliche Daten: {{data.data}}
|
||||||
|
Variante: {{data.variant}}
|
||||||
|
Sendungsadrese: {{data.send_to}} {% endif %}
|
||||||
|
|
||||||
{% for label, value in form_data.items %}{{ label }}: {{ value }}
|
Das Team Comunitys und Engagement wird sich um die Bearbeitung deiner Anfrage kümmern
|
||||||
{% endfor %}
|
und sich in den nächsten Tagen bei dir melden. Solltest du Rückfragen haben,
|
||||||
|
wende dich gern an community@wikimedia.de.
|
||||||
|
|
||||||
Das Team Community-Konferenzen & Förderung wird sich um deine Anfrage kümmern und sich in den nächsten Tagen bei dir melden. Wenn du Fragen hast, wende dich gern jederzeit an community@wikimedia.de.
|
Viele Grüße, dein freundliches aber komplett unmenschliches automatisches
|
||||||
|
Formularbeantwortungssystem.
|
||||||
--
|
|
||||||
|
|
||||||
Wikimedia Deutschland e. V. | Tempelhofer Ufer 23–24 | 10963 Berlin
|
|
||||||
Zentrale: +49 30 5771162-0
|
|
||||||
https://wikimedia.de
|
|
||||||
|
|
||||||
Unsere Vision ist eine Welt, in der alle Menschen am Wissen der Menschheit teilhaben, es nutzen und mehren können. Helfen Sie uns dabei!
|
|
||||||
https://spenden.wikimedia.de
|
|
||||||
|
|
||||||
Wikimedia Deutschland – Gesellschaft zur Förderung Freien Wissens e. V. Eingetragen im Vereinsregister des Amtsgerichts Charlottenburg, VR 23855 B. Als gemeinnützig anerkannt durch das Finanzamt für Körperschaften I Berlin, Steuernummer 27/029/42207. Geschäftsführende Vorständin: Franziska Heine.
|
|
||||||
|
|
||||||
Datenschutzerklärung:
|
|
||||||
Soweit Sie uns personenbezogene Daten mitteilen, verarbeiten wir diese Daten gemäß unserer Datenschutzerklärung (https://www.wikimedia.de/datenschutz/).
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,13 @@
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from django.forms import model_to_dict
|
|
||||||
from django.shortcuts import resolve_url
|
from django.shortcuts import resolve_url
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from foerderbarometer.constants import *
|
from input.models import Library, TYPE_PROJ
|
||||||
from input.models import Library, ProjectCategory, WikimediaProject
|
|
||||||
from input.utils.testing import create_superuser, login, request
|
from input.utils.testing import create_superuser, login, request
|
||||||
from input.views import PROJECT_FUNDING, TYPES, ApplicationView
|
from input.views import TYPES
|
||||||
|
|
||||||
PATHS = {TYPES[path].code: path for path in TYPES}
|
PATHS = {TYPES[path].code: path for path in TYPES}
|
||||||
PATHS[TYPE_PROJ] = PROJECT_FUNDING[0].path
|
|
||||||
CODES = list(PATHS)
|
CODES = list(PATHS)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,9 +27,6 @@ class AnonymousViewTestCase(TestCase):
|
||||||
|
|
||||||
request(self, 'extern', expected_url=url, data={'url': url})
|
request(self, 'extern', expected_url=url, data={'url': url})
|
||||||
|
|
||||||
def test_extern_invalid_url(self):
|
|
||||||
request(self, 'extern', data={'url': 'https://domain.not/allowed/to/be/redirected/'})
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_step_data(cls, choice, **data):
|
def get_step_data(cls, choice, **data):
|
||||||
return {
|
return {
|
||||||
|
|
@ -65,15 +59,15 @@ class AnonymousViewTestCase(TestCase):
|
||||||
|
|
||||||
def test_extern_types(self):
|
def test_extern_types(self):
|
||||||
types = [
|
types = [
|
||||||
(TYPE_BIB, 'Bibliotheksausweis'),
|
('BIB', 'Bibliotheksausweis'),
|
||||||
(TYPE_ELIT, 'Online-Ressource'),
|
('ELIT', 'Online-Ressource'),
|
||||||
(TYPE_MAIL, 'Mailadresse beantragen'),
|
('MAIL', 'Mailadresse beantragen'),
|
||||||
(TYPE_IFG, 'gewonnenen Informationen'),
|
('IFG', 'gewonnenen Informationen'),
|
||||||
(TYPE_LIT, 'Literatur verwenden'),
|
('LIT', 'Literatur verwenden'),
|
||||||
(TYPE_LIST, 'Mailingliste beantragen'),
|
('LIST', 'Mailingliste beantragen'),
|
||||||
(TYPE_TRAV, 'Transportmittel'),
|
('TRAV', 'Transportmittel'),
|
||||||
(TYPE_SOFT, 'Lizenz'),
|
('SOFT', 'Lizenz'),
|
||||||
(TYPE_VIS, 'DIN 5008'),
|
('VIS', 'DIN 5008'),
|
||||||
(TYPE_PROJ, 'Projektförderung'),
|
(TYPE_PROJ, 'Projektförderung'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -85,7 +79,7 @@ class AnonymousViewTestCase(TestCase):
|
||||||
self.assertContains(response, text)
|
self.assertContains(response, text)
|
||||||
|
|
||||||
def test_extern_travel(self):
|
def test_extern_travel(self):
|
||||||
self.helper_extern(TYPE_TRAV, 'Transportmittel', {
|
self.helper_extern('TRAV', 'Transportmittel', {
|
||||||
'project_name': 'Test',
|
'project_name': 'Test',
|
||||||
'transport': 'BAHN',
|
'transport': 'BAHN',
|
||||||
'travelcost': 10,
|
'travelcost': 10,
|
||||||
|
|
@ -96,27 +90,27 @@ class AnonymousViewTestCase(TestCase):
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_extern_lit(self):
|
def test_extern_lit(self):
|
||||||
self.helper_extern(TYPE_LIT, 'Literatur verwenden', {
|
self.helper_extern('LIT', 'Literatur verwenden', {
|
||||||
'cost': 20,
|
'cost': 20,
|
||||||
'info': 'Test',
|
'info': 'Test',
|
||||||
'source': 'Test',
|
'source': 'Test',
|
||||||
'notes': '',
|
'notes': '',
|
||||||
'selfbuy': 'FALSE',
|
'selfbuy': 'TRUE',
|
||||||
'selfbuy_data': 'Test',
|
'selfbuy_data': 'NONE',
|
||||||
'selfbuy_give_data': True,
|
'selfbuy_give_data': True,
|
||||||
'check': True,
|
'check': True,
|
||||||
'terms_accepted': True,
|
'terms_accepted': True,
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_extern_lit_without_consent_fails(self):
|
def test_extern_lit_without_consent_fails(self):
|
||||||
response = self.helper_extern_base(TYPE_LIT, 'Literatur verwenden', {
|
response = self.helper_extern_base('LIT', 'Literatur verwenden', {
|
||||||
'cost': 20,
|
'cost': 20,
|
||||||
'info': 'Test',
|
'info': 'Test',
|
||||||
'source': 'Test',
|
'source': 'Test',
|
||||||
'notes': '',
|
'notes': '',
|
||||||
'selfbuy': 'TRUE',
|
'selfbuy': 'TRUE',
|
||||||
'selfbuy_data': '',
|
'selfbuy_data': 'NONE',
|
||||||
'selfbuy_give_data': False,
|
'selfbuy_give_data': True,
|
||||||
'check': False,
|
'check': False,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -130,32 +124,9 @@ class AnonymousViewTestCase(TestCase):
|
||||||
'notes': '',
|
'notes': '',
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_extern_proj(self):
|
|
||||||
category = ProjectCategory.objects.order_by('?').first()
|
|
||||||
wikimedia_project = WikimediaProject.objects.order_by('?').first()
|
|
||||||
|
|
||||||
self.helper_extern(TYPE_PROJ, 'Projektförderung', {
|
|
||||||
'name': 'Test',
|
|
||||||
'description': 'Test',
|
|
||||||
'categories': [category.id, 0],
|
|
||||||
'categories_other': 'Test',
|
|
||||||
'wikimedia_projects': [wikimedia_project.id, 0],
|
|
||||||
'wikimedia_projects_other': 'Test',
|
|
||||||
'start': '2025-01-01',
|
|
||||||
'end': '2025-01-02',
|
|
||||||
'participants_estimated': 1,
|
|
||||||
'cost': 20,
|
|
||||||
})
|
|
||||||
|
|
||||||
def test_extern_invalid_code(self):
|
def test_extern_invalid_code(self):
|
||||||
request(self, 'extern', args=['invalid'], status_code=404)
|
request(self, 'extern', args=['invalid'], status_code=404)
|
||||||
|
|
||||||
def test_unknown_name(self):
|
|
||||||
obj = Library(type=Library.TYPE)
|
|
||||||
data = model_to_dict(obj)
|
|
||||||
name = ApplicationView.get_recipient_name(obj, data)
|
|
||||||
|
|
||||||
self.assertEqual(name, 'Unbekannt')
|
|
||||||
|
|
||||||
|
|
||||||
class AuthenticatedViewTestCase(TestCase):
|
class AuthenticatedViewTestCase(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
import datetime
|
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from smtplib import SMTPException
|
from smtplib import SMTPException
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from urllib.parse import urljoin
|
|
||||||
|
|
||||||
from django.forms import ChoiceField, Field
|
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.http import HttpResponse, Http404
|
from django.http import HttpResponse, Http404
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.choices import flatten_choices
|
|
||||||
from django.utils.formats import date_format
|
|
||||||
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.http import url_has_allowed_host_and_scheme
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.text import get_text_list
|
|
||||||
from django.core.mail import BadHeaderError
|
from django.core.mail import BadHeaderError
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
@ -22,7 +14,6 @@ from django.views.generic import TemplateView
|
||||||
from django.views.generic.edit import FormView
|
from django.views.generic.edit import FormView
|
||||||
from django.utils.html import strip_tags
|
from django.utils.html import strip_tags
|
||||||
|
|
||||||
from input.utils.admin import admin_url_name
|
|
||||||
from input.utils.mail import build_email, collect_and_attach
|
from input.utils.mail import build_email, collect_and_attach
|
||||||
|
|
||||||
from .forms import (
|
from .forms import (
|
||||||
|
|
@ -52,8 +43,6 @@ from .models import (
|
||||||
TYPE_SOFT,
|
TYPE_SOFT,
|
||||||
TYPE_TRAV,
|
TYPE_TRAV,
|
||||||
TYPE_VIS,
|
TYPE_VIS,
|
||||||
Project,
|
|
||||||
ProductCategoryFormField,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
HELP_TEXTS = {
|
HELP_TEXTS = {
|
||||||
|
|
@ -87,13 +76,13 @@ class ApplicationType:
|
||||||
form_class: type[BaseApplicationForm]
|
form_class: type[BaseApplicationForm]
|
||||||
link: str
|
link: str
|
||||||
label: Optional[str] = None
|
label: Optional[str] = None
|
||||||
help_texts: Optional[dict] = None
|
help_texts: Optional[str] = None
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
if self.label is None:
|
if self.label is None:
|
||||||
self.label = TYPE_CHOICES[self.code]
|
self.label = TYPE_CHOICES[self.code]
|
||||||
|
|
||||||
if self.help_texts is None: # pragma: no branch
|
if self.help_texts is None:
|
||||||
self.help_texts = HELP_TEXTS.get(self.code)
|
self.help_texts = HELP_TEXTS.get(self.code)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -254,7 +243,14 @@ class ApplicationView(FormView):
|
||||||
|
|
||||||
def prepare_data(self, form):
|
def prepare_data(self, form):
|
||||||
# Collect cleaned data and mark the current type
|
# Collect cleaned data and mark the current type
|
||||||
return {**form.cleaned_data, 'choice': self.type_code}
|
|
||||||
|
data = {**form.cleaned_data, 'choice': self.type_code}
|
||||||
|
|
||||||
|
# Special rule for literature applications
|
||||||
|
if self.type_code == TYPE_LIT and data.get('selfbuy') == 'TRUE':
|
||||||
|
data['selfbuy_give_data'] = 'False'
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
def save_obj(self, form, data):
|
def save_obj(self, form, data):
|
||||||
# Save model instance
|
# Save model instance
|
||||||
|
|
@ -290,9 +286,19 @@ class ApplicationView(FormView):
|
||||||
def send_mail(self, obj, data):
|
def send_mail(self, obj, data):
|
||||||
# Prepare minimal mail context and send mails
|
# Prepare minimal mail context and send mails
|
||||||
|
|
||||||
context = self.get_email_context(obj, data)
|
type_label_html = self.type_info.label
|
||||||
|
type_label_plain = strip_tags(type_label_html)
|
||||||
|
|
||||||
|
data['pk'] = obj.pk
|
||||||
|
data['url_prefix'] = settings.EMAIL_URL_PREFIX
|
||||||
|
data['type_label'] = type_label_html
|
||||||
|
|
||||||
|
context = {'data': data}
|
||||||
|
|
||||||
|
applicant_name = self.get_recipient_name(obj, data)
|
||||||
applicant_subject = 'Deine Förderanfrage bei Wikimedia Deutschland'
|
applicant_subject = 'Deine Förderanfrage bei Wikimedia Deutschland'
|
||||||
staff_subject = 'Anfrage {type_label} von {applicant_name}'.format(**context)
|
|
||||||
|
staff_subject = f'Anfrage {type_label_plain} von {applicant_name}'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.send_email('applicant', 'ifg_volunteer_mail', applicant_subject, data['email'], context)
|
self.send_email('applicant', 'ifg_volunteer_mail', applicant_subject, data['email'], context)
|
||||||
|
|
@ -304,59 +310,6 @@ class ApplicationView(FormView):
|
||||||
obj.delete()
|
obj.delete()
|
||||||
return HttpResponse('Error in sending mails (probably wrong address?). Data not saved!')
|
return HttpResponse('Error in sending mails (probably wrong address?). Data not saved!')
|
||||||
|
|
||||||
def get_email_context(self, obj, data):
|
|
||||||
return {
|
|
||||||
'data': data,
|
|
||||||
'urls': self.get_urls(obj),
|
|
||||||
'form_data': self.get_form_data(obj, data),
|
|
||||||
'applicant_name': self.get_recipient_name(obj, data),
|
|
||||||
'type_label': self.sanitize_label(self.type_info.label),
|
|
||||||
}
|
|
||||||
|
|
||||||
def get_urls(self, obj, **urls):
|
|
||||||
urls['admin'] = self.get_absolute_url(admin_url_name(obj, 'change'), obj.id)
|
|
||||||
|
|
||||||
if isinstance(obj, Project):
|
|
||||||
urls['authorize'] = urls['deny'] = None
|
|
||||||
else:
|
|
||||||
urls['authorize'] = self.get_absolute_url('authorize', self.type_info.code, obj.id)
|
|
||||||
urls['deny'] = self.get_absolute_url('deny', self.type_info.code, obj.id)
|
|
||||||
|
|
||||||
return urls
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_absolute_url(view, *args):
|
|
||||||
return urljoin(settings.EMAIL_URL_PREFIX, reverse(view, args=args))
|
|
||||||
|
|
||||||
def get_form_data(self, obj, data):
|
|
||||||
return {
|
|
||||||
self.sanitize_label(field.label): self.format_value(field.field, field.initial)
|
|
||||||
for field in self.type_info.form_class(initial=data)
|
|
||||||
}
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def sanitize_label(label: str):
|
|
||||||
label = strip_tags(label)
|
|
||||||
words = str.split(label)
|
|
||||||
|
|
||||||
return ' '.join(words)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def format_value(field: Field, value):
|
|
||||||
if isinstance(field, ProductCategoryFormField):
|
|
||||||
value = get_text_list(value, 'und')
|
|
||||||
elif isinstance(field, ChoiceField):
|
|
||||||
choices = flatten_choices(field.choices)
|
|
||||||
value = dict(choices).get(value, value)
|
|
||||||
elif isinstance(value, bool):
|
|
||||||
value = '✓' if value else '✗'
|
|
||||||
elif isinstance(value, datetime.date):
|
|
||||||
value = date_format(value)
|
|
||||||
elif value in field.empty_values:
|
|
||||||
value = '–'
|
|
||||||
|
|
||||||
return value
|
|
||||||
|
|
||||||
def send_email(self, kind, template_name, subject, recipient, context, *, fail_silently=False):
|
def send_email(self, kind, template_name, subject, recipient, context, *, fail_silently=False):
|
||||||
email = build_email(template_name, context, subject, recipient)
|
email = build_email(template_name, context, subject, recipient)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue