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): |
|
15 profile = self.getProfile(request) |
|
16 if profile is None: |
|
17 self.pageError(request, C.HTTP_FORBIDDEN) |
|
18 request_data = self.getRData(request) |
|
19 request_data["post_redirect_page"] = self.getPageByName("blog") |
|
20 title, tags, body = self.getPostedData(request, ('title', 'tags', 'body')) |
|
21 mb_data = {"content_rich": body} |
|
22 title = title.strip() |
|
23 if title: |
|
24 mb_data["title_rich"] = title |
|
25 tags = [t.strip() for t in tags.split(',') if t.strip()] |
|
26 if tags: |
|
27 mb_data["tags"] = tags |
|
28 |
|
29 await self.host.bridgeCall( |
|
30 'mbSend', |
|
31 "", |
|
32 "", |
|
33 data_format.serialise(mb_data), |
|
34 profile |
|
35 ) |