X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/5810ce115f54f6890d63e0ab8bd60dde726e4cb2..5a5fd7200d429896765a5043908441683e5f06ea:/sercom/subcontrollers/curso/__init__.py?ds=sidebyside diff --git a/sercom/subcontrollers/curso/__init__.py b/sercom/subcontrollers/curso/__init__.py index 29e4bca..ae1ed7a 100644 --- a/sercom/subcontrollers/curso/__init__.py +++ b/sercom/subcontrollers/curso/__init__.py @@ -10,7 +10,11 @@ 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 sqlobject.dberrors import * +from sercom.widgets import * #}}} #{{{ Configuración @@ -19,6 +23,85 @@ 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 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_alumnos'); + for (i=0; i