diff --git a/ACMAS/app/ACMAS_Web/templates/_base.html b/ACMAS/app/ACMAS_Web/templates/_base.html index 42ea394..193d1b5 100644 --- a/ACMAS/app/ACMAS_Web/templates/_base.html +++ b/ACMAS/app/ACMAS_Web/templates/_base.html @@ -1,7 +1,6 @@ {% load static %} {% load component_tags %} -{% with mode="light" %} @@ -153,6 +152,7 @@
  • Login
  • {% endblock %} {% endif %} +
  • Change theme (currently {{ mode }})
  • @@ -175,5 +175,4 @@ {% endblock body %} -{% endwith %} diff --git a/ACMAS/app/ACMAS_Web/views.py b/ACMAS/app/ACMAS_Web/views.py index a0e7029..cad653a 100644 --- a/ACMAS/app/ACMAS_Web/views.py +++ b/ACMAS/app/ACMAS_Web/views.py @@ -19,6 +19,11 @@ def generateContext(request): + os.getenv("GOOGLE_ANALYTICS_ID", default=""), "CANONICAL_PATH": request.build_absolute_uri(request.path), } + if 'mode' in request.COOKIES: + context['mode'] = request.COOKIES.get('mode') + else: + request.COOKIES['mode'] = 'light' + context['mode'] = "light" return context @@ -234,5 +239,12 @@ def profile(request): def darkmode(request): + if 'mode' in request.COOKIES: + mode = request.COOKIES.get('mode') + if mode == 'dark': + request.COOKIES['mode'] = 'light' + else: + request.COOKIES['mode'] = 'dark' context = generateContext(request) - return render(request, "darkmode.html", context) \ No newline at end of file + + return render(request, "index.html", context) \ No newline at end of file