diff --git a/sat/plugins/plugin_exp_pubsub_schema.py b/sat/plugins/plugin_exp_pubsub_schema.py index ce3fe6f2..51875f84 100644 --- a/sat/plugins/plugin_exp_pubsub_schema.py +++ b/sat/plugins/plugin_exp_pubsub_schema.py @@ -310,17 +310,23 @@ class PubsubSchema(object): form = data_form.Form.fromElement(x_elt) if form_ns and form.formNamespace != form_ns: continue + prepend = [ + ("label", "id"), + ("text", item_elt["id"], "id"), + ("label", "publisher"), + ] + try: + publisher = jid.JID(item_elt['publisher']) + except (KeyError, jid.InvalidFormat): + pass + else: + prepend.append(("jid", publisher, "publisher")) xmlui = xml_tools.dataFormResult2XMLUI( form, schema_form, # FIXME: conflicts with schema (i.e. if "id" or "publisher" already exists) # are not checked - prepend=( - ("label", "id"), - ("text", item_elt["id"], "id"), - ("label", "publisher"), - ("text", item_elt.getAttribute("publisher", ""), "publisher"), - ), + prepend=prepend, filters=filters, read_only=False, ) diff --git a/sat/tools/common/template_xmlui.py b/sat/tools/common/template_xmlui.py index acfcf3ee..0e38c6d1 100644 --- a/sat/tools/common/template_xmlui.py +++ b/sat/tools/common/template_xmlui.py @@ -22,11 +22,10 @@ XMLUI classes from this modules can then be iterated to create the template """ -from sat.core.log import getLogger - -log = getLogger(__name__) -from sat_frontends.tools import xmlui from functools import partial +from sat.core.log import getLogger +from sat_frontends.tools import xmlui +from sat_frontends.tools import jid try: from jinja2 import Markup as safe except ImportError: @@ -35,6 +34,9 @@ except ImportError: safe = lambda x: x +log = getLogger(__name__) + + ## Widgets ## @@ -119,6 +121,13 @@ class TextWidget(xmlui.TextWidget, ValueWidget): type = "text" +class JidWidget(xmlui.JidWidget, ValueWidget): + type = "jid" + + def __init__(self, xmlui_parent, value): + self.value = jid.JID(value) + + class LabelWidget(xmlui.LabelWidget, ValueWidget): type = "label" @@ -137,7 +146,6 @@ class StringWidget(xmlui.StringWidget, InputWidget): class JidInputWidget(xmlui.JidInputWidget, StringWidget): type = "jid" - class TextBoxWidget(xmlui.TextWidget, InputWidget): type = "textbox"