X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/blobdiff_plain/5cd1df8c26d5462fed3d660d965d5e2e34af8119..081f501efd6fd1c2833faafb45ed4f57fa4bb8c8:/sercom/subcontrollers/docente/__init__.py diff --git a/sercom/subcontrollers/docente/__init__.py b/sercom/subcontrollers/docente/__init__.py index c410e4d..c4dcfc5 100644 --- a/sercom/subcontrollers/docente/__init__.py +++ b/sercom/subcontrollers/docente/__init__.py @@ -60,17 +60,30 @@ class DocenteController(controllers.Controller, identity.SecureResource): return dict(records=r, name=name, namepl=namepl, tg_flash=f) + @expose() + def activate(self, id, activo): + """Save or create record to model""" + cls.get(int(id)).activo = int(activo) + + raise redirect('../list') + @expose(template='kid:sercom.subcontrollers.%s.templates.new' % name) def new(self, **kw): """Create new records in model""" - return dict(name=name, namepl=namepl, form=form) + f = kw.get('tg_flash', None) + return dict(name=name, namepl=namepl, form=form, tg_flash=f, values=kw) @validate(form=form) @error_handler(new) @expose() def create(self, **kw): """Save or create record to model""" - Docente(**kw) + try: + Docente(**kw) + except Exception, e: + raise redirect('new', tg_flash=_(u'No se pudo crear el nuevo %s, ' \ + 'probablemente ya existe uno con el mismo usuario (error: %s).' + % (name, e)), **kw) raise redirect('list', tg_flash=_(u'Se creó un nuevo %s.') % name)