view libervia/pages/blog/edit/page_meta.py @ 1466:cff720e26089

pages (blog/view): activate pagination when a single item is shown: `previous_page_url` and `next_page_url` are set when `item_id` is used. For now, they are both activated even if there is no item before or after, as it would request to make extra request to check it. This may be improved in 0.9 by using internal cache. fix 399
author Goffi <goffi@goffi.org>
date Thu, 30 Sep 2021 17:04:22 +0200
parents 925a7c498cda
children 081b4f8a63d8
line wrap: on
line source

#!/usr/bin/env python3

from libervia.server.constants import Const as C
from sat.core.log import getLogger
from sat.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.getProfile(request)
    if profile is None:
        self.pageError(request, C.HTTP_FORBIDDEN)
    request_data = self.getRData(request)
    title, tags, body = self.getPostedData(request, ('title', 'tags', 'body'))
    mb_data = {"content_rich": body}
    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.bridgeCall(
        'mbSend',
        "",
        "",
        data_format.serialise(mb_data),
        profile
    )

    request_data["post_redirect_page"] = self.getPageByName("blog")