diff options
author | flavio <fdanesse@gmail.com> | 2013-08-23 15:23:40 (GMT) |
---|---|---|
committer | flavio <fdanesse@gmail.com> | 2013-08-23 15:23:40 (GMT) |
commit | 6c69805d4eb400fcdb96a23fe6ea07e81c84a05a (patch) | |
tree | 6744e010433adf3c2ae457d3c24f2deb06f2af8e /CeibalEncuesta | |
parent | 1fe91c827126119f5fb952c3b0e8e406d74b624b (diff) |
issue 4527 - Corrección en persistencia para un caso particular de checkbox
Diffstat (limited to 'CeibalEncuesta')
-rw-r--r-- | CeibalEncuesta/gtk2/CeibalEncuesta/CeibalEncuesta.py | 6 | ||||
-rw-r--r-- | CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py | 31 |
2 files changed, 20 insertions, 17 deletions
diff --git a/CeibalEncuesta/gtk2/CeibalEncuesta/CeibalEncuesta.py b/CeibalEncuesta/gtk2/CeibalEncuesta/CeibalEncuesta.py index be0d37d..5448cdf 100644 --- a/CeibalEncuesta/gtk2/CeibalEncuesta/CeibalEncuesta.py +++ b/CeibalEncuesta/gtk2/CeibalEncuesta/CeibalEncuesta.py @@ -296,7 +296,7 @@ class CeibalEncuesta(gtk.Window): self.out_dict[encuestado][indice_grupo]["name"] = grupo_name self.out_dict[encuestado][indice_grupo]["fields"][indice_pregunta] = dict_pregunta - + def save_text(self): self.__save_json() @@ -330,7 +330,7 @@ class CeibalEncuesta(gtk.Window): self.out_dict[encuestado][indice_grupo]["name"] = grupo_name self.out_dict[encuestado][indice_grupo]["fields"][indice_pregunta] = dict_pregunta - + self.__save_json() def __new_selection(self, widget, encuestado): @@ -747,7 +747,7 @@ class CeibalEncuesta(gtk.Window): "poll_id": poll_id, "pollster_id": pollster_id, "pollster_username": pollster_username} - + self.poll_id = getattr(self, "poll_id", poll_id) self.path = os.path.join(os.path.dirname(self.path), "%s.encuesta" % self.poll_id) diff --git a/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py b/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py index c58fd8a..3412933 100644 --- a/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py +++ b/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py @@ -382,7 +382,7 @@ class Panel(gtk.Paned): dict_pregunta = dict(pregunta.pregunta.copy()) - if activan: dict_pregunta["default"] = list(activan) # list(pregunta.widget_obtions.default) + if activan: dict_pregunta["default"] = list(activan) if text: dict_pregunta["options"][id_opcion]["newtext"] = text self.emit("text_and_change", encuestado, widget_grupo, pregunta, dict_pregunta) @@ -399,7 +399,8 @@ class Panel(gtk.Paned): grupo_name = widget_grupo.grupo["name"] dict_pregunta = pregunta.pregunta.copy() - if activan: dict_pregunta["default"] = list(activan) # list(pregunta.widget_obtions.default) + + if activan: dict_pregunta["default"] = list(activan) indice_grupo = widget_grupo.indice indice_pregunta = pregunta.indice @@ -425,11 +426,11 @@ class Panel(gtk.Paned): preguntas = grupo.box_preguntas.get_children() for preg in preguntas: - opciones_activas = opciones_activas + preg.widget_obtions.get_active_options() - + opciones_activas.extend(preg.widget_obtions.get_active_options()) + almacenar = False # flag preguntas_a_checkear = [] # preguntas posteriores a la modificada - + ### Obtener preguntas posteriores a la que ha lanzado "new". for grupo in grupos[grupos.index(widget_grupo):-1]: @@ -612,7 +613,7 @@ class Panel(gtk.Paned): for grupo in grupos[:-1]: preguntas = grupo.box_preguntas.get_children() for preg in preguntas: - opciones_activas = opciones_activas + preg.widget_obtions.get_active_options() + opciones_activas.extend(preg.widget_obtions.get_active_options()) ### Actualiza Visibilidad. preguntas_para_activar = [] @@ -624,7 +625,7 @@ class Panel(gtk.Paned): for preg in preguntas: contestada = preg.widget_obtions.get_active_options() con_dependencias = preg.pregunta.get("dependence", False) - + if contestada or not con_dependencias: preguntas_para_activar.append(preg) @@ -1637,7 +1638,7 @@ class Widget_MultipleCheckBox(gtk.VButtonBox): options = self.get_children() - activan = [] + activan = self.get_active_options() if widget.none and widget.get_active(): ### Desactivar todas las opciones que no sean "ninguna." @@ -1646,9 +1647,10 @@ class Widget_MultipleCheckBox(gtk.VButtonBox): if child == widget: activan = [child.indice] - continue - - child.set_active(False) + + else: + if child.indice in activan: activan.remove(child.indice) + child.set_active(False) elif not widget.none and widget.get_active(): ### Desactivar la opción "ninguna." @@ -1656,12 +1658,13 @@ class Widget_MultipleCheckBox(gtk.VButtonBox): child = child.get_button() if child.none and child.get_active(): + if child.indice in activan: activan.remove(child.indice) child.set_active(False) - + else: if child.get_active(): - activan.append(child.indice) - + if not child.indice in activan: activan.append(child.indice) + self.emit("new", activan) def update(self, dict): |