X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/blobdiff_plain/30b66b3ed7061eaaab51a23cc71e6aff0dbdc650..bcb3e4bcc3dfbface661034e16a86c69d4218d74:/sercom/subcontrollers/curso/__init__.py diff --git a/sercom/subcontrollers/curso/__init__.py b/sercom/subcontrollers/curso/__init__.py index 0528def..699bc79 100644 --- a/sercom/subcontrollers/curso/__init__.py +++ b/sercom/subcontrollers/curso/__init__.py @@ -10,13 +10,14 @@ from turbogears import identity from turbogears import paginate from docutils.core import publish_parts from sercom.subcontrollers import validate as val -from sercom.model import Curso, Correccion, Ejercicio, Alumno, Docente, Grupo, DocenteInscripto +from sercom.model import Curso, Correccion, Ejercicio, Alumno, Docente, Grupo, DocenteInscripto, Rol from curso_alumno import * from sqlobject import * from sqlobject.dberrors import * from sercom.widgets import * from alumno import AlumnoInscriptoController from grupo import GrupoController +from ejercicio import EjercicioController #}}} #{{{ Configuración @@ -104,17 +105,8 @@ def validate_del(id): return val.validate_del(cls, name, id) #}}} -def get_ejercicios(): - return [(fk1.id, fk1.shortrepr()) for fk1 in Ejercicio.select()] - def get_docentes(): - return [(fk1.id, fk1.shortrepr()) for fk1 in Docente.select()] - -def get_alumnos(): - return [(fk1.id, fk1.shortrepr()) for fk1 in Alumno.select()] - -def get_grupos(): - return [(fk1.id, fk1.shortrepr()) for fk1 in Grupo.select()] + return [(fk1.id, fk1.shortrepr()) for fk1 in Docente.selectBy(activo=True)] #{{{ Formulario @@ -172,6 +164,7 @@ class CursoController(controllers.Controller, identity.SecureResource): curso_alumno = CursoAlumnoController() alumno = AlumnoInscriptoController() grupo = GrupoController() + ejercicio = EjercicioController() @expose() def default(self, tg_errors=None): @@ -186,7 +179,7 @@ class CursoController(controllers.Controller, identity.SecureResource): @paginate('records') def list(self): """List records in model""" - r = cls.select() + r = cls.select().orderBy((-cls.q.anio, -cls.q.cuatrimestre, cls.q.numero)) return dict(records=r, name=name, namepl=namepl) @expose() @@ -229,20 +222,10 @@ class CursoController(controllers.Controller, identity.SecureResource): def edit(self, id, **kw): """Edit record in model""" r = validate_get(id) - class EmptyClass: - pass - values = EmptyClass() - values.id = r.id - values.anio = r.anio - values.numero = r.numero - values.cuatrimestre = r.cuatrimestre - values.cursoID = r.id - values.descripcion = r.descripcion # cargo la lista con los docentes asignados al curso - values.docentes_to = [{"id":d.docente.id, "label":d.docente.shortrepr()} for d in DocenteInscripto.selectBy(curso=r.id)] - values.alumnos_inscriptos = [{"id":a.alumno.id, "label":a.alumno.shortrepr()} for a in AlumnoInscripto.selectBy(curso=r.id)] - - return dict(name=name, namepl=namepl, record=values, form=form) + r.docentes_to = [{"id":d.docente.id, "label":d.docente.shortrepr()} for d in r.docentes] + r.alumnos_inscriptos = [{"id":a.alumno.id, "label":a.alumno.shortrepr()} for a in r.alumnos] + return dict(name=name, namepl=namepl, record=r, form=form) @validate(form=form) @error_handler(edit) @@ -317,13 +300,13 @@ class CursoController(controllers.Controller, identity.SecureResource): if row == []: continue try: - u = Alumno(row[0], nombre=row[1]) + u = Alumno(row[0], nombre=row[1], roles=[Rol.by_nombre('alumno')]) except: u = Alumno.byPadron(row[0]) try: u.email = row[2] u.telefono = row[3] - u.contrasenia = row[0] + u.password = row[0] u.activo = True curso.add_alumno(u) ok.append(row) @@ -372,7 +355,7 @@ class CursoController(controllers.Controller, identity.SecureResource): if c[0].nota > 7: correctas += 1 else: - col["E"+str(ej.numero)+str(ins.numero)] = "" + col["E"+str(ej.numero)+str(ins.numero)] = "" col["EA"] = correctas col["NP"] = i.nota_practica col["NF"] = i.nota_final @@ -427,7 +410,6 @@ class CursoController(controllers.Controller, identity.SecureResource): s = ",".join(cols) + "\n" for i in rows: s = s + ",".join(i) + "\n" - return s #}}}