Mercurial > libervia-web
comparison libervia/pages/tickets/new/page_meta.py @ 1216:b2d067339de3
python 3 port:
/!\ Python 3.6+ is now needed to use libervia
/!\ instability may occur and features may not be working anymore, this will improve with time
/!\ TxJSONRPC dependency has been removed
The same procedure as in backend has been applied (check backend commit ab2696e34d29 logs
for details). Removed now deprecated code (Pyjamas compiled browser part, legacy blog,
JSON RPC related code).
Adapted code to work without `html` and `themes` dirs.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 13 Aug 2019 19:12:31 +0200 |
parents | bed008b65d7c |
children | f511f8fbbf8a |
comparison
equal
deleted
inserted
replaced
1215:f14ab8a25e8b | 1216:b2d067339de3 |
---|---|
1 #!/usr/bin/env python2.7 | 1 #!/usr/bin/env python3 |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 | 3 |
4 from libervia.server.constants import Const as C | 4 from libervia.server.constants import Const as C |
5 from twisted.internet import defer | 5 from twisted.internet import defer |
6 from sat.tools.common import template_xmlui | 6 from sat.tools.common import template_xmlui |
7 from sat.core.log import getLogger | 7 from sat.core.log import getLogger |
8 | 8 |
9 log = getLogger(__name__) | 9 log = getLogger(__name__) |
10 """ticket handling pages""" | 10 """ticket handling pages""" |
11 | 11 |
12 name = u"tickets_new" | 12 name = "tickets_new" |
13 access = C.PAGES_ACCESS_PROFILE | 13 access = C.PAGES_ACCESS_PROFILE |
14 template = u"ticket/create.html" | 14 template = "ticket/create.html" |
15 | 15 |
16 | 16 |
17 @defer.inlineCallbacks | 17 @defer.inlineCallbacks |
18 def prepare_render(self, request): | 18 def prepare_render(self, request): |
19 data = self.getRData(request) | 19 data = self.getRData(request) |
20 template_data = request.template_data | 20 template_data = request.template_data |
21 service, node = data.get(u"service", u""), data.get(u"node", u"") | 21 service, node = data.get("service", ""), data.get("node", "") |
22 profile = self.getProfile(request) | 22 profile = self.getProfile(request) |
23 schema = yield self.host.bridgeCall("ticketsSchemaGet", service.full(), node, profile) | 23 schema = yield self.host.bridgeCall("ticketsSchemaGet", service.full(), node, profile) |
24 data["schema"] = schema | 24 data["schema"] = schema |
25 # following fields are handled in backend | 25 # following fields are handled in backend |
26 ignore = ( | 26 ignore = ( |
35 "priority", | 35 "priority", |
36 ) | 36 ) |
37 xmlui_obj = template_xmlui.create(self.host, schema, ignore=ignore) | 37 xmlui_obj = template_xmlui.create(self.host, schema, ignore=ignore) |
38 try: | 38 try: |
39 # small trick to get a one line text input instead of the big textarea | 39 # small trick to get a one line text input instead of the big textarea |
40 xmlui_obj.widgets[u"labels"].type = u"string" | 40 xmlui_obj.widgets["labels"].type = "string" |
41 except KeyError: | 41 except KeyError: |
42 pass | 42 pass |
43 | 43 |
44 # same as for tickets_edit, we have to convert for now | 44 # same as for tickets_edit, we have to convert for now |
45 wid = xmlui_obj.widgets[u'body'] | 45 wid = xmlui_obj.widgets['body'] |
46 if wid.type == u"xhtmlbox": | 46 if wid.type == "xhtmlbox": |
47 wid.type = u"textbox" | 47 wid.type = "textbox" |
48 wid.value = yield self.host.bridgeCall( | 48 wid.value = yield self.host.bridgeCall( |
49 u"syntaxConvert", wid.value, C.SYNTAX_XHTML, u"markdown", | 49 "syntaxConvert", wid.value, C.SYNTAX_XHTML, "markdown", |
50 False, profile) | 50 False, profile) |
51 template_data[u"new_ticket_xmlui"] = xmlui_obj | 51 template_data["new_ticket_xmlui"] = xmlui_obj |
52 | 52 |
53 | 53 |
54 @defer.inlineCallbacks | 54 @defer.inlineCallbacks |
55 def on_data_post(self, request): | 55 def on_data_post(self, request): |
56 data = self.getRData(request) | 56 data = self.getRData(request) |
65 pass | 65 pass |
66 profile = self.getProfile(request) | 66 profile = self.getProfile(request) |
67 | 67 |
68 # we convert back body to XHTML | 68 # we convert back body to XHTML |
69 body = yield self.host.bridgeCall( | 69 body = yield self.host.bridgeCall( |
70 u"syntaxConvert", posted_data[u'body'][0], u"markdown", C.SYNTAX_XHTML, | 70 "syntaxConvert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML, |
71 False, profile) | 71 False, profile) |
72 posted_data[u'body'] = [u'<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, | 72 posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, |
73 body=body)] | 73 body=body)] |
74 | 74 |
75 | 75 |
76 yield self.host.bridgeCall( | 76 yield self.host.bridgeCall( |
77 "ticketSet", service.full(), node, posted_data, u"", u"", u"", profile | 77 "ticketSet", service.full(), node, posted_data, "", "", "", profile |
78 ) | 78 ) |
79 # we don't want to redirect to creation page on success, but to tickets list | 79 # we don't want to redirect to creation page on success, but to tickets list |
80 data["post_redirect_page"] = ( | 80 data["post_redirect_page"] = ( |
81 self.getPageByName(u"tickets"), | 81 self.getPageByName("tickets"), |
82 service.full(), | 82 service.full(), |
83 node or u"@", | 83 node or "@", |
84 ) | 84 ) |