From dbebd6ebb551f40f51684f8653b373690f06e694 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 27 Feb 2007 03:08:11 +0000 Subject: [PATCH] error en new si no existe el alumno en el curso --- sercom/subcontrollers/grupo/__init__.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sercom/subcontrollers/grupo/__init__.py b/sercom/subcontrollers/grupo/__init__.py index f919753..8c5bdaa 100644 --- a/sercom/subcontrollers/grupo/__init__.py +++ b/sercom/subcontrollers/grupo/__init__.py @@ -154,7 +154,22 @@ class GrupoController(controllers.Controller, identity.SecureResource): @expose() def create(self, **kw): """Save or create record to model""" - validate_new(kw) + 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] + else: + raise Exception + except Exception, (inst): + flash(_(u'El responsable %s no existe') % responsable) + raise redirect('list') + + kw['responsable'] = alumno + r = validate_new(kw) flash(_(u'Se creó un nuevo %s.') % name) raise redirect('list') -- 2.43.0