core (stdui): fixed cancellation of ContactList forms
This commit is contained in:
parent
bd47ab8d3d
commit
44933e1a60
2 changed files with 13 additions and 3 deletions
|
|
@ -22,7 +22,6 @@ from sat.core.constants import Const as C
|
|||
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 @@ class ContactList(object):
|
|||
@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 @@ class ContactList(object):
|
|||
@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 @@ class ContactList(object):
|
|||
@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')
|
||||
|
|
|
|||
|
|
@ -913,6 +913,8 @@ class ListWidget(InputWidget):
|
|||
- 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
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue