From 6e373c0523d8ca200b13ab0d2322e4b9347b930c Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 13 Mar 2007 04:32:19 +0000 Subject: [PATCH] Filtro por Curso para Grupo y linkeo filtrado desde Curso. --- .../subcontrollers/curso/templates/list.kid | 2 +- sercom/subcontrollers/grupo/__init__.py | 19 ++++++++++++++++--- .../subcontrollers/grupo/templates/list.kid | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/sercom/subcontrollers/curso/templates/list.kid b/sercom/subcontrollers/curso/templates/list.kid index 9c34d12..059c7d3 100644 --- a/sercom/subcontrollers/curso/templates/list.kid +++ b/sercom/subcontrollers/curso/templates/list.kid @@ -33,7 +33,7 @@ descripcion Docentes Alumnos - Grupos + Grupos Ejercicio Ver Editar 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): diff --git a/sercom/subcontrollers/grupo/templates/list.kid b/sercom/subcontrollers/grupo/templates/list.kid index a715913..c166fe9 100644 --- a/sercom/subcontrollers/grupo/templates/list.kid +++ b/sercom/subcontrollers/grupo/templates/list.kid @@ -9,6 +9,8 @@

Administración de Objetos

+
Filtros
+ -- 2.43.0
Curso