Skip to content
Snippets Groups Projects
Commit 81d21a9b authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Handle empty list of available models

parent 3ed1ac21
Branches
No related tags found
No related merge requests found
......@@ -28,14 +28,19 @@
<h2>VIPS grid map</h2>
<p>
View results from VIPS models run on gridded weather data.
{% if available_grid_models|length > 0 %}
<ul>
{% for model in available_grid_models %}
{% for model in available_grid_models %}
<li><a href="gridmap/{{model.model_id}}">{{ model.model_name }}</a></li>
{% endfor %}
{% endfor %}
</ul>
{% else %}
<p><em>No GRID models available</em></p>
{% endif %}
</p>
<h2>Other resources</h2>
<ul>
<li><a href="test/PSILARTEMP">Carrot rust fly map [TEST]</a></li>
</ul>
{% endblock %}
......@@ -4,7 +4,9 @@ from django.conf import settings
def index(request):
context = {"available_grid_models": settings.AVAILABLE_GRID_MODELS}
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):
......@@ -12,9 +14,12 @@ def psilartemp(request):
return render(request, 'spatial/psilartemp.html', context)
def gridmap(request, model_id):
for model in settings.AVAILABLE_GRID_MODELS:
if model_id == model["model_id"]:
context = {"model_id": model_id}
return render(request, 'spatial/gridmap.html', context)
try:
for model in settings.AVAILABLE_GRID_MODELS:
if model_id == model["model_id"]:
context = {"model_id": model_id}
return render(request, 'spatial/gridmap.html', context)
except AttributeError:
pass
return index(request)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment