示例#1
0
def eliminarProfesor():
    id = request.args.get('id')
    profesor = Profesor.getProfesor(int(id))
    verif_materias = profesor.verificarMateriasProfesor()
    if verif_materias[0]['cantidad'] > 0:
        lista_materias_profesor = Profesor().selectMateriasProfesor(profesor)
        return render_template('/profesor/errorEliminarProfesor.html',
                               lista_materias_profesor=lista_materias_profesor)
    profesor.eliminarProfesor()
    return redirect('/profesor/mostrar/')
示例#2
0
def crearP():
    nombre = request.form['nom']
    apellido = request.form['apell']
    fn = request.form['fn']

    profesor = Profesor()
    profesor.setNombre(nombre)
    profesor.setApellido(apellido)
    fn_split = fn.split('-', 2)
    profesor.setFechaNac(int(fn_split[0]), int(fn_split[1]), int(fn_split[2]))

    profesor.insertProfesor()
    return redirect('/profesor/')
示例#3
0
def modificarMateria():
    idMat = request.args.get('id')
    materia = Materia().selectMateria(idMat)
    lista_curso = Curso().getListaCurso()
    lista_profesores = Profesor().getListaProfesor()
    return render_template('/materia/modificarMateria.html',
                           materia=materia,
                           lista_curso=lista_curso,
                           lista_profesores=lista_profesores)
示例#4
0
def crearC():
    nom = request.form['nom']
    curs = Curso().getCursoDB(request.form['curs'])
    prof = Profesor().getProfesor(int(request.form['prof']))

    materia = Materia()
    materia.setNombre(nom)
    materia.setCurso(curs)
    materia.setProfesor(prof)
    materia.insertarMateria()
    return redirect('/materia/')
示例#5
0
def crearUsuarioProfesor():
    nombre_completo = request.form["fullname"]
    usuario = request.form["user"]
    contraseña = request.form["passwd"]

    temp_prof = Profesor().getProfesor(nombre_completo)
    if temp_prof == False:
        return render_template(
            "/login_templates/profesor/profesor_signup.html", error=True)

    else:
        redirect("/home")
示例#6
0
def opcion():
    if not 'userid' in session:
        return redirect('/login/adminLogin')

    user = Usuario().getUsuario(int(session['userid']))

    if type(user.tipoUsuario) is Profesor():
        return render_template("opcion.html", user=user, ver="Es Profesor")
    elif type(user.tipoUsuario) is Familia():
        return render_template("opcion.html", user=user, ver="Es Familia")
    elif user.tipoUsuario == 1:
        return render_template("opcion.html", user=user, ver="Es Admin")
示例#7
0
    def selectListaMaterias():
        temp_subject_list = []
        subject_dict = DB().run("select * from Materia")
        for subject in subject_dict:
            temp_subject = Materia()
            temp_subject.setID(subject["idMateria"])
            temp_subject.setNombre(subject["nombre"])
            temp_subject.setProfesor(Profesor().getProfesor(subject["Profesor_idProfesor"]))
            temp_subject.setCurso(Curso().getCursoDB(subject["Curso_idCurso"]))

            temp_subject_list.append(temp_subject)

        return temp_subject_list
示例#8
0
    def selectMateria(id_materia):
        subject_dict = DB().run("select * from Materia where idMateria = " + id_materia)
        subject_fetch = subject_dict.fetchall()

        if len(subject_fetch) == 0:
            return False
        else:
            temp_sub = Materia()
            temp_sub.setID(subject_fetch[0]["idMateria"])
            temp_sub.setNombre(subject_fetch[0]["nombre"])
            temp_sub.setProfesor(Profesor().getProfesor(subject_fetch[0]["Profesor_idProfesor"]))
            temp_sub.setCurso(Curso().getCursoDB(subject_fetch[0]["Curso_idCurso"]))

            return temp_sub
示例#9
0
def modificar():
    idMateria = request.form['id']
    nom = request.form['nom']
    curs = Curso().getCursoDB(request.form['curs'])
    prof = Profesor().getProfesor(int(request.form['prof']))

    materia = Materia().selectMateria(idMateria)
    if nom != materia.nombre:
        materia.setNombre(nom)
    if curs != materia.curso:
        materia.setCurso(curs)
    if prof != materia.profesor:
        materia.setProfesor(prof)

    materia.actualizarMateria()
    return redirect('/materia/mostrar/')
