Mercurial > libervia-web
comparison libervia/pages/tickets/new/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/tickets/new/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 twisted.internet import defer | |
6 from sat.tools.common import template_xmlui | |
7 from sat.core.log import getLogger | |
8 | |
9 log = getLogger("pages/ticket") | |
10 """ticket handling pages""" | |
11 | |
12 name = u"tickets_new" | |
13 access = C.PAGES_ACCESS_PROFILE | |
14 template = u"ticket/create.html" | |
15 | |
16 | |
17 @defer.inlineCallbacks | |
18 def prepare_render(self, request): | |
19 data = self.getRData(request) | |
20 template_data = request.template_data | |
21 service, node = data.get(u"service", u""), data.get(u"node", u"") | |
22 profile = self.getProfile(request) | |
23 schema = yield self.host.bridgeCall("ticketsSchemaGet", service.full(), node, profile) | |
24 data["schema"] = schema | |
25 # following fields are handled in backend | |
26 ignore = ( | |
27 "author", | |
28 "author_jid", | |
29 "author_email", | |
30 "created", | |
31 "updated", | |
32 "comments_uri", | |
33 "status", | |
34 "milestone", | |
35 "priority", | |
36 ) | |
37 xmlui_obj = template_xmlui.create(self.host, schema, ignore=ignore) | |
38 try: | |
39 # small trick to get a one line text input instead of the big textarea | |
40 xmlui_obj.widgets[u"labels"].type = u"string" | |
41 except KeyError: | |
42 pass | |
43 template_data[u"new_ticket_xmlui"] = xmlui_obj | |
44 | |
45 | |
46 @defer.inlineCallbacks | |
47 def on_data_post(self, request): | |
48 data = self.getRData(request) | |
49 service = data["service"] | |
50 node = data["node"] | |
51 posted_data = self.getAllPostedData(request) | |
52 if not posted_data["title"] or not posted_data["body"]: | |
53 self.pageError(request, C.HTTP_BAD_REQUEST) | |
54 try: | |
55 posted_data["labels"] = [l.strip() for l in posted_data["labels"][0].split(",")] | |
56 except (KeyError, IndexError): | |
57 pass | |
58 profile = self.getProfile(request) | |
59 yield self.host.bridgeCall( | |
60 "ticketSet", service.full(), node, posted_data, u"", u"", {}, profile | |
61 ) | |
62 # we don't want to redirect to creation page on success, but to tickets list | |
63 data["post_redirect_page"] = ( | |
64 self.getPageByName(u"tickets"), | |
65 service.full(), | |
66 node or u"@", | |
67 ) |