From 05d15f29c862ff13b9da5d9a57c8470065a6b824 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Sun, 4 Mar 2007 19:04:48 +0000 Subject: [PATCH] Controller de AlumnoInscripto basico. --- sercom/controllers.py | 2 + sercom/subcontrollers/__init__.py | 1 + .../alumno_inscripto/__init__.py | 124 ++++++++++++++++++ .../alumno_inscripto/templates/__init__.py | 0 .../alumno_inscripto/templates/list.kid | 43 ++++++ 5 files changed, 170 insertions(+) create mode 100644 sercom/subcontrollers/alumno_inscripto/__init__.py create mode 100644 sercom/subcontrollers/alumno_inscripto/templates/__init__.py create mode 100644 sercom/subcontrollers/alumno_inscripto/templates/list.kid diff --git a/sercom/controllers.py b/sercom/controllers.py index 3e96564..d1f2e18 100644 --- a/sercom/controllers.py +++ b/sercom/controllers.py @@ -105,6 +105,8 @@ class Root(controllers.RootController): docente_inscripto = DocenteInscriptoController() + alumno_inscripto = AlumnoInscriptoController() + correccion = CorreccionController() diff --git a/sercom/subcontrollers/__init__.py b/sercom/subcontrollers/__init__.py index 1fe1dc1..7be8ae8 100644 --- a/sercom/subcontrollers/__init__.py +++ b/sercom/subcontrollers/__init__.py @@ -7,3 +7,4 @@ from ejercicio import EjercicioController from docente_inscripto import DocenteInscriptoController from grupo import GrupoController from correccion import CorreccionController +from alumno_inscripto import AlumnoInscriptoController diff --git a/sercom/subcontrollers/alumno_inscripto/__init__.py b/sercom/subcontrollers/alumno_inscripto/__init__.py new file mode 100644 index 0000000..4b91be0 --- /dev/null +++ b/sercom/subcontrollers/alumno_inscripto/__init__.py @@ -0,0 +1,124 @@ +# vim: set et sw=4 sts=4 encoding=utf-8 foldmethod=marker : + +#{{{ Imports +import cherrypy +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 AlumnoInscripto, Correccion, Curso, Ejercicio, InstanciaDeEntrega +from sqlobject import * + +#}}} + +#{{{ Configuración +cls = AlumnoInscripto +name = 'alumno inscripto' +namepl = 'alumnos inscriptos' +#}}} + +#{{{ 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) +#}}} + +#{{{ Formulario +class AlumnoInscriptoForm(W.TableForm): + class Fields(W.WidgetsList): + linstancia = W.Label(label=_(u'Instancia de Entrega')) + lentregador = W.Label(label=_(u'Entregador')) + lentrega = W.Label(label=_(u'Entrega')) + lcorrector = W.Label(label=_(u'Corrector')) + nota = W.TextField(label=_(u'Nota'), validator=V.Number(not_empty=True, strip=True)) + observaciones = W.TextArea(label=_(u'Observaciones'), validator=V.UnicodeString(not_empty=False, strip=True)) + fields = Fields() + javascript = [W.JSSource("MochiKit.DOM.focusOnLoad('form_instancia');")] + +def get_cursos(): + return [(0, u'---')] + [(fk1.id, fk1.shortrepr()) for fk1 in Curso.select()] + +class AlumnoInscriptoFiltros(W.TableForm): + class Fields(W.WidgetsList): + cursoID = W.SingleSelectField(label=_(u'Curso'), options = get_cursos, validator = V.Int(not_empty=True)) + fields = Fields() + +filtro = AlumnoInscriptoFiltros() +form = AlumnoInscriptoForm() +#}}} + +#{{{ Controlador +class AlumnoInscriptoController(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__) + @paginate('records') + def list(self, cursoID = 0): + """List records in model""" + vfilter = dict(cursoID = cursoID) + if int(cursoID) == 0: + r = cls.select() + else: + r = cls.select(cls.q.cursoID == cursoID) + return dict(records=r, name=name, namepl=namepl, form=filtro, vfilter=vfilter) + + @expose(template='kid:%s.templates.edit' % __name__) + def edit(self, id, **kw): + """Edit record in model""" + r = validate_get(id) + r.linstancia = r.instancia.shortrepr() + r.lentregador = r.entregador.shortrepr() + r.lentrega = r.entrega.shortrepr() + r.lcorrector = r.corrector.shortrepr() + 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""" + from sqlobject import DateTimeCol + r = Correccion.get(id) + r.nota = kw['nota'] + r.observaciones = kw['observaciones'] + r.corregido = DateTimeCol.now() + 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.observaciones is None: + r.obs = '' + else: + r.obs = publish_parts(r.observaciones, writer_name='html')['html_body'] + return dict(name=name, namepl=namepl, record=r) + + @expose(template='kid:%s.templates.entregas' % __name__) + @paginate('records') + def entregas(self, id): + r = validate_get(id) + return dict(records=r.entregas, correccion = id) + +#}}} + diff --git a/sercom/subcontrollers/alumno_inscripto/templates/__init__.py b/sercom/subcontrollers/alumno_inscripto/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sercom/subcontrollers/alumno_inscripto/templates/list.kid b/sercom/subcontrollers/alumno_inscripto/templates/list.kid new file mode 100644 index 0000000..c5c72fd --- /dev/null +++ b/sercom/subcontrollers/alumno_inscripto/templates/list.kid @@ -0,0 +1,43 @@ + + + + + +list + + + +

Administración de Objetos

+ +
Filtros
+ + + + + + + + + + + + + + + + +
CursoAlumnoCondicional?TutorOperaciones
usuariofecha asignadofecha corregidoTutor + Ver +
+ +
+ ${page} + ${page} +
+ + + + + -- 2.43.0