From: Ricardo Markiewicz Date: Sun, 4 Mar 2007 21:40:22 +0000 (+0000) Subject: curso: add docentes X-Git-Tag: 0_9~131 X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/commitdiff_plain/0c099354041335dc9a9248b7b791656e24b53138?ds=sidebyside curso: add docentes * distintos comportamiento de las listas docentes en crear y editar cursos. --- diff --git a/sercom/subcontrollers/curso/__init__.py b/sercom/subcontrollers/curso/__init__.py index ae1ed7a..0e488dd 100644 --- a/sercom/subcontrollers/curso/__init__.py +++ b/sercom/subcontrollers/curso/__init__.py @@ -24,20 +24,6 @@ namepl = name + 's' #}}} ajax = u""" - function makeOption(option) { - return OPTION({"value": option.value}, option.text); - } - - function moveOption( fromSelect, toSelect) { - // add 'selected' nodes toSelect - appendChildNodes(toSelect, - map( makeOption,ifilter(itemgetter('selected'), $(fromSelect).options))); - // remove the 'selected' fromSelect - replaceChildNodes(fromSelect, - list(ifilterfalse(itemgetter('selected'), $(fromSelect).options)) - ); - } - function alumnos_agregar_a_la_lista(texto, lista) { t = MochiKit.DOM.getElement(texto); @@ -81,7 +67,7 @@ ajax = u""" var d = loadJSONDoc(url); d.addCallbacks(procesar, err); } - + function onsubmit() { /* TODO : Validar datos y evitar el submit si no esta completo */ @@ -147,9 +133,9 @@ class CursoForm(W.TableForm): options=get_docentes, validator=V.Int(not_empty=True)) addDocente = W.Button(default='Asignar', label='', - attrs=dict( onclick='moveOption("form_docentes","form_docentes_curso")')) + attrs=dict( onclick='mover("form_docentes","form_docentes_curso")')) remDocente = W.Button(default='Remover', label='', - attrs=dict( onclick='moveOption("form_docentes_curso","form_docentes")')) + attrs=dict( onclick='remover("form_docentes_curso","form_docentes")')) docentes_curso = W.MultipleSelectField(name="docentes_curso", label=_(u'Docentes del curso'), attrs=dict(style='width:300px'), @@ -242,7 +228,7 @@ class CursoController(controllers.Controller, identity.SecureResource): values.cursoID = r.id values.descripcion = r.descripcion # cargo la lista con los docentes asignados al curso - values.docentes_curso = [{"id":d.docente.id, "label":d.docente.nombre} for d in DocenteInscripto.selectBy(curso=r.id)] + values.docentes_curso = [{"id":d.docente.id, "label":d.docente.shortrepr()} for d in DocenteInscripto.selectBy(curso=r.id)] values.alumnos_inscriptos = [{"id":a.alumno.id, "label":a.alumno.nombre} for a in AlumnoInscripto.selectBy(curso=r.id)] return dict(name=name, namepl=namepl, record=values, form=form) diff --git a/sercom/subcontrollers/curso/templates/edit.kid b/sercom/subcontrollers/curso/templates/edit.kid index e4e6811..0a13da4 100644 --- a/sercom/subcontrollers/curso/templates/edit.kid +++ b/sercom/subcontrollers/curso/templates/edit.kid @@ -18,6 +18,28 @@ } MochiKit.DOM.addLoadEvent(init_data) + + function makeOption(option) { + return OPTION({"value": option.value}, option.text); + } + + function moveOption( fromSelect, toSelect) { + // add 'selected' nodes toSelect + appendChildNodes(toSelect, + map( makeOption,ifilter(itemgetter('selected'), $(fromSelect).options))); + // remove the 'selected' fromSelect + // replaceChildNodes(fromSelect, + // list(ifilterfalse(itemgetter('selected'), $(fromSelect).options))); + } + + function mover( src, dest ) { + moveOption(src, dest) + } + + function remover (src, dest) { + replaceChildNodes(src,list(ifilterfalse(itemgetter('selected'), $(src).options))) + } + diff --git a/sercom/subcontrollers/curso/templates/new.kid b/sercom/subcontrollers/curso/templates/new.kid index 96de154..c815316 100644 --- a/sercom/subcontrollers/curso/templates/new.kid +++ b/sercom/subcontrollers/curso/templates/new.kid @@ -2,6 +2,30 @@ + + new