annotate src/pages/tickets/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 296bda6b7ed0
children 3996acd7c796
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2.7
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from libervia.server.constants import Const as C
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 from twisted.internet import defer
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 from sat.tools.common import template_xmlui
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 from sat.tools.common import data_objects
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 from sat.core.log import getLogger
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 log = getLogger('pages/ticket')
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 """ticket handling pages"""
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
1078
296bda6b7ed0 pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
12 name = u'tickets'
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 access = C.PAGES_ACCESS_PUBLIC
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 template = u"ticket/overview.html"
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 def parse_url(self, request):
1078
296bda6b7ed0 pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
18 self.getPathArgs(request, ['service', 'node'], service='jid')
296bda6b7ed0 pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
19 data = self.getRData(request)
296bda6b7ed0 pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
20 service, node = data[u'service'], data[u'node']
296bda6b7ed0 pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
21 if node is None:
296bda6b7ed0 pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
22 self.pageRedirect(u"tickets_disco", request)
296bda6b7ed0 pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
23 if node == u'@':
296bda6b7ed0 pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
24 node = data[u'node'] = u''
973
2e75dc986e03 pages (tickets): URLs for list and new are set in the template for the whole subhierarchy
Goffi <goffi@goffi.org>
parents: 967
diff changeset
25 template_data = request.template_data
1078
296bda6b7ed0 pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
26 template_data[u'url_tickets_list'] = self.getURL(service.full(), node or u'@')
981
97cce8c1e96a pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents: 978
diff changeset
27 template_data[u'url_tickets_new'] = self.getSubPageURL(request, 'tickets_new')
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 @defer.inlineCallbacks
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 def prepare_render(self, request):
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 data = self.getRData(request)
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 template_data = request.template_data
981
97cce8c1e96a pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents: 978
diff changeset
33 service, node = data[u'service'], data[u'node']
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 profile = self.getProfile(request) or C.SERVICE_PROFILE
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35
1021
b39c527f208c pages (tickets): check cache in prepare_render instead of parse_url
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
36 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short='tickets')
b39c527f208c pages (tickets): check cache in prepare_render instead of parse_url
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
37
1007
c1c74d97a691 pages(tickets): use bridgeCall instead of bridge
Goffi <goffi@goffi.org>
parents: 986
diff changeset
38 tickets = yield self.host.bridgeCall('ticketsGet', service.full() if service else u'', node, C.NO_LIMIT, [], '', {}, profile)
981
97cce8c1e96a pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents: 978
diff changeset
39 template_data[u'tickets'] = [template_xmlui.create(self.host, x) for x in tickets[0]]
1043
d8666fdb015c pages (tickets, merge-requests): fixed items URLs
Goffi <goffi@goffi.org>
parents: 1021
diff changeset
40 template_data[u'on_ticket_click'] = data_objects.OnClick(url=self.getSubPageURL(request, u'tickets_view') + u'/{item.id}')