diff --git a/Dockerfile b/Dockerfile index 77d4795..3ac03a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/cgi-bin/form.py b/cgi-bin/form.py index abfbf19..53d440c 100755 --- a/cgi-bin/form.py +++ b/cgi-bin/form.py @@ -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": diff --git a/sites/angestoepselt/_data/config.json b/sites/angestoepselt/_data/config.json new file mode 100644 index 0000000..87dcb20 --- /dev/null +++ b/sites/angestoepselt/_data/config.json @@ -0,0 +1,3 @@ +{ + "applicationsClosed": true +} \ No newline at end of file diff --git a/sites/angestoepselt/computer-beantragen/privat.md b/sites/angestoepselt/computer-beantragen/privat.md index aa89f62..32706dc 100644 --- a/sites/angestoepselt/computer-beantragen/privat.md +++ b/sites/angestoepselt/computer-beantragen/privat.md @@ -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.
diff --git a/sites/angestoepselt/index.md b/sites/angestoepselt/index.md index d6e6e0a..9bc3a94 100644 --- a/sites/angestoepselt/index.md +++ b/sites/angestoepselt/index.md @@ -31,7 +31,9 @@ Wir schaffen Zugang in die digitale Welt