X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/blobdiff_plain/357be9e396cadfeaa3814fd29fcbf28baaf7fa2d..8e6df21683f1d7169f6822fe9f0f0c62fe520679:/sercom/subcontrollers/enunciado/__init__.py diff --git a/sercom/subcontrollers/enunciado/__init__.py b/sercom/subcontrollers/enunciado/__init__.py index 86bc1f8..818fda3 100644 --- a/sercom/subcontrollers/enunciado/__init__.py +++ b/sercom/subcontrollers/enunciado/__init__.py @@ -1,5 +1,6 @@ # vim: set et sw=4 sts=4 encoding=utf-8 : +#{{{ Imports from turbogears import controllers, expose, redirect from turbogears import validate, validators, flash, error_handler from turbogears.widgets import * @@ -8,7 +9,9 @@ from turbogears import paginate from docutils.core import publish_parts from sercom.subcontrollers import validate as val from sercom.model import Enunciado, Docente +#}}} +#{{{ Configuración cls = Enunciado name = 'enunciado' namepl = name + 's' @@ -16,7 +19,9 @@ namepl = name + 's' fkcls = Docente fkname = 'autor' fknamepl = fkname + 'es' +#}}} +#{{{ Validación def validate_fk(data): fk = data.get(fkname + 'ID', None) if fk == 0: fk = None @@ -41,7 +46,9 @@ def validate_set(id, data): def validate_new(data): validate_fk(data) return val.validate_new(cls, name, data) +#}}} +#{{{ Formulario def get_options(): return [(0, _(u'--'))] + [(fk.id, fk.shortrepr()) for fk in fkcls.select()] @@ -54,7 +61,10 @@ form = TableForm(fields=[ TextField(name='descripcion', label=_(u'Descripción'), validator=validators.UnicodeString(not_empty=False, max=255, strip=True)), ]) +form.javascript.append(JSSource("MochiKit.DOM.focusOnLoad('form_nombre');")) +#}}} +#{{{ Controlador class EnunciadoController(controllers.Controller, identity.SecureResource): """Basic model admin interface""" require = identity.has_permission('admin') @@ -125,4 +135,5 @@ class EnunciadoController(controllers.Controller, identity.SecureResource): r.destroySelf() flash(_(u'El %s fue eliminado permanentemente.') % name) raise redirect('../list') +#}}}