Mercurial > libervia-web
annotate libervia/web/pages/merge-requests/disco/page_meta.py @ 1593:c6976c5b85a1
browser (chat/select): add bookmarked entities on empty search
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 11 Dec 2023 00:43:06 +0100 |
parents | eb00d593801d |
children |
rev | line source |
---|---|
1216 | 1 #!/usr/bin/env python3 |
1239 | 2 |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
1518
eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents:
1509
diff
changeset
|
4 from libervia.web.server.constants import Const as C |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 from twisted.words.protocols.jabber import jid |
1518
eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents:
1509
diff
changeset
|
6 from libervia.backend.core.log import getLogger |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1081
diff
changeset
|
7 |
1145
29eb15062416
pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
8 log = getLogger(__name__) |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1239
diff
changeset
|
9 |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
1216 | 11 name = "merge-requests_disco" |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 access = C.PAGES_ACCESS_PUBLIC |
1216 | 13 template = "merge-request/discover.html" |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 |
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 def prepare_render(self, request): |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1081
diff
changeset
|
17 mr_handlers_config = self.host.options["mr_handlers_json"] |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 if mr_handlers_config: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1081
diff
changeset
|
19 handlers = request.template_data["mr_handlers"] = [] |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 try: |
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 for handler_data in mr_handlers_config: |
1216 | 22 service = handler_data["service"] |
23 node = handler_data["node"] | |
24 name = handler_data["name"] | |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
25 url = self.get_page_by_name("merge-requests").get_url(service, node) |
1216 | 26 handlers.append({"name": name, "url": url}) |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 except KeyError as e: |
1216 | 28 log.warning("Missing field in mr_handlers_json: {msg}".format(msg=e)) |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 except Exception as e: |
1216 | 30 log.warning("Can't decode mr handlers: {msg}".format(msg=e)) |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1081
diff
changeset
|
32 |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 def on_data_post(self, request): |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
34 jid_str = self.get_posted_data(request, "jid") |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 try: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1081
diff
changeset
|
36 jid_ = jid.JID(jid_str) |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 except RuntimeError: |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
38 self.page_error(request, C.HTTP_BAD_REQUEST) |
1081
ed67265205c4
pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 # for now we just use default node |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
40 url = self.get_page_by_name("merge-requests").get_url(jid_.full(), "@") |
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
41 self.http_redirect(request, url) |