plugins schema, tickets, merge_requests: use serialised data for extra dict + some cosmetic changes
This commit is contained in:
parent
0f97a75f6f
commit
481ce4c379
1 changed files with 94 additions and 72 deletions
|
|
@ -30,14 +30,14 @@ log = getLogger(__name__)
|
|||
NS_TICKETS = "org.salut-a-toi.tickets:0"
|
||||
|
||||
PLUGIN_INFO = {
|
||||
C.PI_NAME: _("Tickets management"),
|
||||
C.PI_IMPORT_NAME: "TICKETS",
|
||||
C.PI_TYPE: "EXP",
|
||||
C.PI_NAME: _(u"Tickets management"),
|
||||
C.PI_IMPORT_NAME: u"TICKETS",
|
||||
C.PI_TYPE: u"EXP",
|
||||
C.PI_PROTOCOLS: [],
|
||||
C.PI_DEPENDENCIES: ["XEP-0060", "PUBSUB_SCHEMA", "XEP-0277", "IDENTITY"],
|
||||
C.PI_MAIN: "Tickets",
|
||||
C.PI_HANDLER: "no",
|
||||
C.PI_DESCRIPTION: _("""Tickets management plugin"""),
|
||||
C.PI_DEPENDENCIES: [u"XEP-0060", u"PUBSUB_SCHEMA", u"XEP-0277", u"IDENTITY"],
|
||||
C.PI_MAIN: u"Tickets",
|
||||
C.PI_HANDLER: u"no",
|
||||
C.PI_DESCRIPTION: _(u"""Tickets management plugin"""),
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -45,15 +45,15 @@ class Tickets(object):
|
|||
def __init__(self, host):
|
||||
log.info(_(u"Tickets plugin initialization"))
|
||||
self.host = host
|
||||
host.registerNamespace("tickets", NS_TICKETS)
|
||||
self._p = self.host.plugins["XEP-0060"]
|
||||
self._s = self.host.plugins["PUBSUB_SCHEMA"]
|
||||
self._m = self.host.plugins["XEP-0277"]
|
||||
host.registerNamespace(u"tickets", NS_TICKETS)
|
||||
self._p = self.host.plugins[u"XEP-0060"]
|
||||
self._s = self.host.plugins[u"PUBSUB_SCHEMA"]
|
||||
self._m = self.host.plugins[u"XEP-0277"]
|
||||
host.bridge.addMethod(
|
||||
"ticketsGet",
|
||||
".plugin",
|
||||
in_sign="ssiassa{ss}s",
|
||||
out_sign="(asa{ss})",
|
||||
u"ticketsGet",
|
||||
u".plugin",
|
||||
in_sign=u"ssiassa{ss}s",
|
||||
out_sign=u"(asa{ss})",
|
||||
method=utils.partial(
|
||||
self._s._get,
|
||||
default_node=NS_TICKETS,
|
||||
|
|
@ -69,7 +69,7 @@ class Tickets(object):
|
|||
host.bridge.addMethod(
|
||||
"ticketSet",
|
||||
".plugin",
|
||||
in_sign="ssa{sas}ssa{ss}s",
|
||||
in_sign="ssa{sas}ssss",
|
||||
out_sign="s",
|
||||
method=self._set,
|
||||
async=True,
|
||||
|
|
@ -83,7 +83,7 @@ class Tickets(object):
|
|||
async=True,
|
||||
)
|
||||
|
||||
def _set(self, service, node, values, schema=None, item_id=None, extra=None,
|
||||
def _set(self, service, node, values, schema=None, item_id=None, extra=u'',
|
||||
profile_key=C.PROF_KEY_NONE):
|
||||
client, service, node, schema, item_id, extra = self._s.prepareBridgeSet(
|
||||
service, node, schema, item_id, extra, profile_key
|
||||
|
|
@ -102,6 +102,7 @@ class Tickets(object):
|
|||
@param node(unicode, None): Pubsub node to use
|
||||
None to use default tickets node
|
||||
@param values(dict[key(unicode), [iterable[object]|object]]): values of the ticket
|
||||
|
||||
if value is not iterable, it will be put in a list
|
||||
'created' and 'updated' will be forced to current time:
|
||||
- 'created' is set if item_id is None, i.e. if it's a new ticket
|
||||
|
|
@ -114,6 +115,7 @@ class Tickets(object):
|
|||
"""
|
||||
if not node:
|
||||
node = NS_TICKETS
|
||||
|
||||
if not item_id:
|
||||
comments_service = yield self._m.getCommentsService(client, service)
|
||||
|
||||
|
|
@ -132,12 +134,13 @@ class Tickets(object):
|
|||
self._p.OPT_PUBLISH_MODEL: self._p.ACCESS_OPEN,
|
||||
}
|
||||
yield self._p.createNode(client, comments_service, comments_node, options)
|
||||
values["comments_uri"] = uri.buildXMPPUri(
|
||||
values[u"comments_uri"] = uri.buildXMPPUri(
|
||||
u"pubsub",
|
||||
subtype="microblog",
|
||||
path=comments_service.full(),
|
||||
node=comments_node,
|
||||
)
|
||||
|
||||
item_id = yield self._s.set(
|
||||
client, service, node, values, schema, item_id, extra, deserialise, form_ns
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue