Mercurial > libervia-web
annotate libervia/web/pages/lists/new/page_meta.py @ 1566:e65d2ef1ded4
browser (calls/webrtc): send ICE candidates when received:
- ICE candidates gathering is not waited for anymore
- if session is not ready, candidates are buffered and replayed when suitable
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 21 Aug 2023 15:36:09 +0200 |
parents | eb00d593801d |
children |
rev | line source |
---|---|
1216 | 1 #!/usr/bin/env python3 |
1239 | 2 |
1518
eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents:
1509
diff
changeset
|
3 from libervia.web.server.constants import Const as C |
eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents:
1509
diff
changeset
|
4 from libervia.backend.tools.common import template_xmlui |
eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents:
1509
diff
changeset
|
5 from libervia.backend.core.log import getLogger |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
6 |
1145
29eb15062416
pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents:
1143
diff
changeset
|
7 log = getLogger(__name__) |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1302
diff
changeset
|
8 |
967 | 9 |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1302
diff
changeset
|
10 name = "list_new" |
967 | 11 access = C.PAGES_ACCESS_PROFILE |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1302
diff
changeset
|
12 template = "list/create_item.html" |
967 | 13 |
14 | |
1387
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
15 def parse_url(self, request): |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
16 self.get_path_args(request, ["service", "node"], service="jid", node="@") |
1387
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
17 |
1302
04e7dd6b6f4d
pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents:
1239
diff
changeset
|
18 async def prepare_render(self, request): |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
19 data = self.get_r_data(request) |
973
2e75dc986e03
pages (tickets): URLs for list and new are set in the template for the whole subhierarchy
Goffi <goffi@goffi.org>
parents:
971
diff
changeset
|
20 template_data = request.template_data |
1216 | 21 service, node = data.get("service", ""), data.get("node", "") |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
22 profile = self.get_profile(request) |
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
23 schema = await self.host.bridge_call("list_schema_get", service.full(), node, profile) |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
24 data["schema"] = schema |
967 | 25 # following fields are handled in backend |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
26 ignore = ( |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
27 "author", |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
28 "author_jid", |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
29 "author_email", |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
30 "created", |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
31 "updated", |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
32 "comments_uri", |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
33 "status", |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
34 "milestone", |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
35 "priority", |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
36 ) |
967 | 37 xmlui_obj = template_xmlui.create(self.host, schema, ignore=ignore) |
971
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
38 try: |
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
39 # small trick to get a one line text input instead of the big textarea |
1216 | 40 xmlui_obj.widgets["labels"].type = "string" |
971
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
41 except KeyError: |
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
42 pass |
1143
7bd47d32da87
pages (tickets, merge-requests): convert body from/to markdown while editing/creating new ticket:
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
43 |
1387
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
44 try: |
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
45 wid = xmlui_obj.widgets['body'] |
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
46 except KeyError: |
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
47 pass |
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
48 else: |
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
49 if wid.type == "xhtmlbox": |
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
50 # same as for list_edit, we have to convert for now |
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
51 wid.type = "textbox" |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
52 wid.value = await self.host.bridge_call( |
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
53 "syntax_convert", wid.value, C.SYNTAX_XHTML, "markdown", |
1387
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
54 False, profile) |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1302
diff
changeset
|
55 template_data["new_list_item_xmlui"] = xmlui_obj |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
56 |
967 | 57 |
1302
04e7dd6b6f4d
pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents:
1239
diff
changeset
|
58 async 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:
1387
diff
changeset
|
59 data = self.get_r_data(request) |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
60 service = data["service"] |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
61 node = data["node"] |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
62 posted_data = self.get_all_posted_data(request) |
1387
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
63 if (("title" in posted_data and not posted_data["title"]) |
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
64 or ("body" in posted_data and not posted_data["body"])): |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
65 self.page_error(request, C.HTTP_BAD_REQUEST) |
971
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
66 try: |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
67 posted_data["labels"] = [l.strip() for l in posted_data["labels"][0].split(",")] |
971
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
68 except (KeyError, IndexError): |
6e966ef8d69f
page(tickets/new): use string instead of textbox for labels, and use comma to split them
Goffi <goffi@goffi.org>
parents:
970
diff
changeset
|
69 pass |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
70 profile = self.get_profile(request) |
1143
7bd47d32da87
pages (tickets, merge-requests): convert body from/to markdown while editing/creating new ticket:
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
71 |
7bd47d32da87
pages (tickets, merge-requests): convert body from/to markdown while editing/creating new ticket:
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
72 # we convert back body to XHTML |
1387
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
73 if "body" in posted_data: |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
74 body = await self.host.bridge_call( |
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
75 "syntax_convert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML, |
1387
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
76 False, profile) |
a84383c659b4
lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents:
1378
diff
changeset
|
77 posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, |
1143
7bd47d32da87
pages (tickets, merge-requests): convert body from/to markdown while editing/creating new ticket:
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
78 body=body)] |
7bd47d32da87
pages (tickets, merge-requests): convert body from/to markdown while editing/creating new ticket:
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
79 |
7bd47d32da87
pages (tickets, merge-requests): convert body from/to markdown while editing/creating new ticket:
Goffi <goffi@goffi.org>
parents:
1124
diff
changeset
|
80 |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
81 await self.host.bridge_call( |
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
82 "list_set", service.full(), node, posted_data, "", "", "", profile |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
83 ) |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1302
diff
changeset
|
84 # we don't want to redirect to creation page on success, but to list overview |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
85 data["post_redirect_page"] = ( |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1387
diff
changeset
|
86 self.get_page_by_name("lists"), |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
87 service.full(), |
1216 | 88 node or "@", |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1098
diff
changeset
|
89 ) |