forked from beba/foerderbarometer
change all string literals to single quotes
This commit is contained in:
parent
8ba54bdca9
commit
238c674517
|
|
@ -132,14 +132,14 @@ class BaseApplicationForm(FdbForm):
|
||||||
- Ensures consistency across all application types.
|
- Ensures consistency across all application types.
|
||||||
"""
|
"""
|
||||||
realname = CharField(
|
realname = CharField(
|
||||||
label="Realname",
|
label='Realname',
|
||||||
required=True,
|
required=True,
|
||||||
help_text="Bitte gib deinen Vor- und Nachnamen ein."
|
help_text='Bitte gib deinen Vor- und Nachnamen ein.'
|
||||||
)
|
)
|
||||||
email = EmailField(
|
email = EmailField(
|
||||||
label="E-Mail-Adresse",
|
label='E-Mail-Adresse',
|
||||||
required=True,
|
required=True,
|
||||||
help_text="Bitte gib deine E-Mail-Adresse ein, damit dich <br> Wikimedia Deutschland bei Rückfragen oder für <br> die Zusage kontaktieren kann."
|
help_text='Bitte gib deine E-Mail-Adresse ein, damit dich <br> Wikimedia Deutschland bei Rückfragen oder für <br> die Zusage kontaktieren kann.'
|
||||||
)
|
)
|
||||||
check = BooleanField(required=True,
|
check = BooleanField(required=True,
|
||||||
label=format_html(
|
label=format_html(
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ from .views import (
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', index, name='index'),
|
path('', index, name='index'),
|
||||||
path(
|
path(
|
||||||
"extern/",
|
'extern/',
|
||||||
TemplateView.as_view(template_name="input/forms/extern.html"),
|
TemplateView.as_view(template_name='input/forms/extern.html'),
|
||||||
name="extern",
|
name='extern',
|
||||||
),
|
),
|
||||||
path('saved', done, name='done'),
|
path('saved', done, name='done'),
|
||||||
path('export', export, name='export'),
|
path('export', export, name='export'),
|
||||||
|
|
@ -23,18 +23,18 @@ urlpatterns = [
|
||||||
# Static info page for project funding above 1000 EUR
|
# Static info page for project funding above 1000 EUR
|
||||||
path('extern/info/projektfoerderung-ab-1000/',
|
path('extern/info/projektfoerderung-ab-1000/',
|
||||||
TemplateView.as_view(template_name='input/info_project_funding_gt_1000.html'),
|
TemplateView.as_view(template_name='input/info_project_funding_gt_1000.html'),
|
||||||
name="info-foerderprojekt-ab-1000"),
|
name='info-foerderprojekt-ab-1000'),
|
||||||
|
|
||||||
# New single-page application views
|
# New single-page application views
|
||||||
path("extern/reisekosten/", TravelApplicationView.as_view(), name="reisekosten"),
|
path('extern/reisekosten/', TravelApplicationView.as_view(), name='reisekosten'),
|
||||||
path("extern/ifg/", IFGApplicationView.as_view(), name="ifg"),
|
path('extern/ifg/', IFGApplicationView.as_view(), name='ifg'),
|
||||||
path("extern/email/", EmailApplicationView.as_view(), name="email"),
|
path('extern/email/', EmailApplicationView.as_view(), name='email'),
|
||||||
path("extern/literaturstipendium/", LiteratureApplicationView.as_view(), name="literatur"),
|
path('extern/literaturstipendium/', LiteratureApplicationView.as_view(), name='literatur'),
|
||||||
path("extern/mailingliste/", ListApplicationView.as_view(), name="mailingliste"),
|
path('extern/mailingliste/', ListApplicationView.as_view(), name='mailingliste'),
|
||||||
path("extern/visitenkarten/", BusinessCardApplicationView.as_view(), name="visitenkarten"),
|
path('extern/visitenkarten/', BusinessCardApplicationView.as_view(), name='visitenkarten'),
|
||||||
path("extern/bibliotheksstipendium/", LibraryApplicationView.as_view(), name="bibliotheksstipendium"),
|
path('extern/bibliotheksstipendium/', LibraryApplicationView.as_view(), name='bibliotheksstipendium'),
|
||||||
path("extern/eliteraturstipendium/", ELiteratureApplicationView.as_view(), name="eliteraturstipendium"),
|
path('extern/eliteraturstipendium/', ELiteratureApplicationView.as_view(), name='eliteraturstipendium'),
|
||||||
path("extern/softwarestipendium/", SoftwareApplicationView.as_view(), name="softwarestipendium"),
|
path('extern/softwarestipendium/', SoftwareApplicationView.as_view(), name='softwarestipendium'),
|
||||||
|
|
||||||
# JavaScript translations for date widgets, etc.
|
# JavaScript translations for date widgets, etc.
|
||||||
path('jsi18n/', JavaScriptCatalog.as_view(), name='jsi18n'),
|
path('jsi18n/', JavaScriptCatalog.as_view(), name='jsi18n'),
|
||||||
|
|
|
||||||
112
input/views.py
112
input/views.py
|
|
@ -31,25 +31,25 @@ LIBRARY_FORMS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
HELP_TEXTS = {
|
HELP_TEXTS = {
|
||||||
"IFG": {
|
'IFG': {
|
||||||
"notes": (
|
'notes': (
|
||||||
"Bitte gib an, wie die gewonnenen Informationen den<br>"
|
'Bitte gib an, wie die gewonnenen Informationen den<br>'
|
||||||
"Wikimedia-Projekten zugute kommen sollen."
|
'Wikimedia-Projekten zugute kommen sollen.'
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
"MAIL": {
|
'MAIL': {
|
||||||
"domain": (
|
'domain': (
|
||||||
"Mit welcher Domain, bzw. für welches Wikimedia-Projekt,<br>"
|
'Mit welcher Domain, bzw. für welches Wikimedia-Projekt,<br>'
|
||||||
"möchtest du eine Mailadresse beantragen?"
|
'möchtest du eine Mailadresse beantragen?'
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
"LIT": {
|
'LIT': {
|
||||||
"notes": "Bitte gib an, wofür du die Literatur verwenden möchtest."
|
'notes': 'Bitte gib an, wofür du die Literatur verwenden möchtest.'
|
||||||
},
|
},
|
||||||
"LIST": {
|
'LIST': {
|
||||||
"domain": (
|
'domain': (
|
||||||
"Mit welcher Domain, bzw. für welches Wikimedia-Projekt,<br>"
|
'Mit welcher Domain, bzw. für welches Wikimedia-Projekt,<br>'
|
||||||
"möchtest du eine Mailingliste beantragen?"
|
'möchtest du eine Mailingliste beantragen?'
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +76,7 @@ def authorize(request, choice, pk):
|
||||||
if ret := auth_deny(choice, pk, True):
|
if ret := auth_deny(choice, pk, True):
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}")
|
return HttpResponse(f'AUTHORIZED! choice: {choice}, pk: {pk}')
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
@ -87,12 +87,12 @@ def deny(request, choice, pk):
|
||||||
if ret := auth_deny(choice, pk, False):
|
if ret := auth_deny(choice, pk, False):
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
return HttpResponse(f"DENIED! choice: {choice}, pk: {pk}")
|
return HttpResponse(f'DENIED! choice: {choice}, pk: {pk}')
|
||||||
|
|
||||||
|
|
||||||
def done(request):
|
def done(request):
|
||||||
return HttpResponse(
|
return HttpResponse(
|
||||||
"Deine Anfrage wurde gesendet. Du erhältst in Kürze eine E-Mail-Benachrichtigung mit deinen Angaben. Für alle Fragen kontaktiere bitte das Team Communitys und Engagement unter community@wikimedia.de.")
|
'Deine Anfrage wurde gesendet. Du erhältst in Kürze eine E-Mail-Benachrichtigung mit deinen Angaben. Für alle Fragen kontaktiere bitte das Team Communitys und Engagement unter community@wikimedia.de.')
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
|
|
@ -112,13 +112,13 @@ class BaseApplicationView(FormView):
|
||||||
- Sends notification mail to the internal IF address.
|
- Sends notification mail to the internal IF address.
|
||||||
- Returns the "done" response after successful processing.
|
- Returns the "done" response after successful processing.
|
||||||
"""
|
"""
|
||||||
template_name = "input/forms/form_generic.html"
|
template_name = 'input/forms/form_generic.html'
|
||||||
type_code: str = ""
|
type_code: str = ''
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
"""Add the human-readable type string (from TYPE_CHOICES) to the template context."""
|
"""Add the human-readable type string (from TYPE_CHOICES) to the template context."""
|
||||||
ctx = super().get_context_data(**kwargs)
|
ctx = super().get_context_data(**kwargs)
|
||||||
ctx["typestring"] = TYPE_CHOICES.get(self.type_code, self.type_code)
|
ctx['typestring'] = TYPE_CHOICES.get(self.type_code, self.type_code)
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
def get_form(self, form_class=None):
|
def get_form(self, form_class=None):
|
||||||
|
|
@ -144,113 +144,113 @@ class BaseApplicationView(FormView):
|
||||||
|
|
||||||
# Collect cleaned data and mark the current type
|
# Collect cleaned data and mark the current type
|
||||||
data = form.cleaned_data.copy()
|
data = form.cleaned_data.copy()
|
||||||
data["choice"] = self.type_code
|
data['choice'] = self.type_code
|
||||||
|
|
||||||
# Special rule for literature applications
|
# Special rule for literature applications
|
||||||
if self.type_code == "LIT" and data.get("selfbuy") == "TRUE":
|
if self.type_code == 'LIT' and data.get('selfbuy') == 'TRUE':
|
||||||
data["selfbuy_give_data"] = "False"
|
data['selfbuy_give_data'] = 'False'
|
||||||
|
|
||||||
# Save model instance
|
# Save model instance
|
||||||
modell = form.save(commit=False)
|
modell = form.save(commit=False)
|
||||||
|
|
||||||
# Username from session if present
|
# Username from session if present
|
||||||
user = self.request.session.get("user")
|
user = self.request.session.get('user')
|
||||||
if user:
|
if user:
|
||||||
modell.username = user.get("username")
|
modell.username = user.get('username')
|
||||||
|
|
||||||
# Copy common fields if provided by the form
|
# Copy common fields if provided by the form
|
||||||
if "realname" in data:
|
if 'realname' in data:
|
||||||
modell.realname = data["realname"]
|
modell.realname = data['realname']
|
||||||
if "email" in data:
|
if 'email' in data:
|
||||||
modell.email = data["email"]
|
modell.email = data['email']
|
||||||
|
|
||||||
# Set model.type for specific request types
|
# Set model.type for specific request types
|
||||||
if self.type_code in ("BIB", "ELIT", "SOFT"):
|
if self.type_code in ('BIB', 'ELIT', 'SOFT'):
|
||||||
modell.type = self.type_code
|
modell.type = self.type_code
|
||||||
|
|
||||||
# Literature-specific extra field
|
# Literature-specific extra field
|
||||||
if self.type_code == "LIT" and "selfbuy_give_data" in data:
|
if self.type_code == 'LIT' and 'selfbuy_give_data' in data:
|
||||||
modell.selfbuy_give_data = data["selfbuy_give_data"]
|
modell.selfbuy_give_data = data['selfbuy_give_data']
|
||||||
|
|
||||||
modell.save()
|
modell.save()
|
||||||
if hasattr(form, "save_m2m"):
|
if hasattr(form, 'save_m2m'):
|
||||||
form.save_m2m()
|
form.save_m2m()
|
||||||
|
|
||||||
# Prepare minimal mail context and send mails
|
# Prepare minimal mail context and send mails
|
||||||
data["pk"] = modell.pk
|
data['pk'] = modell.pk
|
||||||
data["url_prefix"] = settings.EMAIL_URL_PREFIX
|
data['url_prefix'] = settings.EMAIL_URL_PREFIX
|
||||||
data["typestring"] = TYPE_CHOICES.get(self.type_code, self.type_code)
|
data['typestring'] = TYPE_CHOICES.get(self.type_code, self.type_code)
|
||||||
context = {"data": data}
|
context = {'data': data}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Mail to applicant
|
# Mail to applicant
|
||||||
txt1 = get_template("input/ifg_volunteer_mail.txt").render(context)
|
txt1 = get_template('input/ifg_volunteer_mail.txt').render(context)
|
||||||
html1 = get_template("input/ifg_volunteer_mail.html").render(context)
|
html1 = get_template('input/ifg_volunteer_mail.html').render(context)
|
||||||
msg1 = EmailMultiAlternatives(
|
msg1 = EmailMultiAlternatives(
|
||||||
"Formular ausgefüllt", txt1, settings.IF_EMAIL, [data["email"]]
|
'Formular ausgefüllt', txt1, settings.IF_EMAIL, [data['email']]
|
||||||
)
|
)
|
||||||
msg1.attach_alternative(html1, "text/html")
|
msg1.attach_alternative(html1, 'text/html')
|
||||||
msg1.send()
|
msg1.send()
|
||||||
|
|
||||||
# Mail to IF
|
# Mail to IF
|
||||||
txt2 = get_template("input/if_mail.txt").render(context)
|
txt2 = get_template('input/if_mail.txt').render(context)
|
||||||
html2 = get_template("input/if_mail.html").render(context)
|
html2 = get_template('input/if_mail.html').render(context)
|
||||||
msg2 = EmailMultiAlternatives(
|
msg2 = EmailMultiAlternatives(
|
||||||
"Formular ausgefüllt", txt2, settings.IF_EMAIL, [settings.IF_EMAIL]
|
'Formular ausgefüllt', txt2, settings.IF_EMAIL, [settings.IF_EMAIL]
|
||||||
)
|
)
|
||||||
msg2.attach_alternative(html2, "text/html")
|
msg2.attach_alternative(html2, 'text/html')
|
||||||
msg2.send()
|
msg2.send()
|
||||||
|
|
||||||
except BadHeaderError:
|
except BadHeaderError:
|
||||||
modell.delete()
|
modell.delete()
|
||||||
return HttpResponse("Invalid header found. Data not saved!")
|
return HttpResponse('Invalid header found. Data not saved!')
|
||||||
except SMTPException:
|
except SMTPException:
|
||||||
modell.delete()
|
modell.delete()
|
||||||
return HttpResponse("Error in sending mails (probably wrong adress?). Data not saved!")
|
return HttpResponse('Error in sending mails (probably wrong adress?). Data not saved!')
|
||||||
|
|
||||||
return done(self.request)
|
return done(self.request)
|
||||||
|
|
||||||
|
|
||||||
class TravelApplicationView(BaseApplicationView):
|
class TravelApplicationView(BaseApplicationView):
|
||||||
form_class = TravelForm
|
form_class = TravelForm
|
||||||
type_code = "TRAV"
|
type_code = 'TRAV'
|
||||||
|
|
||||||
|
|
||||||
class LibraryApplicationView(BaseApplicationView):
|
class LibraryApplicationView(BaseApplicationView):
|
||||||
form_class = LibraryForm
|
form_class = LibraryForm
|
||||||
type_code = "BIB"
|
type_code = 'BIB'
|
||||||
|
|
||||||
|
|
||||||
class ELiteratureApplicationView(BaseApplicationView):
|
class ELiteratureApplicationView(BaseApplicationView):
|
||||||
form_class = ELiteratureForm
|
form_class = ELiteratureForm
|
||||||
type_code = "ELIT"
|
type_code = 'ELIT'
|
||||||
|
|
||||||
|
|
||||||
class SoftwareApplicationView(BaseApplicationView):
|
class SoftwareApplicationView(BaseApplicationView):
|
||||||
form_class = SoftwareForm
|
form_class = SoftwareForm
|
||||||
type_code = "SOFT"
|
type_code = 'SOFT'
|
||||||
|
|
||||||
|
|
||||||
class IFGApplicationView(BaseApplicationView):
|
class IFGApplicationView(BaseApplicationView):
|
||||||
form_class = IFGForm
|
form_class = IFGForm
|
||||||
type_code = "IFG"
|
type_code = 'IFG'
|
||||||
|
|
||||||
|
|
||||||
class EmailApplicationView(BaseApplicationView):
|
class EmailApplicationView(BaseApplicationView):
|
||||||
form_class = EmailForm
|
form_class = EmailForm
|
||||||
type_code = "MAIL"
|
type_code = 'MAIL'
|
||||||
|
|
||||||
|
|
||||||
class LiteratureApplicationView(BaseApplicationView):
|
class LiteratureApplicationView(BaseApplicationView):
|
||||||
form_class = LiteratureForm
|
form_class = LiteratureForm
|
||||||
type_code = "LIT"
|
type_code = 'LIT'
|
||||||
|
|
||||||
|
|
||||||
class ListApplicationView(BaseApplicationView):
|
class ListApplicationView(BaseApplicationView):
|
||||||
form_class = ListForm
|
form_class = ListForm
|
||||||
type_code = "LIST"
|
type_code = 'LIST'
|
||||||
|
|
||||||
|
|
||||||
class BusinessCardApplicationView(BaseApplicationView):
|
class BusinessCardApplicationView(BaseApplicationView):
|
||||||
form_class = BusinessCardForm
|
form_class = BusinessCardForm
|
||||||
type_code = "VIS"
|
type_code = 'VIS'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue