Mercurial > libervia-web
comparison src/pages/tickets/disco/page_meta.py @ 1078:296bda6b7ed0
pages (tickets): tickets discovery:
if not is not specified in URL, new discovery page is used.
Discovery is for now basic and allows only to use a free jid with standard node, or display nodes specified in config.
Service, node and name of a tickets node can be specified in config using tickets_trackers_json.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 26 Mar 2018 21:32:16 +0200 |
parents | |
children | cdd389ef97bc |
comparison
equal
deleted
inserted
replaced
1077:880ea673aaff | 1078:296bda6b7ed0 |
---|---|
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 | |
7 log = getLogger('pages/ticket') | |
8 """ticket handling pages""" | |
9 | |
10 name = u'tickets_disco' | |
11 access = C.PAGES_ACCESS_PUBLIC | |
12 template = u"ticket/discover.html" | |
13 | |
14 | |
15 def prepare_render(self, request): | |
16 tickets_trackers_config = self.host.options['tickets_trackers_json'] | |
17 if tickets_trackers_config: | |
18 trackers = request.template_data['tickets_trackers'] = [] | |
19 try: | |
20 for tracker_data in tickets_trackers_config: | |
21 service = tracker_data[u'service'] | |
22 node = tracker_data[u'node'] | |
23 name = tracker_data[u'name'] | |
24 url = self.getPageByName(u'tickets').getURL(service, node) | |
25 trackers.append({u'name': name, u'url': url}) | |
26 except KeyError as e: | |
27 log.warning(u"Missing field in tickets_trackers_json: {msg}".format(msg=e)) | |
28 except Exception as e: | |
29 log.warning(u"Can't decode tickets trackers: {msg}".format(msg=e)) | |
30 | |
31 def on_data_post(self, request): | |
32 jid_str = self.getPostedData(request, u'jid') | |
33 try: | |
34 jid_ = jid.JID(jid_str) | |
35 except RuntimeError: | |
36 self.pageError(request, C.HTTP_BAD_REQUEST) | |
37 # for now we just use default node | |
38 url = self.getPageByName(u'tickets').getURL(jid_.full(), u'@') | |
39 self.HTTPRedirect(request, url) |