Author: asterix Date: 2008-07-29 17:27:00 +0200 (Tue, 29 Jul 2008) New Revision: 10074
Modified: trunk/src/common/dataforms.py trunk/src/search_window.py Log: implement a get_purged() function in dataforms to send minimalist dataforms when we send a reply. fixes #4132
Modified: trunk/src/common/dataforms.py =================================================================== --- trunk/src/common/dataforms.py 2008-07-29 14:12:06 UTC (rev 10073) +++ trunk/src/common/dataforms.py 2008-07-29 15:27:00 UTC (rev 10074) @@ -386,6 +386,22 @@ def __init__(self, type=None, title=None, instructions=None, fields=None, extend=None): DataForm.__init__(self, type=type, title=title, instructions=instructions, extend=extend) 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): def __init__(self, type=None, title=None, instructions=None, items=None, extend=None):
Modified: trunk/src/search_window.py =================================================================== --- trunk/src/search_window.py 2008-07-29 14:12:06 UTC (rev 10073) +++ trunk/src/search_window.py 2008-07-29 15:27:00 UTC (rev 10074) @@ -77,7 +77,7 @@ if self.is_form: self.data_form_widget.data_form.type = 'submit' 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: infos = self.data_form_widget.get_infos() if infos.has_key('instructions'):