Add toggle for turning the application form on an off

This commit is contained in:
Yannik Rödel 2023-06-29 15:03:52 +02:00
parent 38c95df9d9
commit 04b43c6660
6 changed files with 25 additions and 3 deletions

View file

@ -35,6 +35,7 @@ RUN apk add --no-cache lighttpd && \
COPY --from=build /build/dist /www/
COPY cgi-bin /cgi-bin/
COPY sites/${SITE}/httpd.conf /httpd.conf
COPY sites/${SITE}/_data/config.json /config.json
# Patch the lighttpd config file. These placeholders expect a Nix derivation
# path, so the Python binary used in the end is at @python@/bin/python. The

View file

@ -10,6 +10,7 @@ import mimetypes
import re
import os
import secrets
import json
from typing import Any, Optional, overload
import itsdangerous
@ -25,6 +26,13 @@ def fail(status: str, reason: str) -> None:
exit(0)
try:
with open("/config.json", "r") as config_file:
CONFIG = json.load(config_file)
except IOError:
CONFIG = {}
HONEYPOT_FIELD_NAME = "addressline1"
SITE_DIRECTORY = os.environ.get("SITE_DIRECTORY", "")
@ -57,6 +65,8 @@ else:
signed_csrf_token = serializer.dumps(csrf_token)
form_disabled = request_uri.startswith("/anmelden")
if request_uri.startswith("/computer-beantragen/privat") and CONFIG.get("applicationsClosed"):
form_disabled = True
match os.environ.get("REQUEST_METHOD", "").upper():
case "GET":

View file

@ -0,0 +1,3 @@
{
"applicationsClosed": true
}

View file

@ -17,6 +17,9 @@ Auf dieser Seite kannst du einen Antrag einreichen, um einen Computer von uns zu
erhalten. Bitte teile uns zunächst deine Kontaktdaten mit.
<form method="post" action="/computer-beantragen/privat" enctype="multipart/form-data">
{% if config.applicationsClosed %}
<fieldset disabled="disabled" class="blanked-out-form">
{% endif %}
<label class="form-input">
<span>Name:</span>
<input type="text" name="contactname" required placeholder="Vorname Nachname" />
@ -37,7 +40,6 @@ Welches Gerät würdest du gerne von uns erhalten?
<div class="form-input">
<label for="hardware-bare-laptop">Laptop ohne Akku</label>
</div>
<fieldset disabled="disabled" class="blanked-out-form">
<input type="radio" id="hardware-laptop" class="radio-input" name="hardware" required disabled value="Laptop" />
<div class="form-input">
<label for="hardware-laptop">
@ -45,7 +47,6 @@ Welches Gerät würdest du gerne von uns erhalten?
<em>Aktuell nicht verfügbar | Voraussichtlich erst wieder ab Juni</em>
</label>
</div>
</fieldset>
Damit du einen Computer von uns erhalten kannst, benötigen wir von dir einen
Nachweis der Bedürftigkeit. Das ist eines dieser Papiere, die von offiziellen
@ -116,4 +117,8 @@ installiert. Es gibt ein Programm zum Schreiben
<div class="form-submit">
<input type="submit" value="Abschicken" />
</div>
{% if config.applicationsClosed %}
</fieldset>
{% endif %}
</form>

View file

@ -31,7 +31,9 @@ Wir schaffen Zugang in die digitale Welt
<a href="/computer-beantragen">
<div>
<h3>Computer bekommen</h3>
<em class="inline-callout">Aktuell keine Notebooks verfügbar. Nur Desktop Computer und Notebooks ohne Akku.</em>
{% if config.applicationsClosed %}
<em class="inline-callout">Aktuell nur eingeschränkt verfügbar.</em>
{% endif %}
</div>
<svg class="action-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 219 175">
<linearGradient id="emphasis-gradient-sun" class="emphasis-gradient">

View file

@ -0,0 +1 @@
{}