comparison sat/plugins/plugin_exp_pubsub_schema.py @ 3271:abca25af06d7

plugin pubsub schema, tools (common/template xmlui): use a JID for publisher: - a JidWidget is used instead of text for publisher, nothing is set if publisher attribute doesn't exist - added missing JidWidget implementation in tools.common.template_xmlui
author Goffi <goffi@goffi.org>
date Mon, 18 May 2020 23:37:04 +0200
parents 6cf4bd6972c2
children 71761e9fb984
comparison
equal deleted inserted replaced
3270:0c3b7ee2628f 3271:abca25af06d7
308 for item_elt in items: 308 for item_elt in items:
309 for x_elt in item_elt.elements((data_form.NS_X_DATA, "x")): 309 for x_elt in item_elt.elements((data_form.NS_X_DATA, "x")):
310 form = data_form.Form.fromElement(x_elt) 310 form = data_form.Form.fromElement(x_elt)
311 if form_ns and form.formNamespace != form_ns: 311 if form_ns and form.formNamespace != form_ns:
312 continue 312 continue
313 prepend = [
314 ("label", "id"),
315 ("text", item_elt["id"], "id"),
316 ("label", "publisher"),
317 ]
318 try:
319 publisher = jid.JID(item_elt['publisher'])
320 except (KeyError, jid.InvalidFormat):
321 pass
322 else:
323 prepend.append(("jid", publisher, "publisher"))
313 xmlui = xml_tools.dataFormResult2XMLUI( 324 xmlui = xml_tools.dataFormResult2XMLUI(
314 form, 325 form,
315 schema_form, 326 schema_form,
316 # FIXME: conflicts with schema (i.e. if "id" or "publisher" already exists) 327 # FIXME: conflicts with schema (i.e. if "id" or "publisher" already exists)
317 # are not checked 328 # are not checked
318 prepend=( 329 prepend=prepend,
319 ("label", "id"),
320 ("text", item_elt["id"], "id"),
321 ("label", "publisher"),
322 ("text", item_elt.getAttribute("publisher", ""), "publisher"),
323 ),
324 filters=filters, 330 filters=filters,
325 read_only=False, 331 read_only=False,
326 ) 332 )
327 items_xmlui.append(xmlui) 333 items_xmlui.append(xmlui)
328 break 334 break