Mercurial > libervia-web
comparison libervia/pages/tickets/disco/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 | 29eb15062416 |
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.words.protocols.jabber import jid | 5 from twisted.words.protocols.jabber import jid |
6 from sat.core.log import getLogger | 6 from sat.core.log import getLogger |
7 | 7 |
8 log = getLogger(__name__) | 8 log = getLogger(__name__) |
9 """ticket handling pages""" | 9 """ticket handling pages""" |
10 | 10 |
11 name = u"tickets_disco" | 11 name = "tickets_disco" |
12 access = C.PAGES_ACCESS_PUBLIC | 12 access = C.PAGES_ACCESS_PUBLIC |
13 template = u"ticket/discover.html" | 13 template = "ticket/discover.html" |
14 | 14 |
15 | 15 |
16 def prepare_render(self, request): | 16 def prepare_render(self, request): |
17 tickets_trackers_config = self.host.options["tickets_trackers_json"] | 17 tickets_trackers_config = self.host.options["tickets_trackers_json"] |
18 if tickets_trackers_config: | 18 if tickets_trackers_config: |
19 trackers = request.template_data["tickets_trackers"] = [] | 19 trackers = request.template_data["tickets_trackers"] = [] |
20 try: | 20 try: |
21 for tracker_data in tickets_trackers_config: | 21 for tracker_data in tickets_trackers_config: |
22 service = tracker_data[u"service"] | 22 service = tracker_data["service"] |
23 node = tracker_data[u"node"] | 23 node = tracker_data["node"] |
24 name = tracker_data[u"name"] | 24 name = tracker_data["name"] |
25 url = self.getPageByName(u"tickets").getURL(service, node) | 25 url = self.getPageByName("tickets").getURL(service, node) |
26 trackers.append({u"name": name, u"url": url}) | 26 trackers.append({"name": name, "url": url}) |
27 except KeyError as e: | 27 except KeyError as e: |
28 log.warning(u"Missing field in tickets_trackers_json: {msg}".format(msg=e)) | 28 log.warning("Missing field in tickets_trackers_json: {msg}".format(msg=e)) |
29 except Exception as e: | 29 except Exception as e: |
30 log.warning(u"Can't decode tickets trackers: {msg}".format(msg=e)) | 30 log.warning("Can't decode tickets trackers: {msg}".format(msg=e)) |
31 | 31 |
32 | 32 |
33 def on_data_post(self, request): | 33 def on_data_post(self, request): |
34 jid_str = self.getPostedData(request, u"jid") | 34 jid_str = self.getPostedData(request, "jid") |
35 try: | 35 try: |
36 jid_ = jid.JID(jid_str) | 36 jid_ = jid.JID(jid_str) |
37 except RuntimeError: | 37 except RuntimeError: |
38 self.pageError(request, C.HTTP_BAD_REQUEST) | 38 self.pageError(request, C.HTTP_BAD_REQUEST) |
39 # for now we just use default node | 39 # for now we just use default node |
40 url = self.getPageByName(u"tickets").getURL(jid_.full(), u"@") | 40 url = self.getPageByName("tickets").getURL(jid_.full(), "@") |
41 self.HTTPRedirect(request, url) | 41 self.HTTPRedirect(request, url) |