From 487deb11abdfca9f3ccb1e09d017311624de2034 Mon Sep 17 00:00:00 2001 From: OnaMosimege Date: Thu, 25 Apr 2024 08:19:08 +0200 Subject: [PATCH] Change return of context current page from view to single variable, to fix aria-current page in template --- app/app/views.py | 6 +++--- app/general/admin.py | 2 +- app/templates/base.html | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/app/views.py b/app/app/views.py index 13c44a52..7a360b19 100644 --- a/app/app/views.py +++ b/app/app/views.py @@ -13,7 +13,7 @@ def health(request): def home(request): template = "app/home.html" - context = {"home_page": "active"} + context = {"current_page": "home"} return render(request, template_name=template, context=context) @@ -22,14 +22,14 @@ def institutions(request): template = "app/institutions.html" institutions = Institution.objects.all().order_by("name").values() - context = {"institutions_page": "active", "institutions": institutions} + context = {"current_page": "institutions", "institutions": institutions} return render(request, template_name=template, context=context) def search(request): template = "app/search.html" - context = {"search_page": "active"} + context = {"current_page": "search"} return render(request, template_name=template, context=context) diff --git a/app/general/admin.py b/app/general/admin.py index fe219969..c5b4619c 100644 --- a/app/general/admin.py +++ b/app/general/admin.py @@ -18,7 +18,7 @@ class Meta: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - + # If the instance has a mime_type, the field should be disabled if not self.instance.mime_type: self.fields["mime_type"].widget = HiddenInput() diff --git a/app/templates/base.html b/app/templates/base.html index 6057eebd..f0e1f9c1 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -27,13 +27,22 @@