-
Tor-Einar Skog authoredTor-Einar Skog authored
views.py 2.18 KiB
from django.shortcuts import render
from django.conf import settings
from datetime import datetime
from dateutil.relativedelta import relativedelta
from forecasts.models import Model
# Create your views here.
def index(request):
#forecast_configurations.sort(key=lambda x: x.date_start, reverse=False)
context = {
}
return render(request, 'cerealblotchmodels/index.html', context)
def barleynetblotchform(request):
# We must calculate the maximum sowing date, which is 14 days before
# system date
max_sowing_date = datetime.now() + relativedelta(months = settings.SYSTEM_TIME_OFFSET_MONTHS) - relativedelta(days = 14)
vips_organization_id = settings.VIPS_ORGANIZATION_ID
if request.GET.get("organizationId") != None:
vips_organization_id = request.GET.get("organizationId")
context = {
"vips_organization_id": vips_organization_id,
"form_id" : "barleyNetBlotchForm",
"max_sowing_date" : max_sowing_date
}
return render(request, 'cerealblotchmodels/barleynetblotchform.html', context)
def wheatleafblotchform(request):
# We must calculate the maximum sowing date, which is 14 days before
# system date
#max_sowing_date = datetime.now() + relativedelta(months = settings.SYSTEM_TIME_OFFSET_MONTHS) - relativedelta(days = 14)
vips_organization_id = settings.VIPS_ORGANIZATION_ID
if request.GET.get("organizationId") != None:
vips_organization_id = request.GET.get("organizationId")
wheat_type = request.GET.get("wheat_type", "spring")
context = {
"vips_organization_id": vips_organization_id,
"form_id" : "wheatLeafBlotchForm",
"wheat_type" : wheat_type
#"max_sowing_date" : max_sowing_date
}
return render(request, 'cerealblotchmodels/wheatleafblotchform.html', context)
def septoriahumidityform(request):
model = Model.get_model("SEPTORIAHU")
context = {
"form_id" : "septoriaHumidityForm",
"model": model
}
return render(request, 'cerealblotchmodels/septoriahumiditymodelform.html', context)