X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/blobdiff_plain/435b160c7f45d1aa993e2f933fd0343543a1b512..80bb0681e6367432275beb8a3fd09160e7a91fbf:/sercom/subcontrollers/grupo/__init__.py diff --git a/sercom/subcontrollers/grupo/__init__.py b/sercom/subcontrollers/grupo/__init__.py index 6cb6cd1..29ad202 100644 --- a/sercom/subcontrollers/grupo/__init__.py +++ b/sercom/subcontrollers/grupo/__init__.py @@ -153,6 +153,15 @@ class GrupoForm(W.TableForm): javascript = [W.JSSource("MochiKit.DOM.focusOnLoad('curso');"), W.JSSource(ajax)] form_attrs = dict(onsubmit='return onsubmit()') +def get_cursos(): + return [(0, u'---')] + [(fk1.id, fk1.shortrepr()) for fk1 in Curso.select()] + +class GrupoFiltros(W.TableForm): + class Fields(W.WidgetsList): + cursoID = W.SingleSelectField(label=_(u'Curso'), options = get_cursos, validator = V.Int(not_empty=True)) + fields = Fields() + +filtro = GrupoFiltros() form = GrupoForm() #}}} @@ -173,10 +182,14 @@ class GrupoController(controllers.Controller, identity.SecureResource): @expose(template='kid:%s.templates.list' % __name__) @paginate('records') - def list(self): + def list(self, cursoID = 0): """List records in model""" - r = cls.select() - return dict(records=r, name=name, namepl=namepl) + vfilter = dict(cursoID = cursoID) + if int(cursoID) == 0: + r = cls.select() + else: + r = cls.select(cls.q.cursoID == cursoID) + return dict(records=r, name=name, namepl=namepl, form=filtro, vfilter=vfilter) @expose() def activate(self, id, activo): @@ -225,7 +238,7 @@ class GrupoController(controllers.Controller, identity.SecureResource): # TODO : Ver como llenar la lista primero :S if r.responsable: values.responsable = r.responsable.alumno.padron - values.miembros = [{"id":i.alumno.id, "label":i.alumno.alumno.nombre} for i in r.miembros] + values.miembros = [{"id":i.alumno.id, "label":i.alumno.alumno.nombre} for i in filter(lambda x: x.baja is None, r.miembros)] values.tutores = [a.docenteID for a in r.tutores] return dict(name=name, namepl=namepl, record=values, form=form)