Ejemplo n.º 1
0
def fdental(request):
    if request.method == 'POST':
        if 'num_historia' in request.POST:
            registros = Registro.objects.filter(datos__nro_historia__contains=request.POST['num_historia'], fdental__isnull=True)
            return render_to_response('fdental.html', {'registros': registros, 'buscado': 'yes'}, context_instance=RequestContext(request))
        formrd = FdentalForm(request.POST)
        if formrd.is_valid():
            formrd.save()
            return HttpResponseRedirect('/operaciones/')
    else:
        formrd = FdentalForm()
    return render_to_response('fdental.html', {'formrd': formrd}, context_instance=RequestContext(request))
Ejemplo n.º 2
0
def fdental_buscado(request, historiac):
    odontograma = ''
    historia_c = get_object_or_404(Datos, pk=historiac)
    odont = Odontograma.objects.filter(nro_historia=historia_c)
    if len(odont) > 0:
        odontograma = odont[0]
    instancia = Fdental(nro_historia=historia_c)
    if request.method == 'POST':
        formrd = FdentalForm(request.POST)
        if formrd.is_valid():
            formu_d = formrd.save()
            registros = Registro.objects.filter(datos__nro_historia=request.POST['nro_historia'], fdental__isnull=True)
            registro = registros.order_by('-fecha')[0]
            registro.fdental = formu_d
            registro.save()
            return HttpResponseRedirect('/operaciones/')
    else:
        formrd = FdentalForm(instance=instancia)
    return render_to_response('fdental.html', {'formrd': formrd, 'odontograma': odontograma, 'historia_c': historia_c}, context_instance=RequestContext(request))