Mercurial > libervia-web
annotate src/pages/merge-requests/view/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 | b92b06f023cb |
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 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
|
8 from sat.tools.common import uri |
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/tickets/view') |
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_view" |
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"merge-request/item.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 try: |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 item_id = self.nextPath(request) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 except IndexError: |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 log.warning(_(u"no ticket id specified")) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 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
|
25 |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 data = self.getRData(request) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 data[u'ticket_id'] = item_id |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 @defer.inlineCallbacks |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 def prepare_render(self, request): |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 data = self.getRData(request) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 template_data = request.template_data |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 service, node, ticket_id = data.get(u'service', u''), data.get(u'node', u''), data[u'ticket_id'] |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 profile = self.getProfile(request) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 if profile is None: |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 profile = C.SERVICE_PROFILE |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 else: |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 template_data['profile'] = profile |
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 tickets, metadata, parsed_tickets = yield self.host.bridge.mergeRequestsGet(service.full() if service else u'', |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 node, |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 C.NO_LIMIT, |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 [ticket_id], |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 '', |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 {'parse': C.BOOL_TRUE}, |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 profile) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 ticket = template_xmlui.create(self.host, tickets[0], ignore=['publisher', 'request_data', 'type']) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 template_data[u'item'] = ticket |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 template_data['patches'] = parsed_tickets[0] |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 comments_uri = ticket.widgets['comments_uri'].value |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 if comments_uri: |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 uri_data = uri.parseXMPPUri(comments_uri) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 template_data['comments_node'] = comments_node = uri_data['node'] |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 template_data['comments_service'] = comments_service = uri_data['path'] |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 comments = yield self.host.bridge.mbGet(comments_service, |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 comments_node, |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 C.NO_LIMIT, |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 [], |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 {}, |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 profile) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 template_data[u'comments'] = data_objects.BlogItems(comments) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 template_data[u'login_url'] = self.getPageRedirectURL(request) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 @defer.inlineCallbacks |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 def on_data_post(self, request): |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 type_ = self.getPostedData(request, u'type') |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 if type_ == u'comment': |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 blog_page = self.getPageByName(u'blog') |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 yield blog_page.on_data_post(self, request) |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 else: |
6ce9647011b3
pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 log.warning(_(u"Unhandled data type: {}").format(type_)) |