From 2c23f36223624514f3ad84a7c629792a27e74a68 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 27 Feb 2007 04:47:12 +0000 Subject: [PATCH 1/1] hago ajaxoso el agregado de alumnos a la lista por ahora usa el metodo /grupos/de_curso que no deberia estar ahi. calculo que lo movere a /curso/existe_alumno o algo asi, despues veo --- sercom/static/images/loading.gif | Bin 0 -> 1765 bytes sercom/subcontrollers/grupo/__init__.py | 6 ++++- sercom/widgets.py | 33 ++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 sercom/static/images/loading.gif diff --git a/sercom/static/images/loading.gif b/sercom/static/images/loading.gif new file mode 100644 index 0000000000000000000000000000000000000000..31b8cb070582ff26555d41633e5548765d40e40a GIT binary patch literal 1765 zcmaKseM}R18pp@N_KjLvm}${sDTOT+N*UYkv`k;Og)^-2jB8xac%ElGV~l5vag8yaG3V*6_aC|M zpHH5A^U3o`9)AmIYmCVt8T1l@-oAYcLC}pGH}>t@7mY^UZnw|p%VaW#4_^O^78U*Hv8nslc!IgE-WnU-o3lCvojKjoIQK?+O=yq zjw=+3@$vEF$B&1@;qBYE-@kvKWm&0IIyg9Z@ZiB@GI{FMDUu|`V)2O+C-(2(UshJe z=kp&udi3JOi?Ok>TrT(WfsE-uc`&)>Uu@7Aqb&!0cPef##dZQD+sJUKf%+t$|B-QC^S*B6h+ zJsyw4;kbD5;^^q8$z*!`_;GD*?Vde*dV6~f27_9yo}8Qvg+e7ICA)U*8WjnM5L)nwlysEIe@F zfKI1_Vc2G~jf{*KjYgqRxOwwtjYdOJR63pBxpU{coBx!`w?(05YOR;(Y&IFuf@SZf zmH%Gl**cUS(R?{HGN|#lkec@4(V>LKpNM5O79;v@0cnp7BsB4_G(;*k);1g)Fb-vs z!%*eF3Ps{~4TksK?*&7GU+shdonshP)#`ed5tdii8Ucn|8FA67kLwzM6?I}Xk6)r@ zF&N$t6%>_@L(V2AD3r)&%W@)a7L3N?#tLdV~8D=TXRYbLVLkyy^{4C zR4n8u`?P3XeYpB_9TV(W8<4|PFj5=N`3pP0VN8seU&R3{9cb;EgK!KKwmHv`B&cb> zI0qv@86xKJ_@AK`nQ)GBUx1pF-7DD!p6`#K(PU{6;dn!HRP_T*=z0u&6+v%|;;6=! z)Rb&5#7@%?Z`o3SzxV(s5|<9~BL*G|c?GTfV(D^8D$Up;8wa}(#M`||BBZqgAqP8H z->CxqvLpw|zSsZ^rLKH1lLDpynx~BQKy5MSnNO7dYq@B`o5ye(u1KC^aOd~5|C0)W zvRYBN0l^rzSMT)@c6Y-amK3S7uQVmU>-)WXDY}UdbWM7-EL55HvrwZ_P_ts=`cx>$ z5LJP+igbE56n8jiN@udM$RC(=?*GnV=1q=uAyRJLq*bvZ0t zit&Gn;n;9Ot&=ygkf?4;LTL$4V;uz1s781=fX7mN_`0YN$wZb>Clq{O!HTB^B@bpxEkcvb*eBl!b80C*lzv zTbGu>kOssISrNOw#hpW)IP0$nBEV{%;<}Q=EXDz!!7c zpWs+4P9g}2u{35T;keJ|WOOVJH``&FSZ 0: msg = alumno[0].alumno.nombre + else: + error = True except Exception, (inst): msg = u"""Se ha producido un error inesperado al buscar el registro:\n %s""" % str(inst) - return dict(msg=msg) + error = True + return dict(msg=msg, error=error) #}}} diff --git a/sercom/widgets.py b/sercom/widgets.py index 309adc0..218fb3a 100644 --- a/sercom/widgets.py +++ b/sercom/widgets.py @@ -20,10 +20,31 @@ class CustomTextField(widgets.TextField): ''' AlumnoMultiSelectAjax = ''' + + function _on_alumno_get_result(lista, results) + { + load.style.visibility = 'hidden'; + if (results.error) { + alert(results.msg); + return; + } + MochiKit.DOM.appendChildNodes(lista, OPTION(results.msg)); + } + + function _on_alumno_get_error(results) + { + alert(results) + load.style.visibility = 'hidden'; + } + function agregar_a_la_lista(texto, lista) { + load = MochiKit.DOM.getElement('loading'); + load.style.visibility = 'visible'; t = MochiKit.DOM.getElement(texto); - MochiKit.DOM.appendChildNodes(lista, OPTION(t.value)); + url = "/grupo/get_inscripto?cursoid=1&padron="+t.value; + var d = loadJSONDoc(url); + d.addCallbacks(partial(_on_alumno_get_result, lista), _on_alumno_get_error); t.value = ""; } @@ -31,6 +52,12 @@ AlumnoMultiSelectAjax = ''' { l = MochiKit.DOM.getElement(lista); if (l.selectedIndex < 0) return; + + /* caso especial, 1 solo item */ + if (l.options.length == 1) { + l.options.length = 0 + return; + } for (i=l.selectedIndex; i - + + -- 2.43.0