From: Ricardo Markiewicz Date: Sun, 18 Mar 2007 17:43:12 +0000 (+0000) Subject: Muevo docente_inscripto dentro de Curso. X-Git-Tag: 0_9_0~38 X-Git-Url: https://git.llucax.com/software/sercom.git/commitdiff_plain/5c4e1768542d87e9bf39da8bc8aa0eef800b1b47 Muevo docente_inscripto dentro de Curso. --- diff --git a/sercom/controllers.py b/sercom/controllers.py index f809731..cc237b8 100644 --- a/sercom/controllers.py +++ b/sercom/controllers.py @@ -121,8 +121,6 @@ class Root(controllers.RootController): curso = CursoController() - docente_inscripto = DocenteInscriptoController() - correccion = CorreccionController() admin = identity.SecureObject(CatWalk(model), identity.has_permission('admin')) diff --git a/sercom/subcontrollers/__init__.py b/sercom/subcontrollers/__init__.py index eadd6a0..6bd2a35 100644 --- a/sercom/subcontrollers/__init__.py +++ b/sercom/subcontrollers/__init__.py @@ -2,7 +2,6 @@ from docente import DocenteController from alumno import AlumnoController from curso import CursoController from enunciado import EnunciadoController -from docente_inscripto import DocenteInscriptoController from correccion import CorreccionController from misentregas import MisEntregasController from miscorrecciones import MisCorreccionesController diff --git a/sercom/subcontrollers/curso/__init__.py b/sercom/subcontrollers/curso/__init__.py index 5380d43..20c2310 100644 --- a/sercom/subcontrollers/curso/__init__.py +++ b/sercom/subcontrollers/curso/__init__.py @@ -18,6 +18,7 @@ from sercom.widgets import * from alumno import AlumnoInscriptoController from grupo import GrupoController from ejercicio import EjercicioController +from docente import DocenteInscriptoController #}}} #{{{ Configuración @@ -165,6 +166,7 @@ class CursoController(controllers.Controller, identity.SecureResource): alumno = AlumnoInscriptoController() grupo = GrupoController() ejercicio = EjercicioController() + docente = DocenteInscriptoController() @expose() def default(self, tg_errors=None): diff --git a/sercom/subcontrollers/docente_inscripto/__init__.py b/sercom/subcontrollers/curso/docente/__init__.py similarity index 73% rename from sercom/subcontrollers/docente_inscripto/__init__.py rename to sercom/subcontrollers/curso/docente/__init__.py index 84aa179..2f94375 100644 --- a/sercom/subcontrollers/docente_inscripto/__init__.py +++ b/sercom/subcontrollers/curso/docente/__init__.py @@ -2,7 +2,7 @@ #{{{ Imports import cherrypy -from turbogears import controllers, expose, redirect +from turbogears import controllers, expose, redirect, url from turbogears import validate, flash, error_handler from turbogears import validators as V from turbogears import widgets as W @@ -34,14 +34,9 @@ def validate_new(data): def get_docentes(): return [(fk1.id, fk1.shortrepr()) for fk1 in Docente.select()] -def get_cursos(): - return [(fk1.id, fk1.shortrepr()) for fk1 in Curso.select()] - class DocenteInscriptoForm(W.TableForm): class Fields(W.WidgetsList): - curso = W.SingleSelectField(label=_(u'Curso'), options = get_cursos, - validator = V.Int(not_empty=True)) - + cursoID = W.HiddenField() docente = W.SingleSelectField(label=_(u'Docente'), options = get_docentes, validator = V.Int(not_empty=True)) @@ -63,44 +58,49 @@ class DocenteInscriptoController(controllers.Controller, identity.SecureResource @expose() def default(self, tg_errors=None): """handle non exist urls""" - raise redirect('list') + raise redirect(url('/curso/list')) @expose() def index(self): - raise redirect('list') + raise redirect(url('/curso/list')) + @expose(template='kid:%s.templates.list' % __name__) @paginate('records') - def list(self): + def list(self, cursoID): """List records in model""" - r = cls.select() - return dict(records=r, name=name, namepl=namepl) - - @expose() - def activate(self, id, activo): - """Save or create record to model""" - r = validate_get(id) - raise redirect('../../list') + r = cls.select(cls.q.cursoID==cursoID) + return dict(records=r, name=name, namepl=namepl, curso=Curso.get(cursoID)) @expose(template='kid:%s.templates.new' % __name__) - def new(self, **kw): + def new(self, cursoID, **kw): """Create new records in model""" - return dict(name=name, namepl=namepl, form=form, values=kw) + form.fields[0].attrs['value'] = cursoID + return dict(name=name, namepl=namepl, form=form, values=kw, curso=Curso.get(cursoID)) @validate(form=form) @error_handler(new) @expose() def create(self, **kw): """Save or create record to model""" - validate_new(kw) + r = validate_new(kw) flash(_(u'Se creó un nuevo %s.') % name) - raise redirect('list') + raise redirect(url('/curso/docente/list/%d' % r.curso.id)) @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) + class EmptyClass: + pass + values = EmptyClass() + values.id = r.id + values.docente = r.docente.id + values.corrige = r.corrige + values.observaciones = r.observaciones + values.curso = r.curso + values.cursoID = r.curso.id + return dict(name=name, namepl=namepl, record=values, form=form) @validate(form=form) @error_handler(edit) @@ -109,7 +109,7 @@ class DocenteInscriptoController(controllers.Controller, identity.SecureResource """Save or create record to model""" r = validate_set(id, kw) flash(_(u'El %s fue actualizado.') % name) - raise redirect('../list') + raise redirect(url('/curso/docente/list/%d' % r.curso.id)) @expose(template='kid:%s.templates.show' % __name__) def show(self,id, **kw): @@ -118,11 +118,11 @@ class DocenteInscriptoController(controllers.Controller, identity.SecureResource return dict(name=name, namepl=namepl, record=r) @expose() - def delete(self, id): + def delete(self, cursoID, id): """Destroy record in model""" r = validate_get(id) r.destroySelf() flash(_(u'El %s fue eliminado permanentemente.') % name) - raise redirect('../list') + raise redirect(url('/curso/docente/list/%s' % cursoID)) #}}} diff --git a/sercom/subcontrollers/docente_inscripto/templates/__init__.py b/sercom/subcontrollers/curso/docente/templates/__init__.py similarity index 100% rename from sercom/subcontrollers/docente_inscripto/templates/__init__.py rename to sercom/subcontrollers/curso/docente/templates/__init__.py diff --git a/sercom/subcontrollers/docente_inscripto/templates/edit.kid b/sercom/subcontrollers/curso/docente/templates/edit.kid similarity index 60% rename from sercom/subcontrollers/docente_inscripto/templates/edit.kid rename to sercom/subcontrollers/curso/docente/templates/edit.kid index f5c6034..4b6ba81 100644 --- a/sercom/subcontrollers/docente_inscripto/templates/edit.kid +++ b/sercom/subcontrollers/curso/docente/templates/edit.kid @@ -1,6 +1,6 @@ + py:extends="'../../../../templates/master.kid'"> edit @@ -9,12 +9,12 @@

