X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/03da7f62646ae07d940f889f7d04703b7c3bd286..6ce4d4e8ad92583bb1187385f30f52ade8beee9e:/sercom/subcontrollers/grupo/__init__.py diff --git a/sercom/subcontrollers/grupo/__init__.py b/sercom/subcontrollers/grupo/__init__.py index 3f092a2..28abe65 100644 --- a/sercom/subcontrollers/grupo/__init__.py +++ b/sercom/subcontrollers/grupo/__init__.py @@ -220,20 +220,16 @@ class GrupoController(controllers.Controller, identity.SecureResource): """Save or create record to model""" responsable = kw['responsable'] curso = kw['cursoID'] - alumno = None + resp = kw['responsable'] 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') - + resp = AlumnoInscripto.selectBy(cursoID=kw['cursoID'], + alumno=Alumno.byPadron(kw['responsable'])).getOne() + except SQLObjectNotFound: + flash(_(u'El responsable %s no existe') % resp) + raise redirect('list') + kw['responsable'] = resp r = validate_set(id, kw) - r.responsable = alumno flash(_(u'El %s fue actualizado.') % name) raise redirect('../list')