def index(request):
location=0
if request.method == 'POST':
existsLocalization = Localizacion.objects.filter(lugar_id = request.POST['lugar'] )
if existsLocalization.count()==0:
location= Localizacion.objects.create(lugar_id=request.POST['lugar'] , lugar_ds=request.POST['lugar'] )
localizacion_id=location.id
if location!=0:
coordenadas = BuscarCoordenadas(location.lugar_ds)
try:
coordenadasl = Coordenadas.objects.filter(local_ref = location.id)
coordenadasl.delete()
except:
pass
location.coordenadas_set.create(latitud=coordenadas.lat, longitud=coordenadas.lon, descripcion=coordenadas.ds)
opcion= Option.objects.create(option_code=location.id ,option_type="lugares", option_text=coordenadas.ds )
opcionesTemperatura = Option.objects.filter(option_type = "temperaturas")
opcionesEcoRiverFlow = Option.objects.filter(option_type = "ecological river flow")
opcionesMaximumFlow = Option.objects.filter(option_type = "Maximun flow")
opcionesReservoirCapacity = Option.objects.filter(option_type = "Reservoir capacity")
opcionesLugares = Option.objects.filter(option_type = "lugares")
opcionesNetFalling = Option.objects.filter(option_type = "net falling height or head")
opcionesNumberOfTurbines = Option.objects.filter(option_type = "Number of turbines")
opcionesTypeOfTurbine = Option.objects.filter(option_type = "Type of turbines")
anios = Option.objects.filter(option_type = "year")
context = {
'opcionesTemperatura': opcionesTemperatura,
'opcionesEcoRiverFlow': opcionesEcoRiverFlow,
'opcionesMaximumFlow': opcionesMaximumFlow,
'opcionesReservoirCapacity': opcionesReservoirCapacity,
'opcionesNetFalling': opcionesNetFalling,
'opcionesNumberOfTurbines': opcionesNumberOfTurbines,
'opcionesTypeOfTurbine': opcionesTypeOfTurbine,
'opcionesLugares': opcionesLugares,
'anios': anios,
}
return render(request, 'options/index.html', context)
评论列表
文章目录