X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/blobdiff_plain/8c7925a328c452c08004c3797c4bfe602390c46e..623286fc914364430dcedeacd13d66b8e4365f60:/sercom/subcontrollers/grupo/__init__.py diff --git a/sercom/subcontrollers/grupo/__init__.py b/sercom/subcontrollers/grupo/__init__.py index 8190821..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):