implement a get_purged() function in dataforms to send minimalist dataforms when we send a reply. fixes #4132
This commit is contained in:
parent
e941ef691c
commit
8b1746140e
|
@ -387,6 +387,22 @@ class SimpleDataForm(DataForm, DataRecord):
|
||||||
DataForm.__init__(self, type=type, title=title, instructions=instructions, extend=extend)
|
DataForm.__init__(self, type=type, title=title, instructions=instructions, extend=extend)
|
||||||
DataRecord.__init__(self, fields=fields, extend=self, associated=self)
|
DataRecord.__init__(self, fields=fields, extend=self, associated=self)
|
||||||
|
|
||||||
|
def get_purged(self):
|
||||||
|
c = SimpleDataForm(extend=self)
|
||||||
|
del c.title
|
||||||
|
c.instructions = ''
|
||||||
|
for f in c.iter_fields():
|
||||||
|
if f.required:
|
||||||
|
# Keep all required fields
|
||||||
|
continue
|
||||||
|
if (hasattr(f, 'value') and not f.value) or (hasattr(f, 'values') and \
|
||||||
|
len(f.values) == 0):
|
||||||
|
c.delChild(f)
|
||||||
|
else:
|
||||||
|
del f.label
|
||||||
|
del f.description
|
||||||
|
return c
|
||||||
|
|
||||||
class MultipleDataForm(DataForm):
|
class MultipleDataForm(DataForm):
|
||||||
def __init__(self, type=None, title=None, instructions=None, items=None, extend=None):
|
def __init__(self, type=None, title=None, instructions=None, items=None, extend=None):
|
||||||
DataForm.__init__(self, type=type, title=title, instructions=instructions, extend=extend)
|
DataForm.__init__(self, type=type, title=title, instructions=instructions, extend=extend)
|
||||||
|
|
|
@ -77,7 +77,7 @@ class SearchWindow:
|
||||||
if self.is_form:
|
if self.is_form:
|
||||||
self.data_form_widget.data_form.type = 'submit'
|
self.data_form_widget.data_form.type = 'submit'
|
||||||
gajim.connections[self.account].send_search_form(self.jid,
|
gajim.connections[self.account].send_search_form(self.jid,
|
||||||
self.data_form_widget.data_form, True)
|
self.data_form_widget.data_form.get_purged(), True)
|
||||||
else:
|
else:
|
||||||
infos = self.data_form_widget.get_infos()
|
infos = self.data_form_widget.get_infos()
|
||||||
if infos.has_key('instructions'):
|
if infos.has_key('instructions'):
|
||||||
|
|
Loading…
Reference in New Issue