Пример #1
0
def update_vehiculo(request, id):
    """Funcion para Actualizar un vehiculo """
    vehiculo = get_object_or_404(DetalleVehiculo, pk=id)
   
    
    data_form = {
    'sede': vehiculo.vehiculo.sede,
    'placa_antigua': vehiculo.vehiculo.placa_antigua,
    'nro_placa': vehiculo.vehiculo.nro_placa,
    'nro_tarjeta': vehiculo.vehiculo.nro_tarjeta,
    'propietario': vehiculo.propietario,
    'year_fabricacion': vehiculo.vehiculo.year_fabricacion,
    'categoria': vehiculo.vehiculo.categoria,
    'clase': vehiculo.vehiculo.clase,
    'marca':vehiculo.vehiculo.marca,
    'modelo': vehiculo.vehiculo.modelo,
    'asociacion': vehiculo.asociacion,
    'combustible': vehiculo.vehiculo.combustible,
    'carroceria': vehiculo.vehiculo.carroceria,
    'ejes': vehiculo.vehiculo.ejes,
    'color': vehiculo.vehiculo.color,
    'motor': vehiculo.vehiculo.motor,
    'serie': vehiculo.vehiculo.serie,
    'cilindros': vehiculo.vehiculo.cilindros,
    'ruedas': vehiculo.vehiculo.ruedas,
    'pasajeros': vehiculo.vehiculo.pasajeros,
    'asientos': vehiculo.vehiculo.asientos,
    'peso_seco': vehiculo.vehiculo.peso_neto,
    'peso_bruto': vehiculo.vehiculo.peso_bruto,
    'longitud': vehiculo.vehiculo.longitud,
    'altura': vehiculo.vehiculo.altura,
    'ancho': vehiculo.vehiculo.ancho,
    'carga_util': vehiculo.vehiculo.carga_util,

    }
    
    form = FormVehiculo(initial=data_form)
    if request.method == 'POST':
        form = FormVehiculo(request.POST)
        if form.is_valid():
            form_data = form.cleaned_data
            save_edit_vehiculo(vehiculo, form_data, option=1)
            return HttpResponseRedirect('/vehiculos/')
    context = RequestContext(request)
    template = 'vehiculos/add.html'
    data = {
    'form': form
    }
    return render_to_response(template, data, context_instance=context) 
Пример #2
0
def add_vehiculo(request):
    """Fucion para agregar un vehiculo """
    form = FormVehiculo()
    if request.method == 'POST':
        form = FormVehiculo(request.POST) 
        if form.is_valid():
            data_form = form.cleaned_data           
            vehiculo = Vehiculo()

            save_edit_vehiculo(vehiculo, data_form)
            return HttpResponseRedirect('/vehiculos/')
    
    template = 'vehiculos/add.html'
    context = RequestContext(request)
    data = {
    'form': form
    
    }
    
    return render_to_response(template ,data, context_instance=context)