comparison libervia/web/pages/blog/edit/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/blog/edit/page_meta.py@106bae41f5c8
children
comparison
equal deleted inserted replaced
1517:b8ed9726525b 1518:eb00d593801d
1 #!/usr/bin/env python3
2
3 from libervia.web.server.constants import Const as C
4 from libervia.backend.core.log import getLogger
5 from libervia.backend.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):
15 profile = self.get_profile(request)
16 if profile is None:
17 self.page_error(request, C.HTTP_FORBIDDEN)
18 request_data = self.get_r_data(request)
19 title, tags, body = self.get_posted_data(request, ('title', 'tags', 'body'))
20 mb_data = {"content_rich": body, "allow_comments": True}
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
28 await self.host.bridge_call(
29 'mb_send',
30 "",
31 "",
32 data_format.serialise(mb_data),
33 profile
34 )
35
36 request_data["post_redirect_page"] = self.get_page_by_name("blog")