From 899cd679d658580998a8daa9689096b00661ba47 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 19 Mar 2007 00:57:03 +0000 Subject: [PATCH] Bugfix: los correctores son DocenteInscripto, no Docente. --- sercom/finalizer.py | 2 +- sercom/subcontrollers/correccion/__init__.py | 26 ++++++++++--------- .../correccion/templates/list.kid | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/sercom/finalizer.py b/sercom/finalizer.py index e3277f8..c701087 100644 --- a/sercom/finalizer.py +++ b/sercom/finalizer.py @@ -50,7 +50,7 @@ class Finalizer(object): #{{{ def instancia_finalizar(self): #{{{ log.debug(_(u'InstanciaDeEntrega.finalizar()')) curso = self.ejercicio.curso - docentes = [di.docente for di in curso.docentes if di.corrige] + docentes = [di for di in curso.docentes if di.corrige] curr_docente = 0 for ai in curso.alumnos: try: diff --git a/sercom/subcontrollers/correccion/__init__.py b/sercom/subcontrollers/correccion/__init__.py index 20b3ea0..922c404 100644 --- a/sercom/subcontrollers/correccion/__init__.py +++ b/sercom/subcontrollers/correccion/__init__.py @@ -10,7 +10,8 @@ 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 Correccion, Curso, Ejercicio, InstanciaDeEntrega +from sercom.model import Correccion, Curso, Ejercicio +from sercom.model import InstanciaDeEntrega, DocenteInscripto from sqlobject import * #}}} @@ -44,12 +45,9 @@ class CorreccionForm(W.TableForm): fields = Fields() javascript = [W.JSSource("MochiKit.DOM.focusOnLoad('form_instancia');")] -def get_cursos(): - return [(0, u'---')] + [(fk1.id, fk1.shortrepr()) for fk1 in Curso.select()] - class CorreccionFiltros(W.TableForm): class Fields(W.WidgetsList): - cursoID = W.SingleSelectField(label=_(u'Curso'), options = get_cursos, validator = V.Int(not_empty=True)) + cursoID = W.SingleSelectField(label=_(u'Curso'), validator=V.Int(not_empty=True)) form_attrs={'class':"filter"} fields = Fields() @@ -72,22 +70,26 @@ class CorreccionController(controllers.Controller, identity.SecureResource): raise redirect('list') @expose(template='kid:%s.templates.list' % __name__) + @validate(validators=dict(cursoID=V.Int)) @paginate('records') - def list(self, cursoID = 0): + def list(self, cursoID=None): """List records in model""" - vfilter = dict(cursoID = cursoID) - if int(cursoID) == 0: - r = cls.selectBy(corrector=identity.current.user) - else: + vfilter = dict(cursoID=cursoID) + r = [] + if cursoID: r = cls.select( AND( - cls.q.correctorID == identity.current.user.id, + cls.q.correctorID == DocenteInscripto.pk.get( + cursoID=cursoID, docenteID=identity.current.user.id).id, Ejercicio.q.id == InstanciaDeEntrega.q.ejercicioID, InstanciaDeEntrega.q.id == Correccion.q.instanciaID, Ejercicio.q.cursoID == cursoID ) ) - return dict(records=r, name=name, namepl=namepl, form=filtro, vfilter=vfilter) + cursos = [(i.curso.id, i.curso.shortrepr()) + for i in identity.current.user.inscripciones] + return dict(records=r, name=name, namepl=namepl, form=filtro, + vfilter=vfilter, options=dict(cursoID=cursos)) @expose(template='kid:%s.templates.edit' % __name__) def edit(self, id, **kw): diff --git a/sercom/subcontrollers/correccion/templates/list.kid b/sercom/subcontrollers/correccion/templates/list.kid index 265b2ce..308abcb 100644 --- a/sercom/subcontrollers/correccion/templates/list.kid +++ b/sercom/subcontrollers/correccion/templates/list.kid @@ -10,7 +10,7 @@

Administración de Objetos

-
Filtros
+
Filtros
-- 2.43.0