예제 #1
0
파일: views.py 프로젝트: ejrua/MYEscuela
def addHorariosViews(request):
    now = str(datetime.datetime.now())[:10]

    if request.method == "POST":
        formHorario = HorariosForm(request.POST or None)

        if formHorario.is_valid():
            n = formHorario.save()
            n.save()
            return HttpResponseRedirect('/gestion/horario/' + str(n.docente.id)+'/' + str(n.version.id))

        ctx = {'formHorario': formHorario}
        return render_to_response('addHorarios.html', ctx, context_instance=RequestContext(request))

    if request.method == "GET":
        info_enviado = "GET"

        verHorarior = Preferencias.objects.get(descripcion='Version_horario')
        docente = Preferencias.objects.get(descripcion='Docente')
        saloon = Preferencias.objects.get(descripcion='Saloon')

        formHorario = HorariosForm(initial={'ano': 1,
                                            'sede': 1,
                                            'jornada': 1,
                                            'docente':docente.valor,
                                            'version': verHorarior.valor,
                                            'saloon':saloon.valor,
                                            'asignatura':1
                                            })
        ctx = {'formHorario': formHorario, "info_enviado": info_enviado}
        return render_to_response('addHorarios.html/', ctx, context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: ejrua/MYEscuela
def editHorariosview(request, id_horario):
    if request.method == "POST":
        base = get_object_or_404(Horarios, id=id_horario)
        formHorario = HorariosForm(request.POST or None, instance=base)

        if formHorario.is_valid():
            h = formHorario.save()
            h.save()
            return HttpResponseRedirect('/gestion/horarios/')

        ctx = {'formHorario': formHorario}
        return render_to_response('editHorarios.html', ctx, context_instance=RequestContext(request))

    if request.method == "GET":
        info_enviado = "Get"

        horarios = get_object_or_404(Horarios, id=id_horario)
        formHorario = HorariosForm(request.GET or None, instance=horarios)

        ctx = {'info_enviado': info_enviado, 'formHorario': formHorario}
        return render_to_response('editHorarios.html', ctx, context_instance=RequestContext(request))