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
This commit is contained in:
Goffi 2020-05-18 23:37:04 +02:00
commit 9780bd3480

View file

@ -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"