Ejemplo n.º 1
0
def unpublish_post(update: Update, context: CallbackContext) -> None:
    _, post_id = update.callback_query.data.split(":", 1)

    post = Post.objects.get(id=post_id)
    if not post.is_visible:
        update.effective_chat.send_message(
            f"Пост «{post.title}» уже перенесен в черновики")
        update.callback_query.edit_message_reply_markup(reply_markup=None)
        return None

    post.is_visible = False
    post.save()

    SearchIndex.update_post_index(post)

    notify_post_author_rejected(post)

    update.effective_chat.send_message(
        f"👎 Пост «{post.title}» перенесен в черновики ({update.effective_user.full_name})"
    )

    # hide buttons
    update.callback_query.edit_message_reply_markup(reply_markup=None)

    return None
Ejemplo n.º 2
0
def unpublish_post(post_id: str, update: Update) -> (str, bool):
    post = Post.objects.get(id=post_id)
    if not post.is_visible:
        return f"Пост «{post.title}» уже перенесен в черновики", True

    post.is_visible = False
    post.save()

    notify_post_author_rejected(post)

    return f"👎 Пост «{post.title}» перенесен в черновики ({update.effective_user.full_name})", True