~homeworkprod/byceps

e5d69bcaa1e730af41f73f0f49ad24093ec0ffa2 — Jochen Kupperschmidt 8 months ago 8a2015f
Do not explicitly pass current user to `_may_view_drafts()`, rename function
1 files changed, 4 insertions(+), 4 deletions(-)

M byceps/blueprints/site/news/views.py
M byceps/blueprints/site/news/views.py => byceps/blueprints/site/news/views.py +4 -4
@@ 36,7 36,7 @@ def index(page):
    """Show a page of news items."""
    channel_id = _get_channel_id()
    items_per_page = _get_items_per_page_value()
    published_only = not _may_view_drafts(g.user)
    published_only = not _may_current_user_view_drafts()

    items = news_item_service.get_aggregated_items_paginated(
        channel_id, page, items_per_page, published_only=published_only


@@ 53,7 53,7 @@ def index(page):
def view(slug):
    """Show a single news item."""
    channel_id = _get_channel_id()
    published_only = not _may_view_drafts(g.user)
    published_only = not _may_current_user_view_drafts()

    item = news_item_service.find_aggregated_item_by_slug(
        channel_id, slug, published_only=published_only


@@ 88,5 88,5 @@ def _get_items_per_page_value():
    return int(items_per_page)


def _may_view_drafts(user):
    return user.has_permission(NewsItemPermission.view_draft)
def _may_current_user_view_drafts() -> bool:
    return g.user.has_permission(NewsItemPermission.view_draft)