change all string literals to single quotes

This commit is contained in:
Roman 2025-09-01 13:24:59 +02:00
parent 8ba54bdca9
commit 238c674517
3 changed files with 73 additions and 73 deletions

View File

@ -132,14 +132,14 @@ class BaseApplicationForm(FdbForm):
- Ensures consistency across all application types.
"""
realname = CharField(
label="Realname",
label='Realname',
required=True,
help_text="Bitte gib deinen Vor- und Nachnamen ein."
help_text='Bitte gib deinen Vor- und Nachnamen ein.'
)
email = EmailField(
label="E-Mail-Adresse",
label='E-Mail-Adresse',
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,
label=format_html(

View File

@ -11,9 +11,9 @@ from .views import (
urlpatterns = [
path('', index, name='index'),
path(
"extern/",
TemplateView.as_view(template_name="input/forms/extern.html"),
name="extern",
'extern/',
TemplateView.as_view(template_name='input/forms/extern.html'),
name='extern',
),
path('saved', done, name='done'),
path('export', export, name='export'),
@ -23,18 +23,18 @@ urlpatterns = [
# Static info page for project funding above 1000 EUR
path('extern/info/projektfoerderung-ab-1000/',
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
path("extern/reisekosten/", TravelApplicationView.as_view(), name="reisekosten"),
path("extern/ifg/", IFGApplicationView.as_view(), name="ifg"),
path("extern/email/", EmailApplicationView.as_view(), name="email"),
path("extern/literaturstipendium/", LiteratureApplicationView.as_view(), name="literatur"),
path("extern/mailingliste/", ListApplicationView.as_view(), name="mailingliste"),
path("extern/visitenkarten/", BusinessCardApplicationView.as_view(), name="visitenkarten"),
path("extern/bibliotheksstipendium/", LibraryApplicationView.as_view(), name="bibliotheksstipendium"),
path("extern/eliteraturstipendium/", ELiteratureApplicationView.as_view(), name="eliteraturstipendium"),
path("extern/softwarestipendium/", SoftwareApplicationView.as_view(), name="softwarestipendium"),
path('extern/reisekosten/', TravelApplicationView.as_view(), name='reisekosten'),
path('extern/ifg/', IFGApplicationView.as_view(), name='ifg'),
path('extern/email/', EmailApplicationView.as_view(), name='email'),
path('extern/literaturstipendium/', LiteratureApplicationView.as_view(), name='literatur'),
path('extern/mailingliste/', ListApplicationView.as_view(), name='mailingliste'),
path('extern/visitenkarten/', BusinessCardApplicationView.as_view(), name='visitenkarten'),
path('extern/bibliotheksstipendium/', LibraryApplicationView.as_view(), name='bibliotheksstipendium'),
path('extern/eliteraturstipendium/', ELiteratureApplicationView.as_view(), name='eliteraturstipendium'),
path('extern/softwarestipendium/', SoftwareApplicationView.as_view(), name='softwarestipendium'),
# JavaScript translations for date widgets, etc.
path('jsi18n/', JavaScriptCatalog.as_view(), name='jsi18n'),

View File

@ -31,25 +31,25 @@ LIBRARY_FORMS = {
}
HELP_TEXTS = {
"IFG": {
"notes": (
"Bitte gib an, wie die gewonnenen Informationen den<br>"
"Wikimedia-Projekten zugute kommen sollen."
'IFG': {
'notes': (
'Bitte gib an, wie die gewonnenen Informationen den<br>'
'Wikimedia-Projekten zugute kommen sollen.'
)
},
"MAIL": {
"domain": (
"Mit welcher Domain, bzw. für welches Wikimedia-Projekt,<br>"
"möchtest du eine Mailadresse beantragen?"
'MAIL': {
'domain': (
'Mit welcher Domain, bzw. für welches Wikimedia-Projekt,<br>'
'möchtest du eine Mailadresse beantragen?'
)
},
"LIT": {
"notes": "Bitte gib an, wofür du die Literatur verwenden möchtest."
'LIT': {
'notes': 'Bitte gib an, wofür du die Literatur verwenden möchtest.'
},
"LIST": {
"domain": (
"Mit welcher Domain, bzw. für welches Wikimedia-Projekt,<br>"
"möchtest du eine Mailingliste beantragen?"
'LIST': {
'domain': (
'Mit welcher Domain, bzw. für welches Wikimedia-Projekt,<br>'
'möchtest du eine Mailingliste beantragen?'
)
},
}
@ -76,7 +76,7 @@ def authorize(request, choice, pk):
if ret := auth_deny(choice, pk, True):
return ret
else:
return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}")
return HttpResponse(f'AUTHORIZED! choice: {choice}, pk: {pk}')
@login_required
@ -87,12 +87,12 @@ def deny(request, choice, pk):
if ret := auth_deny(choice, pk, False):
return ret
else:
return HttpResponse(f"DENIED! choice: {choice}, pk: {pk}")
return HttpResponse(f'DENIED! choice: {choice}, pk: {pk}')
def done(request):
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):
@ -112,13 +112,13 @@ class BaseApplicationView(FormView):
- Sends notification mail to the internal IF address.
- Returns the "done" response after successful processing.
"""
template_name = "input/forms/form_generic.html"
type_code: str = ""
template_name = 'input/forms/form_generic.html'
type_code: str = ''
def get_context_data(self, **kwargs):
"""Add the human-readable type string (from TYPE_CHOICES) to the template context."""
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
def get_form(self, form_class=None):
@ -144,113 +144,113 @@ class BaseApplicationView(FormView):
# Collect cleaned data and mark the current type
data = form.cleaned_data.copy()
data["choice"] = self.type_code
data['choice'] = self.type_code
# Special rule for literature applications
if self.type_code == "LIT" and data.get("selfbuy") == "TRUE":
data["selfbuy_give_data"] = "False"
if self.type_code == 'LIT' and data.get('selfbuy') == 'TRUE':
data['selfbuy_give_data'] = 'False'
# Save model instance
modell = form.save(commit=False)
# Username from session if present
user = self.request.session.get("user")
user = self.request.session.get('user')
if user:
modell.username = user.get("username")
modell.username = user.get('username')
# Copy common fields if provided by the form
if "realname" in data:
modell.realname = data["realname"]
if "email" in data:
modell.email = data["email"]
if 'realname' in data:
modell.realname = data['realname']
if 'email' in data:
modell.email = data['email']
# 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
# Literature-specific extra field
if self.type_code == "LIT" and "selfbuy_give_data" in data:
modell.selfbuy_give_data = data["selfbuy_give_data"]
if self.type_code == 'LIT' and 'selfbuy_give_data' in data:
modell.selfbuy_give_data = data['selfbuy_give_data']
modell.save()
if hasattr(form, "save_m2m"):
if hasattr(form, 'save_m2m'):
form.save_m2m()
# Prepare minimal mail context and send mails
data["pk"] = modell.pk
data["url_prefix"] = settings.EMAIL_URL_PREFIX
data["typestring"] = TYPE_CHOICES.get(self.type_code, self.type_code)
context = {"data": data}
data['pk'] = modell.pk
data['url_prefix'] = settings.EMAIL_URL_PREFIX
data['typestring'] = TYPE_CHOICES.get(self.type_code, self.type_code)
context = {'data': data}
try:
# Mail to applicant
txt1 = get_template("input/ifg_volunteer_mail.txt").render(context)
html1 = get_template("input/ifg_volunteer_mail.html").render(context)
txt1 = get_template('input/ifg_volunteer_mail.txt').render(context)
html1 = get_template('input/ifg_volunteer_mail.html').render(context)
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()
# Mail to IF
txt2 = get_template("input/if_mail.txt").render(context)
html2 = get_template("input/if_mail.html").render(context)
txt2 = get_template('input/if_mail.txt').render(context)
html2 = get_template('input/if_mail.html').render(context)
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()
except BadHeaderError:
modell.delete()
return HttpResponse("Invalid header found. Data not saved!")
return HttpResponse('Invalid header found. Data not saved!')
except SMTPException:
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)
class TravelApplicationView(BaseApplicationView):
form_class = TravelForm
type_code = "TRAV"
type_code = 'TRAV'
class LibraryApplicationView(BaseApplicationView):
form_class = LibraryForm
type_code = "BIB"
type_code = 'BIB'
class ELiteratureApplicationView(BaseApplicationView):
form_class = ELiteratureForm
type_code = "ELIT"
type_code = 'ELIT'
class SoftwareApplicationView(BaseApplicationView):
form_class = SoftwareForm
type_code = "SOFT"
type_code = 'SOFT'
class IFGApplicationView(BaseApplicationView):
form_class = IFGForm
type_code = "IFG"
type_code = 'IFG'
class EmailApplicationView(BaseApplicationView):
form_class = EmailForm
type_code = "MAIL"
type_code = 'MAIL'
class LiteratureApplicationView(BaseApplicationView):
form_class = LiteratureForm
type_code = "LIT"
type_code = 'LIT'
class ListApplicationView(BaseApplicationView):
form_class = ListForm
type_code = "LIST"
type_code = 'LIST'
class BusinessCardApplicationView(BaseApplicationView):
form_class = BusinessCardForm
type_code = "VIS"
type_code = 'VIS'