Modificación de Objeto

-
Formulario

-Ver (cancela) | -Volver (cancela) +Ver (cancela) | +Volver (cancela) diff --git a/sercom/subcontrollers/docente_inscripto/templates/list.kid b/sercom/subcontrollers/curso/docente/templates/list.kid similarity index 66% rename from sercom/subcontrollers/docente_inscripto/templates/list.kid rename to sercom/subcontrollers/curso/docente/templates/list.kid index d416162..5a0d6f3 100644 --- a/sercom/subcontrollers/docente_inscripto/templates/list.kid +++ b/sercom/subcontrollers/curso/docente/templates/list.kid @@ -1,17 +1,16 @@ + py:extends="'../../../../templates/master.kid'"> list -

Administración de Objetos

+

Objetos del Curso Curso

- @@ -23,17 +22,17 @@ f.method = 'POST'; f.action = '${tg.url('/alumno/activate/%d/%d' % (record.id, int(not record.activo)))}'; f.submit(); return false;" py:attrs="checked=tg.checker(record.activo)" /> - - +
Curso Docente Corrige Observacionescurso docentes SINO observacionesEditar - EliminarEditar + Eliminar

-Agregar +Agregar | +Volver
+ py:extends="'../../../../templates/master.kid'"> new -

Crear Nuevo Objeto

+

Inscribir Docente en curso Curso

-

Formulario

+

Formulario


-
Cancelar +Cancelar diff --git a/sercom/subcontrollers/docente_inscripto/templates/show.kid b/sercom/subcontrollers/curso/docente/templates/show.kid similarity index 100% rename from sercom/subcontrollers/docente_inscripto/templates/show.kid rename to sercom/subcontrollers/curso/docente/templates/show.kid diff --git a/sercom/subcontrollers/curso/templates/list.kid b/sercom/subcontrollers/curso/templates/list.kid index faa27c0..5b35eb3 100644 --- a/sercom/subcontrollers/curso/templates/list.kid +++ b/sercom/subcontrollers/curso/templates/list.kid @@ -12,8 +12,8 @@ - - + + @@ -24,14 +24,14 @@ - - - + + + - - + + - +
#NumeroCuatrimestreNro# Cuat. Anio Descripcion Docentes
idnumerocuatrimestreanionumerocuatrimestreanio descripcionDocentesAlumnosDocentesAlumnos GruposEjercicioEjercicio Ver Editar Notas