X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/a0fbd7a909e29af5349e41664feeb7dfb128304e..4d05c0593fa8b0627b6cca3e3367d5a15d92d1fa:/sercom/subcontrollers/curso/__init__.py diff --git a/sercom/subcontrollers/curso/__init__.py b/sercom/subcontrollers/curso/__init__.py index 8b3c082..ca216fe 100644 --- a/sercom/subcontrollers/curso/__init__.py +++ b/sercom/subcontrollers/curso/__init__.py @@ -12,7 +12,8 @@ from docutils.core import publish_parts from sercom.subcontrollers import validate as val from sercom.model import Curso, Ejercicio, Alumno, Docente, Grupo, DocenteInscripto from curso_alumno import * - +from sqlobject import * +from sercom.widgets import * #}}} #{{{ Configuración @@ -21,6 +22,88 @@ name = 'curso' 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); + + url = "/alumno/get_alumno?padron="+t.value; + t.value = ""; + return url; + } + + function err (err) + { + alert("The metadata for MochiKit.Async could not be fetched :("); + } + + function procesar(result) + { + l = MochiKit.DOM.getElement('form_responsable_info'); + if (result.error) + l.innerHTML = result.msg; + else + l.innerHTML = result.msg.value; + } + + function buscar_alumno() + { + /* Obtengo el curso */ + l = MochiKit.DOM.getElement('form_cursoID'); + cursoid = l.options[l.selectedIndex].value; + if (cursoid <= 0) { + alert('Debe seleccionar un curso'); + return; + } + /* Obtengo el padron ingresado */ + p = MochiKit.DOM.getElement('form_responsable'); + padron = p.value; + if (padron == '') { + alert('Debe ingresar el padrón del alumno responsable'); + return; + } + url = "/grupo/get_inscripto?cursoid="+cursoid+'&padron='+padron; + var d = loadJSONDoc(url); + d.addCallbacks(procesar, err); + } + + function prepare() + { + connect('form_responsable', 'onblur', buscar_alumno); + } + + function onsubmit() + { + /* TODO : Validar datos y evitar el submit si no esta completo */ + + /* Selecciono todos los miembros si no, no llegan al controllere*/ + l = MochiKit.DOM.getElement('form_miembros'); + for (i=0; i