~homeworkprod/byceps

b4b8423ab2e5a09c85a99ea713ce48b74672d749 — Jochen Kupperschmidt 1 year, 11 months ago fa24778
Obtain number of news items to show per page from site settings instead of configuration file
2 files changed, 12 insertions(+), 5 deletions(-)

M byceps/blueprints/news/views.py
M byceps/config_defaults.py
M byceps/blueprints/news/views.py => byceps/blueprints/news/views.py +12 -2
@@ 6,7 6,7 @@ byceps.blueprints.news.views
:License: Modified BSD, see LICENSE for details.
"""

from flask import abort, current_app, g
from flask import abort, g

from ...services.news import service as news_service
from ...services.site import settings_service as site_settings_service


@@ 23,6 23,9 @@ blueprint = create_blueprint('news', __name__)
permission_registry.register_enum(NewsItemPermission)


DEFAULT_ITEMS_PER_PAGE = 4


@blueprint.route('/', defaults={'page': 1})
@blueprint.route('/pages/<int:page>')
@templated


@@ 73,7 76,14 @@ def _get_channel_id():


def _get_items_per_page_value():
    return int(current_app.config['NEWS_ITEMS_PER_PAGE'])
    items_per_page = site_settings_service.find_setting_value(
        g.site_id, 'news_items_per_page'
    )

    if items_per_page is None:
        return DEFAULT_ITEMS_PER_PAGE

    return int(items_per_page)


def _may_view_drafts(user):

M byceps/config_defaults.py => byceps/config_defaults.py +0 -3
@@ 43,9 43,6 @@ TIMEZONE = 'Europe/Berlin'
ROOT_REDIRECT_TARGET = None
ROOT_REDIRECT_STATUS_CODE = 307

# news item pagination
NEWS_ITEMS_PER_PAGE = 4

# message board pagination
BOARD_TOPICS_PER_PAGE = 10
BOARD_POSTINGS_PER_PAGE = 10