Mercurial > libervia-web
comparison libervia/web/pages/merge-requests/disco/page_meta.py @ 1518:eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 16:49:28 +0200 |
parents | libervia/pages/merge-requests/disco/page_meta.py@106bae41f5c8 |
children |
comparison
equal
deleted
inserted
replaced
1517:b8ed9726525b | 1518:eb00d593801d |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 | |
4 from libervia.web.server.constants import Const as C | |
5 from twisted.words.protocols.jabber import jid | |
6 from libervia.backend.core.log import getLogger | |
7 | |
8 log = getLogger(__name__) | |
9 | |
10 | |
11 name = "merge-requests_disco" | |
12 access = C.PAGES_ACCESS_PUBLIC | |
13 template = "merge-request/discover.html" | |
14 | |
15 | |
16 def prepare_render(self, request): | |
17 mr_handlers_config = self.host.options["mr_handlers_json"] | |
18 if mr_handlers_config: | |
19 handlers = request.template_data["mr_handlers"] = [] | |
20 try: | |
21 for handler_data in mr_handlers_config: | |
22 service = handler_data["service"] | |
23 node = handler_data["node"] | |
24 name = handler_data["name"] | |
25 url = self.get_page_by_name("merge-requests").get_url(service, node) | |
26 handlers.append({"name": name, "url": url}) | |
27 except KeyError as e: | |
28 log.warning("Missing field in mr_handlers_json: {msg}".format(msg=e)) | |
29 except Exception as e: | |
30 log.warning("Can't decode mr handlers: {msg}".format(msg=e)) | |
31 | |
32 | |
33 def on_data_post(self, request): | |
34 jid_str = self.get_posted_data(request, "jid") | |
35 try: | |
36 jid_ = jid.JID(jid_str) | |
37 except RuntimeError: | |
38 self.page_error(request, C.HTTP_BAD_REQUEST) | |
39 # for now we just use default node | |
40 url = self.get_page_by_name("merge-requests").get_url(jid_.full(), "@") | |
41 self.http_redirect(request, url) |