Mercurial > libervia-web
comparison libervia/pages/merge-requests/edit/page_meta.py @ 1124:28e3eb3bb217
files reorganisation and installation rework:
- files have been reorganised to follow other SàT projects and usual Python organisation (no more "/src" directory)
- VERSION file is now used, as for other SàT projects
- replace the overcomplicated setup.py be a more sane one. Pyjamas part is not compiled anymore by setup.py, it must be done separatly
- removed check for data_dir if it's empty
- installation tested working in virtual env
- libervia launching script is now in bin/libervia
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 25 Aug 2018 17:59:48 +0200 |
parents | src/pages/merge-requests/edit/page_meta.py@cdd389ef97bc |
children | 7bd47d32da87 |
comparison
equal
deleted
inserted
replaced
1123:63a4b8fe9782 | 1124:28e3eb3bb217 |
---|---|
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 sat.tools.common import template_xmlui | |
8 from sat.core.log import getLogger | |
9 | |
10 """merge-requests edition""" | |
11 | |
12 name = u"merge-requests_edit" | |
13 access = C.PAGES_ACCESS_PROFILE | |
14 template = u"merge-request/edit.html" | |
15 log = getLogger("pages/" + name) | |
16 | |
17 | |
18 def parse_url(self, request): | |
19 try: | |
20 item_id = self.nextPath(request) | |
21 except IndexError: | |
22 log.warning(_(u"no ticket id specified")) | |
23 self.pageError(request, C.HTTP_BAD_REQUEST) | |
24 | |
25 data = self.getRData(request) | |
26 data[u"ticket_id"] = item_id | |
27 | |
28 | |
29 @defer.inlineCallbacks | |
30 def prepare_render(self, request): | |
31 data = self.getRData(request) | |
32 template_data = request.template_data | |
33 service, node, ticket_id = ( | |
34 data.get(u"service", u""), | |
35 data.get(u"node", u""), | |
36 data[u"ticket_id"], | |
37 ) | |
38 profile = self.getProfile(request) | |
39 | |
40 ignore = ( | |
41 "publisher", | |
42 "author", | |
43 "author_jid", | |
44 "author_email", | |
45 "created", | |
46 "updated", | |
47 "comments_uri", | |
48 "request_data", | |
49 "type", | |
50 ) | |
51 tickets = yield self.host.bridgeCall( | |
52 "mergeRequestsGet", | |
53 service.full() if service else u"", | |
54 node, | |
55 C.NO_LIMIT, | |
56 [ticket_id], | |
57 "", | |
58 {}, | |
59 profile, | |
60 ) | |
61 ticket = [template_xmlui.create(self.host, x, ignore=ignore) for x in tickets[0]][0] | |
62 | |
63 try: | |
64 # small trick to get a one line text input instead of the big textarea | |
65 ticket.widgets[u"labels"].type = u"string" | |
66 ticket.widgets[u"labels"].value = ticket.widgets[u"labels"].value.replace( | |
67 u"\n", ", " | |
68 ) | |
69 except KeyError: | |
70 pass | |
71 template_data[u"new_ticket_xmlui"] = ticket | |
72 | |
73 | |
74 @defer.inlineCallbacks | |
75 def on_data_post(self, request): | |
76 data = self.getRData(request) | |
77 service = data["service"] | |
78 node = data["node"] | |
79 ticket_id = data["ticket_id"] | |
80 posted_data = self.getAllPostedData(request) | |
81 if not posted_data["title"] or not posted_data["body"]: | |
82 self.pageError(request, C.HTTP_BAD_REQUEST) | |
83 try: | |
84 posted_data["labels"] = [l.strip() for l in posted_data["labels"][0].split(",")] | |
85 except (KeyError, IndexError): | |
86 pass | |
87 profile = self.getProfile(request) | |
88 yield self.host.bridgeCall( | |
89 "mergeRequestSet", | |
90 service.full(), | |
91 node, | |
92 u"", | |
93 u"auto", | |
94 posted_data, | |
95 u"", | |
96 ticket_id, | |
97 {"update": C.BOOL_TRUE}, | |
98 profile, | |
99 ) | |
100 # we don't want to redirect to edit page on success, but to tickets list | |
101 data["post_redirect_page"] = ( | |
102 self.getPageByName(u"merge-requests"), | |
103 service.full(), | |
104 node or u"@", | |
105 ) |