X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/blobdiff_plain/b6a752602ca8d7c7b6cebfd2e0c9a9e191773ce8..d480400b3f16dd41f6796f5af15ef2be6dfdf6d0:/sercom/subcontrollers/alumno/__init__.py diff --git a/sercom/subcontrollers/alumno/__init__.py b/sercom/subcontrollers/alumno/__init__.py index 7cdb455..3d2c11a 100644 --- a/sercom/subcontrollers/alumno/__init__.py +++ b/sercom/subcontrollers/alumno/__init__.py @@ -11,6 +11,7 @@ from turbogears import paginate from docutils.core import publish_parts from sercom.subcontrollers import validate as val from sercom.model import Alumno +from sqlobject import * #}}} #{{{ Configuración @@ -171,5 +172,25 @@ class AlumnoController(controllers.Controller, identity.SecureResource): row.append(str(e)) fail.append(row) return dict(ok=ok, fail=fail) + + @expose('json') + def get_alumno(self, padron): + msg = u'' + error=False + try: + # Busco el alumno inscripto + alumno = Alumno.byPadron(padron=padron) + msg = {} + msg['id'] = alumno.id + msg['value'] = alumno.nombre + except SQLObjectNotFound: + msg = 'No existe el alumno con padron: %s.' % padron + error=True + except Exception, (inst): + msg = u"""Se ha producido un error inesperado al buscar el registro:\n %s""" % str(inst) + error = True + return dict(msg=msg, error=error) + + #}}}