X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/7e9b43b2435668edbd58b304ef02c1171afec5a8..f7393e0e6363d1c56d579a9fe86c99f9a45bb4bf:/sercom/subcontrollers/validate.py?ds=inline diff --git a/sercom/subcontrollers/validate.py b/sercom/subcontrollers/validate.py index e527e6e..9b4a96a 100644 --- a/sercom/subcontrollers/validate.py +++ b/sercom/subcontrollers/validate.py @@ -21,6 +21,7 @@ def validate_set(cls, name, id, data, url='../edit'): r = validate_get(cls, name, id) try: r.set(**data) + return r except DuplicateEntryError, e: flash(_(u'No se pudo modificar el %s porque no es único (error: %s).') % (name, e)) @@ -42,3 +43,11 @@ def validate_new(cls, name, data, url='new'): u'inválido (error: %s).') % (name, e)) raise redirect(url, **data) +def validate_del(cls, name, id): + try: + id = int(id) + r = validate_get(cls, name, id) + r.destroySelf() + except Exception, e: + flash(_(u'No se pudo eliminar el %s: %s' % (name, e))) + raise redirect('../list')