Example #1
0
def nuevaPersona(request):
    if request.method == 'POST':
        formaPersona = PersonaForm(request.POST)
        if formaPersona.is_valid():
            formaPersona.save()
            return redirect('index')
    else:
        formaPersona = PersonaForm()

    return render(request, 'personas/nuevo.html', {'formapersona': formaPersona})
Example #2
0
def editarPersona(request,id):
    persona = get_object_or_404(Persona, pk=id)
    if request.method == 'POST':
        formaPersona = PersonaForm(request.POST,instance=persona)
        if formaPersona.is_valid():
            formaPersona.save()
            return redirect('index')
    else:
        formaPersona = PersonaForm(instance=persona)

    return render(request, 'personas/editar.html',{'formaPersona':formaPersona})
Example #3
0
def persona_agregar(request):
    modo = request.GET.get('modo')
    if request.method == 'POST':
        volver = request.POST.get('volver')
        form = PersonaForm(request.POST, initial={'volver': volver})
        if form.is_valid():
            form.save()
            return donde_volver(modo)
        else:
            pass
    else:
        volver = request.META.get('HTTP_REFERER')
        form = PersonaForm(initial={'volver': volver})

    template_name = 'persona_form.html'
    return render(request, template_name, {'form': form, 'modo': modo})
Example #4
0
def inscripcion_agregar(request, paso, persona_id=None, curso_id=None):
    if paso == 0:
        """ Alta de persona """
        if request.method == 'POST':
            form = PersonaForm(request.POST, initial={'agregando_involucrado': True})
            if form.is_valid():
                persona = form.save()
                persona_id = persona.id
                url = reverse('inscripcion_agregar', kwargs={'paso': 1,
                                                             'persona_id': persona_id,
                                                             'curso_id': curso_id})
                return redirect(url)
        else:
            form = PersonaForm(initial={'agregando_involucrado': True})

        template_name = 'persona_form.html'
        return render(request, template_name, {'form': form,
                                               'agregando_involucrado': True})
    else:
        if request.POST:
            form = InscripcionForm(request.POST)
            if form.is_valid():
                form.save()
                return redirect('cursos_listar')
        else:
            initial = {'persona': persona_id,
                       'curso': curso_id,
                       'rol': 'ASI'}
            form = InscripcionForm(initial=initial)

    template_name = 'inscripcion_form.html'
    contexto = {'form': form}
    return render(request, template_name, contexto)