コード例 #1
0
ファイル: views.py プロジェクト: Cristian897/Django_Reserva
def add_reserva_view(request):
	info = "iniciado"
	if request.method =="POST":
		form = addReservaForm(request.POST,request.FILES)
		if form.is_valid():
			add = form.save(commit=False)
			add.status = True
			add.save()#Guardar informacion
			info = "Guardado satisfactoriamente"
			return HttpResponseRedirect('/reservas/%s'%add.id)
	else:	
		form = addReservaForm()
	ctx = {'form':form,'informacion':info}	
	return render_to_response('reserva/addReserva.html',ctx, context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: Cristian897/Django_Reserva
def edit_reserva_view(request, id_resv):
	info = "iniciado"
	resv = producto.objects.get(id=id_resv)
	if request.method == "POST":
		form = addReservaForm(request.POST,request.FILES,instance=resv)
		if form.is_valid():
			edit = form.save(commit=False)
			edit.status = True
			edit.save()#Guardar edicion de formulario
			info = "Correcto"
			return HttpResponseRedirect('/reservas/%s'%edit.id)
	else:	
		form = addReservaForm(instance=resv)
	ctx = {'form':form,'informacion':info}	
	return render_to_response('reserva/editReserva.html',ctx, context_instance=RequestContext(request))
コード例 #3
0
def add_reserva_view(request):
    info = "iniciado"
    if request.method == "POST":
        form = addReservaForm(request.POST, request.FILES)
        if form.is_valid():
            add = form.save(commit=False)
            add.status = True
            add.save()  #Guardar informacion
            info = "Guardado satisfactoriamente"
            return HttpResponseRedirect('/reservas/%s' % add.id)
    else:
        form = addReservaForm()
    ctx = {'form': form, 'informacion': info}
    return render_to_response('reserva/addReserva.html',
                              ctx,
                              context_instance=RequestContext(request))
コード例 #4
0
def edit_reserva_view(request, id_resv):
    info = "iniciado"
    resv = producto.objects.get(id=id_resv)
    if request.method == "POST":
        form = addReservaForm(request.POST, request.FILES, instance=resv)
        if form.is_valid():
            edit = form.save(commit=False)
            edit.status = True
            edit.save()  #Guardar edicion de formulario
            info = "Correcto"
            return HttpResponseRedirect('/reservas/%s' % edit.id)
    else:
        form = addReservaForm(instance=resv)
    ctx = {'form': form, 'informacion': info}
    return render_to_response('reserva/editReserva.html',
                              ctx,
                              context_instance=RequestContext(request))