Mercurial > libervia-web
annotate libervia/pages/blog/edit/page_meta.py @ 1509:106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:44:11 +0200 |
parents | 081b4f8a63d8 |
children |
rev | line source |
---|---|
1416 | 1 #!/usr/bin/env python3 |
2 | |
3 from libervia.server.constants import Const as C | |
4 from sat.core.log import getLogger | |
5 from sat.tools.common import data_format | |
6 | |
7 log = getLogger(__name__) | |
8 | |
9 name = "blog_edit" | |
10 access = C.PAGES_ACCESS_PROFILE | |
11 template = "blog/publish.html" | |
12 | |
13 | |
14 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:
1495
diff
changeset
|
15 profile = self.get_profile(request) |
1416 | 16 if profile is None: |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1495
diff
changeset
|
17 self.page_error(request, C.HTTP_FORBIDDEN) |
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1495
diff
changeset
|
18 request_data = self.get_r_data(request) |
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1495
diff
changeset
|
19 title, tags, body = self.get_posted_data(request, ('title', 'tags', 'body')) |
1495
081b4f8a63d8
pages (blog/edit): allow comments when editing a post
Goffi <goffi@goffi.org>
parents:
1420
diff
changeset
|
20 mb_data = {"content_rich": body, "allow_comments": True} |
1416 | 21 title = title.strip() |
22 if title: | |
23 mb_data["title_rich"] = title | |
24 tags = [t.strip() for t in tags.split(',') if t.strip()] | |
25 if tags: | |
26 mb_data["tags"] = tags | |
27 | |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1495
diff
changeset
|
28 await self.host.bridge_call( |
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1495
diff
changeset
|
29 'mb_send', |
1416 | 30 "", |
31 "", | |
32 data_format.serialise(mb_data), | |
33 profile | |
34 ) | |
1420
925a7c498cda
pages (blog/edit): move preview code to new `BlogEditor` class in `editor` module
Goffi <goffi@goffi.org>
parents:
1416
diff
changeset
|
35 |
1509
106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents:
1495
diff
changeset
|
36 request_data["post_redirect_page"] = self.get_page_by_name("blog") |