Mercurial > libervia-web
comparison src/pages/merge-requests/page_meta.py @ 1081:ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
new "mr_handlers_json" option allows to add well known merge-requests handlers in configuration.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 27 Mar 2018 08:40:12 +0200 |
parents | d8666fdb015c |
children | 3996acd7c796 |
comparison
equal
deleted
inserted
replaced
1080:2c2b8c08e6c9 | 1081:ed67265205c4 |
---|---|
1 #!/usr/bin/env python2.7 | 1 #!/usr/bin/env python2.7 |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 | 3 |
4 from libervia.server.constants import Const as C | 4 from libervia.server.constants import Const as C |
5 from sat.core.i18n import _ | |
6 from twisted.internet import defer | 5 from twisted.internet import defer |
7 from twisted.words.protocols.jabber import jid | |
8 from sat.tools.common import template_xmlui | 6 from sat.tools.common import template_xmlui |
9 from sat.tools.common import data_objects | 7 from sat.tools.common import data_objects |
10 from sat.core.log import getLogger | 8 from sat.core.log import getLogger |
11 log = getLogger('pages/ticket') | 9 log = getLogger('pages/ticket') |
12 """ticket handling pages""" | 10 """ticket handling pages""" |
13 | 11 |
14 name = u'merge-requests_list' | 12 name = u'merge-requests' |
15 access = C.PAGES_ACCESS_PUBLIC | 13 access = C.PAGES_ACCESS_PUBLIC |
16 template = u"ticket/overview.html" | 14 template = u"ticket/overview.html" |
17 | 15 |
18 | 16 |
19 def parse_url(self, request): | 17 def parse_url(self, request): |
20 # check the service and node to use | 18 self.getPathArgs(request, ['service', 'node'], service='jid') |
21 try: | 19 data = self.getRData(request) |
22 service = self.nextPath(request) | 20 service, node = data[u'service'], data[u'node'] |
23 node = self.nextPath(request) | 21 if node is None: |
24 except IndexError: | 22 self.pageRedirect(u"merge-requests_disco", request) |
25 log.warning(_(u"missing service and node")) | 23 if node == u'@': |
26 self.pageError(request, C.HTTP_BAD_REQUEST) | 24 node = data[u'node'] = u'' |
27 | |
28 if not service or service == u'@': | |
29 service = u'' | |
30 | |
31 if service: | |
32 try: | |
33 service = jid.JID(service) | |
34 except Exception: | |
35 log.warning(_(u"bad service entered: {}").format(service)) | |
36 self.pageError(request, C.HTTP_BAD_REQUEST) | |
37 | |
38 if not node or node == u'@': | |
39 node = u'' | |
40 | |
41 | |
42 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short='merge-requests') | 25 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short='merge-requests') |
43 | |
44 data = self.getRData(request) | |
45 data['service'] = service | |
46 data['node'] = node | |
47 | |
48 template_data = request.template_data | 26 template_data = request.template_data |
49 template_data[u'url_tickets_list'] = self.getPageByName('merge-requests_list').getURL(service.full(), node or u'@') | 27 template_data[u'url_tickets_list'] = self.getPageByName('merge-requests').getURL(service.full(), node) |
50 template_data[u'url_tickets_new'] = self.getSubPageURL(request, 'merge-requests_new') | 28 template_data[u'url_tickets_new'] = self.getSubPageURL(request, 'merge-requests_new') |
51 | 29 |
52 @defer.inlineCallbacks | 30 @defer.inlineCallbacks |
53 def prepare_render(self, request): | 31 def prepare_render(self, request): |
54 data = self.getRData(request) | 32 data = self.getRData(request) |