Mercurial > libervia-web
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libervia/web/pages/blog/edit/page_meta.py Fri Jun 02 16:49:28 2023 +0200 @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +from libervia.web.server.constants import Const as C +from libervia.backend.core.log import getLogger +from libervia.backend.tools.common import data_format + +log = getLogger(__name__) + +name = "blog_edit" +access = C.PAGES_ACCESS_PROFILE +template = "blog/publish.html" + + +async def on_data_post(self, request): + profile = self.get_profile(request) + if profile is None: + self.page_error(request, C.HTTP_FORBIDDEN) + request_data = self.get_r_data(request) + title, tags, body = self.get_posted_data(request, ('title', 'tags', 'body')) + mb_data = {"content_rich": body, "allow_comments": True} + title = title.strip() + if title: + mb_data["title_rich"] = title + tags = [t.strip() for t in tags.split(',') if t.strip()] + if tags: + mb_data["tags"] = tags + + await self.host.bridge_call( + 'mb_send', + "", + "", + data_format.serialise(mb_data), + profile + ) + + request_data["post_redirect_page"] = self.get_page_by_name("blog")