-
Tor-Einar Skog authoredTor-Einar Skog authored
views.py 1012 B
from django.shortcuts import render, redirect
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)
# 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:
if model_id == model["model_id"]:
context = {"model_id": model_id}
return render(request, 'spatial/gridmap.html', context)
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)