Mercurial > libervia-web
comparison src/pages/merge-requests/page_meta.py @ 991:6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 01 Dec 2017 01:08:25 +0100 |
parents | |
children | d8666fdb015c |
comparison
equal
deleted
inserted
replaced
990:6daa59d44ee2 | 991:6ce9647011b3 |
---|---|
1 #!/usr/bin/env python2.7 | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 from libervia.server.constants import Const as C | |
5 from sat.core.i18n import _ | |
6 from twisted.internet import defer | |
7 from twisted.words.protocols.jabber import jid | |
8 from sat.tools.common import template_xmlui | |
9 from sat.tools.common import data_objects | |
10 from sat.core.log import getLogger | |
11 log = getLogger('pages/ticket') | |
12 """ticket handling pages""" | |
13 | |
14 name = u'merge-requests_list' | |
15 access = C.PAGES_ACCESS_PUBLIC | |
16 template = u"ticket/overview.html" | |
17 | |
18 | |
19 def parse_url(self, request): | |
20 # check the service and node to use | |
21 try: | |
22 service = self.nextPath(request) | |
23 node = self.nextPath(request) | |
24 except IndexError: | |
25 log.warning(_(u"missing service and node")) | |
26 self.pageError(request, C.HTTP_BAD_REQUEST) | |
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') | |
43 | |
44 data = self.getRData(request) | |
45 data['service'] = service | |
46 data['node'] = node | |
47 | |
48 template_data = request.template_data | |
49 template_data[u'url_tickets_list'] = self.getPageByName('merge-requests_list').getURL(service.full(), node or u'@') | |
50 template_data[u'url_tickets_new'] = self.getSubPageURL(request, 'merge-requests_new') | |
51 | |
52 @defer.inlineCallbacks | |
53 def prepare_render(self, request): | |
54 data = self.getRData(request) | |
55 template_data = request.template_data | |
56 service, node = data[u'service'], data[u'node'] | |
57 profile = self.getProfile(request) or C.SERVICE_PROFILE | |
58 | |
59 merge_requests = yield self.host.bridge.mergeRequestsGet(service.full() if service else u'', node, C.NO_LIMIT, [], '', {}, profile) | |
60 template_data[u'tickets'] = [template_xmlui.create(self.host, x) for x in merge_requests[0]] | |
61 template_data[u'on_ticket_click'] = data_objects.OnClick(url=self.getSubPageURL(request, 'merge-requests_view', '{item.id}')) |