comparison src/plugins/plugin_tickets_import.py @ 2393:8ed4ac10cb5e

plugin tickets import: create comments nodes with open access/publishing
author Goffi <goffi@goffi.org>
date Fri, 27 Oct 2017 08:35:22 +0200
parents f57a8eaec8ed
children 66baa687c682
comparison
equal deleted inserted replaced
2392:b29a53fb270d 2393:8ed4ac10cb5e
95 95
96 @defer.inlineCallbacks 96 @defer.inlineCallbacks
97 def importSubItems(self, client, item_import_data, ticket_data, session, options): 97 def importSubItems(self, client, item_import_data, ticket_data, session, options):
98 # TODO: force "open" permission (except if private, check below) 98 # TODO: force "open" permission (except if private, check below)
99 # TODO: handle "private" metadata, to have non public access for node 99 # TODO: handle "private" metadata, to have non public access for node
100 # TODO: node access/publish model should be customisable
100 comments = ticket_data.get('comments', []) 101 comments = ticket_data.get('comments', [])
101 service, node = self._m.getCommentsService(client), self._m.getCommentsNode(session['root_node'] + u'_' + ticket_data['id']) 102 service, node = self._m.getCommentsService(client), self._m.getCommentsNode(session['root_node'] + u'_' + ticket_data['id'])
102 yield self._p.createIfNewNode(client, service, node) 103 node_options = {self._p.OPT_ACCESS_MODEL: self._p.ACCESS_OPEN,
104 self._p.OPT_PERSIST_ITEMS: 1,
105 self._p.OPT_MAX_ITEMS: -1,
106 self._p.OPT_DELIVER_PAYLOADS: 1,
107 self._p.OPT_SEND_ITEM_SUBSCRIBE: 1,
108 self._p.OPT_PUBLISH_MODEL: self._p.ACCESS_OPEN,
109 }
110 yield self._p.createIfNewNode(client, service, node, options=node_options)
103 ticket_data['comments_uri'] = uri.buildXMPPUri(u'pubsub', subtype='microblog', path=service.full(), node=node) 111 ticket_data['comments_uri'] = uri.buildXMPPUri(u'pubsub', subtype='microblog', path=service.full(), node=node)
104 for comment in comments: 112 for comment in comments:
105 if 'updated' not in comment and 'published' in comment: 113 if 'updated' not in comment and 'published' in comment:
106 # we don't want an automatic update date 114 # we don't want an automatic update date
107 comment['updated'] = comment['published'] 115 comment['updated'] = comment['published']