diff sat/plugins/plugin_misc_tickets.py @ 2959:989b622faff6

plugins schema, tickets, merge_requests: use serialised data for extra dict + some cosmetic changes
author Goffi <goffi@goffi.org>
date Fri, 14 Jun 2019 12:37:34 +0200
parents f18d8315929e
children ab2696e34d29
line wrap: on
line diff
--- a/sat/plugins/plugin_misc_tickets.py	Wed Jun 12 09:11:28 2019 +0200
+++ b/sat/plugins/plugin_misc_tickets.py	Fri Jun 14 12:37:34 2019 +0200
@@ -30,14 +30,14 @@
 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 @@
     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 @@
         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 @@
             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 @@
         @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 @@
         """
         if not node:
             node = NS_TICKETS
+
         if not item_id:
             comments_service = yield self._m.getCommentsService(client, service)
 
@@ -132,12 +134,13 @@
                 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
         )