From 00cc1f43fefc9287611dd4464f43ef3980d32d8b Mon Sep 17 00:00:00 2001
From: Tor-Einar Skog <tor-einar.skog@nibio.no>
Date: Wed, 1 Nov 2023 15:17:38 +0100
Subject: [PATCH] Add i18n to grid model titles

---
 spatial/templates/spatial/index.html |  2 +-
 spatial/views.py                     | 13 +++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/spatial/templates/spatial/index.html b/spatial/templates/spatial/index.html
index b8f9dec5..652a0b4c 100644
--- a/spatial/templates/spatial/index.html
+++ b/spatial/templates/spatial/index.html
@@ -31,7 +31,7 @@
     {% if available_grid_models|length > 0 %}
     <ul>
         {% for model in available_grid_models %}
-        <li><a href="gridmap/{{model.model_id}}/">{{ get_text_i18n model.model_name }}</a></li>
+        <li><a href="gridmap/{{model.model_id}}/">{% get_text_i18n model.model_name %}</a></li>
         {% endfor %}
     </ul>
     {% else %}
diff --git a/spatial/views.py b/spatial/views.py
index dd733a0b..9b04a6b8 100644
--- a/spatial/views.py
+++ b/spatial/views.py
@@ -3,16 +3,14 @@ from django.http import Http404
 from django.conf import settings
 
 
+# Fallback view - only displaying info for user to move on
 def index(request):
     context = {
         "available_grid_models": settings.AVAILABLE_GRID_MODELS if hasattr(settings, "AVAILABLE_GRID_MODELS") else []
         }
     return render(request, 'spatial/index.html', context)
 
-def psilartemp(request):
-    context = {}
-    return render(request, 'spatial/psilartemp.html', context)
-
+# The main view. Expects a valid model_id, otherwise it defaults to index
 def gridmap(request, model_id=None):
     try:
         for model in settings.AVAILABLE_GRID_MODELS:
@@ -22,4 +20,11 @@ def gridmap(request, model_id=None):
     except AttributeError:
         pass
     return redirect("../")
+
+
+# TO BE REMOVED when the PSILARTEMP model has been harmonized with the VIPS gridded model format
+def psilartemp(request):
+    context = {}
+    return render(request, 'spatial/psilartemp.html', context)
+
     
-- 
GitLab