Mercurial > libervia-web
annotate libervia/pages/tickets/disco/page_meta.py @ 1361:626b7bbb7f90
server: mechanism to exit Libervia with an exit code:
the new `SysExit` exception can now be used to quit Libervia with a given shell exit code.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 14 Nov 2020 22:24:58 +0100 |
parents | f511f8fbbf8a |
children |
rev | line source |
---|---|
1216 | 1 #!/usr/bin/env python3 |
1239 | 2 |
1078 | 3 |
4 from libervia.server.constants import Const as C | |
5 from twisted.words.protocols.jabber import jid | |
6 from sat.core.log import getLogger | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
7 |
1145
29eb15062416
pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
8 log = getLogger(__name__) |
1078 | 9 """ticket handling pages""" |
10 | |
1216 | 11 name = "tickets_disco" |
1078 | 12 access = C.PAGES_ACCESS_PUBLIC |
1216 | 13 template = "ticket/discover.html" |
1078 | 14 |
15 | |
16 def prepare_render(self, request): | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
17 tickets_trackers_config = self.host.options["tickets_trackers_json"] |
1078 | 18 if tickets_trackers_config: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
19 trackers = request.template_data["tickets_trackers"] = [] |
1078 | 20 try: |
21 for tracker_data in tickets_trackers_config: | |
1216 | 22 service = tracker_data["service"] |
23 node = tracker_data["node"] | |
24 name = tracker_data["name"] | |
25 url = self.getPageByName("tickets").getURL(service, node) | |
26 trackers.append({"name": name, "url": url}) | |
1078 | 27 except KeyError as e: |
1216 | 28 log.warning("Missing field in tickets_trackers_json: {msg}".format(msg=e)) |
1078 | 29 except Exception as e: |
1216 | 30 log.warning("Can't decode tickets trackers: {msg}".format(msg=e)) |
1078 | 31 |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
32 |
1078 | 33 def on_data_post(self, request): |
1216 | 34 jid_str = self.getPostedData(request, "jid") |
1078 | 35 try: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
36 jid_ = jid.JID(jid_str) |
1078 | 37 except RuntimeError: |
38 self.pageError(request, C.HTTP_BAD_REQUEST) | |
39 # for now we just use default node | |
1216 | 40 url = self.getPageByName("tickets").getURL(jid_.full(), "@") |
1078 | 41 self.HTTPRedirect(request, url) |