X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/134cb2d61093217000ace564978667f5a4828c5a..7ca12e30972ce06c083afba89f678555b784b2e3:/sercom/subcontrollers/curso/__init__.py?ds=sidebyside diff --git a/sercom/subcontrollers/curso/__init__.py b/sercom/subcontrollers/curso/__init__.py index de16547..ca216fe 100644 --- a/sercom/subcontrollers/curso/__init__.py +++ b/sercom/subcontrollers/curso/__init__.py @@ -10,7 +10,10 @@ 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 Curso +from sercom.model import Curso, Ejercicio, Alumno, Docente, Grupo, DocenteInscripto +from curso_alumno import * +from sqlobject import * +from sercom.widgets import * #}}} #{{{ Configuración @@ -19,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