Exemple #1
0
def nueva_farmacia (request):
    if request.method == 'POST':
        formulario = FarmaciaForm(request.POST)
        if formulario.is_valid():
            c = formulario.save()
            admin_log_change(request, c, 'Farmacia Creada')
            sms = "Farmacia %s Creada Correctamente"%(c.tipo)
            messages.success(request, sms)
            return HttpResponseRedirect(reverse(index_farmacia))
    else:
        formulario = FarmaciaForm()
    return render(request, 'farmacias/nueva_farmacia.html',{
        'formulario':formulario,
    })
Exemple #2
0
def modificar_farmacia (request, pk):
    formularioMod = get_object_or_404(Farmacia, pk=pk)
    if request.method == 'POST':
        formulario = FarmaciaForm(request.POST, instance=formularioMod)
        if formulario.is_valid():
            c = formulario.save()
            admin_log_change(request, c, 'Farmacia Modificada')
            sms = "Farmacia %s Modificada Correctamente"%(c.tipo)
            messages.success(request, sms)
            return HttpResponseRedirect(reverse(index_farmacia))
    else:
        formulario = FarmaciaForm(instance=formularioMod)
    return render(request, 'farmacias/modificar_farmacia.html',{
        'formulario':formulario,
    })