Mercurial > libervia-web
annotate libervia/pages/tickets/disco/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/disco/page_meta.py@cdd389ef97bc |
children | 29eb15062416 |
rev | line source |
---|---|
1078 | 1 #!/usr/bin/env python2.7 |
2 # -*- coding: utf-8 -*- | |
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 |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
8 log = getLogger("pages/ticket") |
1078 | 9 """ticket handling pages""" |
10 | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
11 name = u"tickets_disco" |
1078 | 12 access = C.PAGES_ACCESS_PUBLIC |
13 template = u"ticket/discover.html" | |
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: | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
22 service = tracker_data[u"service"] |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
23 node = tracker_data[u"node"] |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
24 name = tracker_data[u"name"] |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
25 url = self.getPageByName(u"tickets").getURL(service, node) |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
26 trackers.append({u"name": name, u"url": url}) |
1078 | 27 except KeyError as e: |
28 log.warning(u"Missing field in tickets_trackers_json: {msg}".format(msg=e)) | |
29 except Exception as e: | |
30 log.warning(u"Can't decode tickets trackers: {msg}".format(msg=e)) | |
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): |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
34 jid_str = self.getPostedData(request, u"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 | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1078
diff
changeset
|
40 url = self.getPageByName(u"tickets").getURL(jid_.full(), u"@") |
1078 | 41 self.HTTPRedirect(request, url) |