Mercurial > libervia-backend
comparison sat/plugins/plugin_tickets_import.py @ 3452:bb0225aaf4e6
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 11 Dec 2020 17:57:00 +0100 |
parents | 559a625a236b |
children | be6d91572633 |
comparison
equal
deleted
inserted
replaced
3451:f37e6e78db12 | 3452:bb0225aaf4e6 |
---|---|
30 | 30 |
31 PLUGIN_INFO = { | 31 PLUGIN_INFO = { |
32 C.PI_NAME: "tickets import", | 32 C.PI_NAME: "tickets import", |
33 C.PI_IMPORT_NAME: "TICKETS_IMPORT", | 33 C.PI_IMPORT_NAME: "TICKETS_IMPORT", |
34 C.PI_TYPE: C.PLUG_TYPE_IMPORT, | 34 C.PI_TYPE: C.PLUG_TYPE_IMPORT, |
35 C.PI_DEPENDENCIES: ["IMPORT", "XEP-0060", "XEP-0277", "PUBSUB_SCHEMA"], | 35 C.PI_DEPENDENCIES: ["IMPORT", "XEP-0060", "XEP-0277", "XEP-0346"], |
36 C.PI_MAIN: "TicketsImportPlugin", | 36 C.PI_MAIN: "TicketsImportPlugin", |
37 C.PI_HANDLER: "no", | 37 C.PI_HANDLER: "no", |
38 C.PI_DESCRIPTION: _( | 38 C.PI_DESCRIPTION: _( |
39 """Tickets import management: | 39 """Tickets import management: |
40 This plugin manage the different tickets importers which can register to it, and handle generic importing tasks.""" | 40 This plugin manage the different tickets importers which can register to it, and handle generic importing tasks.""" |
43 | 43 |
44 OPT_MAPPING = "mapping" | 44 OPT_MAPPING = "mapping" |
45 FIELDS_LIST = ("labels", "cc_emails") # fields which must have a list as value | 45 FIELDS_LIST = ("labels", "cc_emails") # fields which must have a list as value |
46 FIELDS_DATE = ("created", "updated") | 46 FIELDS_DATE = ("created", "updated") |
47 | 47 |
48 NS_TICKETS = "org.salut-a-toi.tickets:0" | 48 NS_TICKETS = "fdp/submitted/org.salut-a-toi.tickets:0" |
49 | 49 |
50 | 50 |
51 class TicketsImportPlugin(object): | 51 class TicketsImportPlugin(object): |
52 BOOL_OPTIONS = () | 52 BOOL_OPTIONS = () |
53 JSON_OPTIONS = (OPT_MAPPING,) | 53 JSON_OPTIONS = (OPT_MAPPING,) |
57 log.info(_("plugin Tickets Import initialization")) | 57 log.info(_("plugin Tickets Import initialization")) |
58 self.host = host | 58 self.host = host |
59 self._importers = {} | 59 self._importers = {} |
60 self._p = host.plugins["XEP-0060"] | 60 self._p = host.plugins["XEP-0060"] |
61 self._m = host.plugins["XEP-0277"] | 61 self._m = host.plugins["XEP-0277"] |
62 self._s = host.plugins["PUBSUB_SCHEMA"] | 62 self._s = host.plugins["XEP-0346"] |
63 host.plugins["IMPORT"].initialize(self, "tickets") | 63 host.plugins["IMPORT"].initialize(self, "tickets") |
64 | 64 |
65 @defer.inlineCallbacks | 65 @defer.inlineCallbacks |
66 def importItem( | 66 def importItem( |
67 self, client, item_import_data, session, options, return_data, service, node | 67 self, client, item_import_data, session, options, return_data, service, node |
159 log.debug( | 159 log.debug( |
160 "uploading item [{id}]: {title}".format( | 160 "uploading item [{id}]: {title}".format( |
161 id=id_, title=ticket_data.get("title", "") | 161 id=id_, title=ticket_data.get("title", "") |
162 ) | 162 ) |
163 ) | 163 ) |
164 return self._s.sendDataFormItem( | 164 return defer.ensureDeferred( |
165 client, service, node, ticket_data, session["schema"], id_ | 165 self._s.sendDataFormItem( |
166 client, service, node, ticket_data, session["schema"], id_ | |
167 ) | |
166 ) | 168 ) |
167 | 169 |
168 def itemFilters(self, client, ticket_data, session, options): | 170 def itemFilters(self, client, ticket_data, session, options): |
169 mapping = options.get(OPT_MAPPING) | 171 mapping = options.get(OPT_MAPPING) |
170 if mapping is not None: | 172 if mapping is not None: |