From: Ricardo Markiewicz Date: Tue, 13 Mar 2007 17:09:32 +0000 (+0000) Subject: Lista de tareas de un enunciado. X-Git-Tag: 0_9_0~160 X-Git-Url: https://git.llucax.com/software/sercom.git/commitdiff_plain/5bd374c98f13c5e51cd2e182b7f57eddac33d8fc?hp=8fa6a4ab1ebc11f4c4282c3c519919d397b3effb Lista de tareas de un enunciado. Solo LISTA, faltan demas funcionalidades. --- diff --git a/sercom/subcontrollers/enunciado/__init__.py b/sercom/subcontrollers/enunciado/__init__.py index d265192..2195e2a 100644 --- a/sercom/subcontrollers/enunciado/__init__.py +++ b/sercom/subcontrollers/enunciado/__init__.py @@ -11,6 +11,8 @@ from docutils.core import publish_parts from sercom.subcontrollers import validate as val from sercom.model import Enunciado, Docente, Curso from cherrypy import request, response +from tarea import TareaController + #}}} #{{{ Configuración @@ -81,6 +83,8 @@ class EnunciadoController(controllers.Controller, identity.SecureResource): """Basic model admin interface""" require = identity.has_permission('entregar') + tarea = TareaController() + @expose() def default(self, tg_errors=None): """handle non exist urls""" diff --git a/sercom/subcontrollers/enunciado/tarea/__init__.py b/sercom/subcontrollers/enunciado/tarea/__init__.py new file mode 100644 index 0000000..3fcf22f --- /dev/null +++ b/sercom/subcontrollers/enunciado/tarea/__init__.py @@ -0,0 +1,131 @@ +# vim: set et sw=4 sts=4 encoding=utf-8 foldmethod=marker : + +#{{{ Imports +from turbogears import controllers, expose, redirect +from turbogears import validate, flash, error_handler +from turbogears import validators as V +from turbogears import widgets as W +from turbogears import identity +from turbogears import paginate +from docutils.core import publish_parts +from sercom.subcontrollers import validate as val +from sercom.model import Tarea, Enunciado +#}}} + +#{{{ Configuración +cls = Tarea +name = 'tarea' +namepl = 'tareas' + +#}}} + +#{{{ Validación +def validate_get(id): + return val.validate_get(cls, name, id) + +def validate_set(id, data): + return val.validate_set(cls, name, id, data) + +def validate_new(data): + return val.validate_new(cls, name, data) + +def validate_del(id): + return val.validate_del(cls, name, id) +#}}} + +#{{{ Formulario +def get_options(): + return [(0, _(u'<>'))] + [(fk.id, fk.shortrepr()) + for fk in fkcls.select()] + +class CasoDePruebaForm(W.TableForm): + class Fields(W.WidgetsList): + nombre = W.TextField(label=_(u'Nombre'), + help_text=_(u'Requerido y único.'), + validator=V.UnicodeString(min=5, max=60, strip=True)) + descripcion = W.TextField(label=_(u'Descripción'), + validator=V.UnicodeString(not_empty=False, max=255, + strip=True)) + comando = W.TextField(label=_(u'Comando'), + validator=V.UnicodeString(not_empty=False, strip=True)) + retorno = W.TextField(label=_(u'Código de retorno'), + validator=V.Int(not_empty=False, strip=True)) + max_tiempo_cpu = W.TextField(label=_(u'Máximo tiempo de CPU'), + validator=V.Number(not_empty=False, strip=True)) + fields = Fields() + javascript = [W.JSSource("MochiKit.DOM.focusOnLoad('form_nombre');")] + +form = CasoDePruebaForm() +#}}} + +#{{{ Controlador + +class TareaController(controllers.Controller, identity.SecureResource): + """Basic model admin interface""" + require = identity.has_permission('admin') + + @expose() + def default(self, tg_errors=None): + """handle non exist urls""" + raise redirect('list') + + @expose() + def index(self): + raise redirect('list') + + @expose(template='kid:%s.templates.list' % __name__) + @validate(validators=dict(enunciado=V.Int)) + def list(self, enunciado): + """List records in model""" + if enunciado is None: + raise redirect("../list") + r = Enunciado.get(enunciado) + return dict(enunciado=r) + + @expose(template='kid:%s.templates.new' % __name__) + def new(self, **kw): + """Create new records in model""" + return dict(name=name, namepl=namepl, form=form, values=kw) + + @validate(form=form) + @error_handler(new) + @expose() + def create(self, **kw): + """Save or create record to model""" + validate_new(kw) + flash(_(u'Se creó un nuevo %s.') % name) + raise redirect('list') + + @expose(template='kid:%s.templates.edit' % __name__) + def edit(self, id, **kw): + """Edit record in model""" + r = validate_get(id) + return dict(name=name, namepl=namepl, record=r, form=form) + + @validate(form=form) + @error_handler(edit) + @expose() + def update(self, id, **kw): + """Save or create record to model""" + r = validate_set(id, kw) + flash(_(u'El %s fue actualizado.') % name) + raise redirect('../list') + + @expose(template='kid:%s.templates.show' % __name__) + def show(self, id, **kw): + """Show record in model""" + r = validate_get(id) + if r.descripcion is None: + r.desc = '' + else: + r.desc = publish_parts(r.descripcion, writer_name='html')['html_body'] + return dict(name=name, namepl=namepl, record=r) + + @expose() + def delete(self, id): + """Destroy record in model""" + validate_del(id) + flash(_(u'El %s fue eliminado permanentemente.') % name) + raise redirect('../list') +#}}} + diff --git a/sercom/subcontrollers/enunciado/tarea/templates/__init__.py b/sercom/subcontrollers/enunciado/tarea/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sercom/subcontrollers/enunciado/tarea/templates/list.kid b/sercom/subcontrollers/enunciado/tarea/templates/list.kid new file mode 100644 index 0000000..186ec47 --- /dev/null +++ b/sercom/subcontrollers/enunciado/tarea/templates/list.kid @@ -0,0 +1,28 @@ + + + + +list + + + +

Tareas de Objetos

+ + + + + + + + +
Tarea
tarea
+ +
+Agregar +Volver + + + + + diff --git a/sercom/subcontrollers/enunciado/templates/list.kid b/sercom/subcontrollers/enunciado/templates/list.kid index a6fde05..c3b7007 100644 --- a/sercom/subcontrollers/enunciado/templates/list.kid +++ b/sercom/subcontrollers/enunciado/templates/list.kid @@ -17,6 +17,7 @@ Nombre Descripción Autor + Tareas CP Operaciones @@ -31,6 +32,9 @@ autor + cant cant