示例#10
0
def modificarP():
    idProfesor = request.form['id']
    nom = request.form['nom']
    apell = request.form['apell']
    fn = request.form['fn']

    profesor = Profesor.getProfesor(int(idProfesor))
    if nom != profesor.nombre:
        profesor.setNombre(nom)
    if apell != profesor.apellido:
        profesor.setApellido(apell)
    if fn != profesor.fecha_nacimiento:
        fn_split = fn.split('-', 2)
        profesor.setFechaNac(int(fn_split[0]), int(fn_split[1]),
                             int(fn_split[2]))

    profesor.actualizarProfesor()
    return redirect('/profesor/mostrar/')
    def selectListaMateriasCurso(curso):
        from class_materia import Materia
        from class_profesor import Profesor
        temp_list_subject = []
        sub_dict = DB().run("select * from Materia where Curso_idCurso = " +
                            str(curso.idCurso))
        sub_fetch = sub_dict.fetchall()

        if len(sub_fetch) == 0:
            return temp_list_subject

        for subject in sub_fetch:
            temp_sub = Materia()
            temp_sub.setID(subject["idMateria"])
            temp_sub.setNombre(subject["nombre"])
            temp_sub.setProfesor(Profesor().getProfesor(
                int(subject["Profesor_idProfesor"])))
            temp_sub.setCurso(Curso().getCursoDB(subject["Curso_idCurso"]))

            temp_list_subject.append(temp_sub)

        return temp_list_subject
示例#12
0
    def getUsuario(user):
        if type(user) is not int:
            usuario = DB().run("select * from Usuario where Usuario = '" + user + "'")
        else:
            usuario = DB().run("select * from Usuario where idUsuario = " + str(user))

        usu_fetch = usuario.fetchall()
        if len(usu_fetch) == 0:
            return None

        if usu_fetch[0]["idFamilia"] is None and usu_fetch[0]['idProfesor'] is None:
            temp_user = Usuario()
            temp_user.setID(usu_fetch[0]["idUsuario"])
            temp_user.setTipoUsuario(usu_fetch[0]["idAdmin"])
            temp_user.setUsuario(usu_fetch[0]["usuario"])
            temp_user.setContraseña(usu_fetch[0]["contraseña"])

            return temp_user

        elif usu_fetch[0]["idFamilia"] is None:
            temp_user = Usuario()
            temp_user.setID(usu_fetch[0]["idUsuario"])
            temp_user.setTipoUsuario(Profesor().getProfesor(int(usu_fetch[0]["idProfesor"])))
            temp_user.setUsuario(usu_fetch[0]['usuario'])
            temp_user.setContraseña(usu_fetch[0]['contraseña'])

            return usu_fetch

        elif usu_fetch[0]["idProfesor"] is None:
            temp_user = Usuario()
            temp_user.setID(usu_fetch[0]["idUsuario"])
            temp_user.setTipoUsuario(Familia().getFamilia(usu_fetch[0]['idFamilia']))
            temp_user.setUsuario(usu_fetch[0]['usuario'])
            temp_user.setContraseña(usu_fetch[0]['contraseña'])

            return temp_user
            print("¿Que desea hacer con Profesor?: \n")
            print("1. Crear Profesor")
            print("2. Editar Profesor")
            print("3. Eliminar Profesor")
            print("4. Mostrar Profesores \n")

            op_prof = input("\nIngrese la opcion correspondiente: ")

            if int(op_prof) == 1:
                os.system("clear")
                nom = input("Ingrese el nombre del profesor: ")
                apell = input("Ingrese el apellido del profesor: ")
                fecha_nac = input("Ingrese la fecha de nacimiento del profesor (utilice '/'): ")

                nombre_completo = nom + " " + apell
                verif = Profesor().getProfesor(nombre_completo)

                if verif is False:
                    prof = Profesor()

                    prof.setNombre(nom)
                    prof.setApellido(apell)

                    fecha_nac_split = fecha_nac.split("/", 2)

                    prof.setFechaNac(int(fecha_nac_split[2]), int(fecha_nac_split[1]), int(fecha_nac_split[0]))

                    prof.insertProfesor()

                    print("\nSe ha creado el profesor correctamente.")
                    input("Presione cualquier tecla para continuar...")
示例#14
0
def crearMateria():
    lista_curso = Curso().getListaCurso()
    lista_profesores = Profesor().getListaProfesor()
    return render_template('/materia/crearMateria.html',
                           lista_curso=lista_curso,
                           lista_profesores=lista_profesores)
示例#15
0
def modificarProfesor():
    idProfesor = request.args.get('id')
    profesor = Profesor.getProfesor(int(idProfesor))
    return render_template('/profesor/modificarProfesor.html',
                           profesor=profesor)
示例#16
0
def mostrarProfesor():
    lista_profesores = Profesor.getListaProfesor()
    return render_template('/profesor/mostrarProfesor.html',
                           lista_profesores=lista_profesores)