plugin XEP-0346: "Form Discovery and Publishing" implementation:
this implementation replaces the former non standard node schema, and works in a similar way (the schema is put in a separated node instead of a special field, thus it will now work with most/all PubSub services, and not only SàT PubSub). The implementation has been done in a way that nothing should be changed in frontends (bridge methods names and arguments stay the same). The nodes are modified, but if values are taken from backend, it's automatically adapted.
This commit is contained in:
parent
df6f87d69a
commit
968ee50d31
1 changed files with 158 additions and 134 deletions
|
|
@ -29,14 +29,14 @@ from sat.core.log import getLogger
|
|||
|
||||
log = getLogger(__name__)
|
||||
|
||||
NS_MERGE_REQUESTS = 'org.salut-a-toi.merge_requests:0'
|
||||
APP_NS_MERGE_REQUESTS = 'org.salut-a-toi.merge_requests:0'
|
||||
|
||||
PLUGIN_INFO = {
|
||||
C.PI_NAME: _("Merge requests management"),
|
||||
C.PI_IMPORT_NAME: "MERGE_REQUESTS",
|
||||
C.PI_TYPE: "EXP",
|
||||
C.PI_PROTOCOLS: [],
|
||||
C.PI_DEPENDENCIES: ["XEP-0060", "PUBSUB_SCHEMA", "TICKETS", "TEXT_SYNTAXES"],
|
||||
C.PI_DEPENDENCIES: ["XEP-0060", "XEP-0346", "TICKETS", "TEXT_SYNTAXES"],
|
||||
C.PI_MAIN: "MergeRequests",
|
||||
C.PI_HANDLER: "no",
|
||||
C.PI_DESCRIPTION: _("""Merge requests management plugin""")
|
||||
|
|
@ -68,9 +68,10 @@ class MergeRequests(object):
|
|||
def __init__(self, host):
|
||||
log.info(_("Merge requests plugin initialization"))
|
||||
self.host = host
|
||||
host.registerNamespace('merge_requests', NS_MERGE_REQUESTS)
|
||||
self._s = self.host.plugins["XEP-0346"]
|
||||
self.namespace = self._s.getSubmittedNS(APP_NS_MERGE_REQUESTS)
|
||||
host.registerNamespace('merge_requests', self.namespace)
|
||||
self._p = self.host.plugins["XEP-0060"]
|
||||
self._s = self.host.plugins["PUBSUB_SCHEMA"]
|
||||
self._t = self.host.plugins["TICKETS"]
|
||||
self._handlers = {}
|
||||
self._handlers_list = [] # handlers sorted by priority
|
||||
|
|
@ -89,7 +90,7 @@ class MergeRequests(object):
|
|||
method=lambda service, nodeIdentifier, profile_key:
|
||||
self._s._getUISchema(service,
|
||||
nodeIdentifier,
|
||||
default_node=NS_MERGE_REQUESTS,
|
||||
default_node=self.namespace,
|
||||
profile_key=profile_key),
|
||||
async_=True)
|
||||
host.bridge.addMethod("mergeRequestParseData", ".plugin",
|
||||
|
|
@ -172,7 +173,7 @@ class MergeRequests(object):
|
|||
- list of parsed request data (if extra['parse'] is set, else empty list)
|
||||
"""
|
||||
if not node:
|
||||
node = NS_MERGE_REQUESTS
|
||||
node = self.namespace
|
||||
if extra is None:
|
||||
extra = {}
|
||||
# XXX: Q&D way to get list for labels when displaying them, but text when we
|
||||
|
|
@ -181,17 +182,19 @@ class MergeRequests(object):
|
|||
filters = {'labels': self._s.textbox2ListFilter}
|
||||
else:
|
||||
filters = {}
|
||||
tickets_xmlui, metadata = yield self._s.getDataFormItems(
|
||||
client,
|
||||
service,
|
||||
node,
|
||||
max_items=max_items,
|
||||
item_ids=item_ids,
|
||||
sub_id=sub_id,
|
||||
rsm_request=rsm_request,
|
||||
extra=extra,
|
||||
form_ns=NS_MERGE_REQUESTS,
|
||||
filters = filters)
|
||||
tickets_xmlui, metadata = yield defer.ensureDeferred(
|
||||
self._s.getDataFormItems(
|
||||
client,
|
||||
service,
|
||||
node,
|
||||
max_items=max_items,
|
||||
item_ids=item_ids,
|
||||
sub_id=sub_id,
|
||||
rsm_request=rsm_request,
|
||||
extra=extra,
|
||||
form_ns=APP_NS_MERGE_REQUESTS,
|
||||
filters = filters)
|
||||
)
|
||||
parsed_patches = []
|
||||
if extra.get('parse', False):
|
||||
for ticket in tickets_xmlui:
|
||||
|
|
@ -228,7 +231,7 @@ class MergeRequests(object):
|
|||
@return (unicode): id of the created item
|
||||
"""
|
||||
if not node:
|
||||
node = NS_MERGE_REQUESTS
|
||||
node = self.namespace
|
||||
if values is None:
|
||||
values = {}
|
||||
update = extra.get('update', False)
|
||||
|
|
@ -285,7 +288,7 @@ class MergeRequests(object):
|
|||
values[FIELD_DATA] = data
|
||||
|
||||
item_id = await self._t.set(client, service, node, values, schema, item_id, extra,
|
||||
deserialise, form_ns=NS_MERGE_REQUESTS)
|
||||
deserialise, form_ns=APP_NS_MERGE_REQUESTS)
|
||||
return item_id
|
||||
|
||||
def _parseData(self, data_type, data):
|
||||
|
|
@ -326,14 +329,16 @@ class MergeRequests(object):
|
|||
@param repository(unicode): path to the repository where the code stands
|
||||
"""
|
||||
if not node:
|
||||
node = NS_MERGE_REQUESTS
|
||||
tickets_xmlui, metadata = yield self._s.getDataFormItems(
|
||||
client,
|
||||
service,
|
||||
node,
|
||||
max_items=1,
|
||||
item_ids=[item],
|
||||
form_ns=NS_MERGE_REQUESTS)
|
||||
node = self.namespace
|
||||
tickets_xmlui, metadata = yield defer.ensureDeferred(
|
||||
self._s.getDataFormItems(
|
||||
client,
|
||||
service,
|
||||
node,
|
||||
max_items=1,
|
||||
item_ids=[item],
|
||||
form_ns=APP_NS_MERGE_REQUESTS)
|
||||
)
|
||||
ticket_xmlui = tickets_xmlui[0]
|
||||
data = ticket_xmlui.named_widgets[FIELD_DATA].value
|
||||
data_type = ticket_xmlui.named_widgets[FIELD_DATA_TYPE].value
|
||||
|
|
|
|||
Loading…
Reference in a new issue