Mercurial > libervia-web
annotate src/pages/merge-requests/edit/page_meta.py @ 1112:f287fc8bb31a
browser (contact list): renamed entityToShow to entityVisible following Quick Frontend change
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 24 Jun 2018 22:21:25 +0200 |
parents | 01e95ec9df9e |
children | cdd389ef97bc |
rev | line source |
---|---|
1096
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python2.7 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 from libervia.server.constants import Const as C |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 from sat.core.i18n import _ |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 from twisted.internet import defer |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 from sat.tools.common import template_xmlui |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 from sat.core.log import getLogger |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 """merge-requests edition""" |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 name = u'merge-requests_edit' |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 access = C.PAGES_ACCESS_PROFILE |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 template = u"merge-request/edit.html" |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 log = getLogger('pages/' + name) |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 def parse_url(self, request): |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 try: |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 item_id = self.nextPath(request) |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 except IndexError: |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 log.warning(_(u"no ticket id specified")) |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 self.pageError(request, C.HTTP_BAD_REQUEST) |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 data = self.getRData(request) |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 data[u'ticket_id'] = item_id |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 @defer.inlineCallbacks |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 def prepare_render(self, request): |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 data = self.getRData(request) |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 template_data = request.template_data |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 service, node, ticket_id = data.get(u'service', u''), data.get(u'node', u''), data[u'ticket_id'] |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 profile = self.getProfile(request) |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 ignore = ('publisher', 'author', 'author_jid', 'author_email', 'created', 'updated', 'comments_uri', 'request_data', 'type') |
1098
01e95ec9df9e
server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents:
1096
diff
changeset
|
36 tickets = yield self.host.bridgeCall("mergeRequestsGet", service.full() if service else u'', node, C.NO_LIMIT, [ticket_id], '', {}, profile) |
1096
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 ticket = [template_xmlui.create(self.host, x, ignore=ignore) for x in tickets[0]][0] |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 try: |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 # small trick to get a one line text input instead of the big textarea |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 ticket.widgets[u'labels'].type = u'string' |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 ticket.widgets[u'labels'].value = ticket.widgets[u'labels'].value.replace(u'\n', ', ') |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 except KeyError: |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 pass |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 template_data[u'new_ticket_xmlui'] = ticket |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 @defer.inlineCallbacks |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 def on_data_post(self, request): |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 data = self.getRData(request) |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 service = data['service'] |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 node = data['node'] |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 ticket_id = data['ticket_id'] |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 posted_data = self.getAllPostedData(request) |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 if not posted_data['title'] or not posted_data['body']: |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 self.pageError(request, C.HTTP_BAD_REQUEST) |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 try: |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 posted_data['labels'] = [l.strip() for l in posted_data['labels'][0].split(',')] |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 except (KeyError, IndexError): |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 pass |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 profile = self.getProfile(request) |
1098
01e95ec9df9e
server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents:
1096
diff
changeset
|
61 yield self.host.bridgeCall("mergeRequestSet", service.full(), |
01e95ec9df9e
server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents:
1096
diff
changeset
|
62 node, |
01e95ec9df9e
server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents:
1096
diff
changeset
|
63 u'', |
01e95ec9df9e
server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents:
1096
diff
changeset
|
64 u'auto', |
01e95ec9df9e
server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents:
1096
diff
changeset
|
65 posted_data, |
01e95ec9df9e
server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents:
1096
diff
changeset
|
66 u'', |
01e95ec9df9e
server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents:
1096
diff
changeset
|
67 ticket_id, |
01e95ec9df9e
server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents:
1096
diff
changeset
|
68 {'update': C.BOOL_TRUE}, |
01e95ec9df9e
server, pages: fixed blocking calls to bridge by using bridgeCall instead
Goffi <goffi@goffi.org>
parents:
1096
diff
changeset
|
69 profile) |
1096
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 # we don't want to redirect to edit page on success, but to tickets list |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 data['post_redirect_page'] = (self.getPageByName(u'merge-requests'), |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 service.full(), |
01538d8a77be
merge-requests, tickets: new "edit" pages
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 node or u'@') |