From 8a15f8fedd03ec178f5f50f33af3300529ddeff8 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 27 Feb 2007 02:58:22 +0000 Subject: [PATCH] el update ahora setea el responsable --- sercom/subcontrollers/grupo/__init__.py | 15 ++++++++++++++- sercom/subcontrollers/grupo/templates/edit.kid | 5 ++--- sercom/subcontrollers/grupo/templates/list.kid | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/sercom/subcontrollers/grupo/__init__.py b/sercom/subcontrollers/grupo/__init__.py index e7e1b30..f919753 100644 --- a/sercom/subcontrollers/grupo/__init__.py +++ b/sercom/subcontrollers/grupo/__init__.py @@ -108,7 +108,7 @@ class GrupoForm(W.TableForm): curso = W.SingleSelectField(name='cursoID', label=_(u'Curso'), options = get_cursos, validator = V.Int(not_empty=True)) nombre = W.TextField(label=_(u'Nombre'), validator=V.UnicodeString(not_empty=True,strip=True)) - responsable = CustomTextField(label=_(u'Responsable'), validator=V.Int(not_empty=True), attrs=dict(size='8')) + responsable = CustomTextField(label=_(u'Responsable'), validator=V.UnicodeString(not_empty=True), attrs=dict(size='8')) fields = Fields() javascript = [W.JSSource("MochiKit.DOM.focusOnLoad('curso');"), W.JSSource(ajax)] @@ -169,7 +169,20 @@ class GrupoController(controllers.Controller, identity.SecureResource): @expose() def update(self, id, **kw): """Save or create record to model""" + responsable = kw['responsable'] + curso = kw['cursoID'] + alumno = None + try: + # Busco el alumno inscripto + alumno = AlumnoInscripto.select(AND(Curso.q.id==curso, Alumno.q.usuario==responsable)) + if alumno.count() > 0: + alumno = alumno[0] + except Exception, (inst): + flash(_(u'El responsable %s no existe') % responsable) + raise redirect('../list') + r = validate_set(id, kw) + r.responsable = alumno flash(_(u'El %s fue actualizado.') % name) raise redirect('../list') diff --git a/sercom/subcontrollers/grupo/templates/edit.kid b/sercom/subcontrollers/grupo/templates/edit.kid index 7b50a66..7973188 100644 --- a/sercom/subcontrollers/grupo/templates/edit.kid +++ b/sercom/subcontrollers/grupo/templates/edit.kid @@ -9,12 +9,11 @@

Modificación de Objeto

-
Formulario

-Ver (cancela) | -Volver (cancela) +Volver (cancela) diff --git a/sercom/subcontrollers/grupo/templates/list.kid b/sercom/subcontrollers/grupo/templates/list.kid index 6d7d4af..c9e4979 100644 --- a/sercom/subcontrollers/grupo/templates/list.kid +++ b/sercom/subcontrollers/grupo/templates/list.kid @@ -19,7 +19,7 @@ curso nombre - + Editar Eliminar -- 2.43.0