X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/8a15f8fedd03ec178f5f50f33af3300529ddeff8..86cda0b5747c356334877720dccb99fc9100f615:/sercom/subcontrollers/grupo/__init__.py diff --git a/sercom/subcontrollers/grupo/__init__.py b/sercom/subcontrollers/grupo/__init__.py index f919753..628d1b7 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') @@ -177,6 +192,8 @@ class GrupoController(controllers.Controller, identity.SecureResource): 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')