# HG changeset patch # User Goffi # Date 1473628651 -7200 # Node ID c2fdee1bd908b654a9ecc0b64a852f8677fcc46f # Parent 58f0c96d60e55942ecc25ef4faadd8058ea1e260 core (stdui): fixed cancellation of ContactList forms diff -r 58f0c96d60e5 -r c2fdee1bd908 src/stdui/ui_contact_list.py --- a/src/stdui/ui_contact_list.py Sun Sep 11 11:03:25 2016 +0200 +++ b/src/stdui/ui_contact_list.py Sun Sep 11 23:17:31 2016 +0200 @@ -22,7 +22,6 @@ from sat.tools import xml_tools from twisted.words.protocols.jabber import jid from xml.dom.minidom import Element -import re class ContactList(object): @@ -209,9 +208,14 @@ @param profile: %(doc_profile)s @return dict """ + if C.bool(data.get('cancelled', 'false')): + return {} contact = data[xml_tools.formEscape('contact_jid')] - cb = lambda data, profile: self._deleteContact(jid.JID(contact), profile) - delete_id = self.host.registerCallback(cb, with_data=True, one_shot=True) + def delete_cb(data, profile): + if not C.bool(data.get('cancelled', 'false')): + self._deleteContact(jid.JID(contact), profile) + return {} + delete_id = self.host.registerCallback(delete_cb, with_data=True, one_shot=True) form_ui = xml_tools.XMLUI("form", title=D_("Delete contact"), submit_id=delete_id) form_ui.addText(D_("Are you sure you want to remove %s from your contact list?") % contact) return {'xmlui': form_ui.toXml()} @@ -223,6 +227,8 @@ @param profile: %(doc_profile)s @return dict """ + if C.bool(data.get('cancelled', 'false')): + return {} contact_jid_s = data[xml_tools.formEscape('contact_jid')] try: contact_jid = jid.JID(contact_jid_s) @@ -244,6 +250,8 @@ @param profile: %(doc_profile)s @return dict """ + if C.bool(data.get('cancelled', 'false')): + return {} contact_jid = jid.JID(data[xml_tools.formEscape('contact_jid')]) # TODO: replace '\t' by a constant (see tools.xmlui.XMLUI.onFormSubmitted) groups = data[xml_tools.formEscape('groups_list')].split('\t') diff -r 58f0c96d60e5 -r c2fdee1bd908 src/tools/xml_tools.py --- a/src/tools/xml_tools.py Sun Sep 11 11:03:25 2016 +0200 +++ b/src/tools/xml_tools.py Sun Sep 11 23:17:31 2016 +0200 @@ -913,6 +913,8 @@ - a tuple with a couple of string (value,label) if the label and the value differ @param selected (list[string]): list of the selected values @param styles (iterable[string]): flags to set the behaviour of the list + can be: + - multi: mutliple selection is allowed @param name (string) @param parent """