annotate src/pages/merge-requests/page_meta.py @ 1043:d8666fdb015c

pages (tickets, merge-requests): fixed items URLs
author Goffi <goffi@goffi.org>
date Wed, 24 Jan 2018 09:58:00 +0100
parents 6ce9647011b3
children ed67265205c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
991
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2.7
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
3
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from libervia.server.constants import Const as C
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
5 from sat.core.i18n import _
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
6 from twisted.internet import defer
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
7 from twisted.words.protocols.jabber import jid
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
8 from sat.tools.common import template_xmlui
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
9 from sat.tools.common import data_objects
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
10 from sat.core.log import getLogger
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
11 log = getLogger('pages/ticket')
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
12 """ticket handling pages"""
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
13
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
14 name = u'merge-requests_list'
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
15 access = C.PAGES_ACCESS_PUBLIC
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
16 template = u"ticket/overview.html"
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
17
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
18
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
19 def parse_url(self, request):
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
20 # check the service and node to use
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
21 try:
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
22 service = self.nextPath(request)
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
23 node = self.nextPath(request)
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
24 except IndexError:
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
25 log.warning(_(u"missing service and node"))
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
26 self.pageError(request, C.HTTP_BAD_REQUEST)
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
27
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
28 if not service or service == u'@':
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
29 service = u''
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
30
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
31 if service:
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
32 try:
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
33 service = jid.JID(service)
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
34 except Exception:
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
35 log.warning(_(u"bad service entered: {}").format(service))
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
36 self.pageError(request, C.HTTP_BAD_REQUEST)
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
37
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
38 if not node or node == u'@':
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
39 node = u''
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
40
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
41
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
42 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short='merge-requests')
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
43
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
44 data = self.getRData(request)
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
45 data['service'] = service
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
46 data['node'] = node
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
47
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
48 template_data = request.template_data
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
49 template_data[u'url_tickets_list'] = self.getPageByName('merge-requests_list').getURL(service.full(), node or u'@')
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
50 template_data[u'url_tickets_new'] = self.getSubPageURL(request, 'merge-requests_new')
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
51
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
52 @defer.inlineCallbacks
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
53 def prepare_render(self, request):
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
54 data = self.getRData(request)
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
55 template_data = request.template_data
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
56 service, node = data[u'service'], data[u'node']
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
57 profile = self.getProfile(request) or C.SERVICE_PROFILE
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
58
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
59 merge_requests = yield self.host.bridge.mergeRequestsGet(service.full() if service else u'', node, C.NO_LIMIT, [], '', {}, profile)
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
60 template_data[u'tickets'] = [template_xmlui.create(self.host, x) for x in merge_requests[0]]
1043
d8666fdb015c pages (tickets, merge-requests): fixed items URLs
Goffi <goffi@goffi.org>
parents: 991
diff changeset
61 template_data[u'on_ticket_click'] = data_objects.OnClick(url=self.getSubPageURL(request, u'merge-requests_view') + u'/{item.id}')