Example #1
0
def configure_template_filters(app):
    """Configures the template filters."""
    filters = {}

    filters["crop_title"] = crop_title
    filters["format_date"] = format_date
    filters["format_datetime"] = format_datetime
    filters["forum_is_unread"] = forum_is_unread
    filters["is_online"] = is_online
    filters["time_since"] = time_since
    filters["topic_is_unread"] = topic_is_unread

    permissions = [
        ("is_admin", IsAdmin),
        ("is_moderator", IsAtleastModerator),
        ("is_admin_or_moderator", IsAtleastModerator),
        ("can_edit_user", CanEditUser),
        ("can_ban_user", CanBanUser),
    ]

    filters.update(
        (name, permission_with_identity(perm, name=name))
        for name, perm in permissions
    )

    filters["can_moderate"] = can_moderate
    filters["post_reply"] = can_post_reply
    filters["edit_post"] = can_edit_post
    filters["delete_post"] = can_edit_post
    filters["post_topic"] = can_post_topic
    filters["delete_topic"] = can_delete_topic
    filters["has_permission"] = has_permission

    app.jinja_env.filters.update(filters)

    app.jinja_env.globals["run_hook"] = template_hook
    app.jinja_env.globals["NavigationContentType"] = NavigationContentType
    app.jinja_env.globals["get_random_logo"] = get_random_logo

    app.pluggy.hook.flaskbb_jinja_directives(app=app)
Example #2
0
def configure_template_filters(app):
    """Configures the template filters."""
    filters = {}

    filters["crop_title"] = crop_title
    filters["format_date"] = format_date
    filters["format_datetime"] = format_datetime
    filters["forum_is_unread"] = forum_is_unread
    filters["is_online"] = is_online
    filters["time_since"] = time_since
    filters["topic_is_unread"] = topic_is_unread

    permissions = [
        ("is_admin", IsAdmin),
        ("is_moderator", IsAtleastModerator),
        ("is_admin_or_moderator", IsAtleastModerator),
        ("can_edit_user", CanEditUser),
        ("can_ban_user", CanBanUser),
    ]

    filters.update(
        (name, permission_with_identity(perm, name=name))
        for name, perm in permissions
    )

    filters["can_moderate"] = can_moderate
    filters["post_reply"] = can_post_reply
    filters["edit_post"] = can_edit_post
    filters["delete_post"] = can_edit_post
    filters["post_topic"] = can_post_topic
    filters["delete_topic"] = can_delete_topic
    filters["has_permission"] = has_permission

    app.jinja_env.filters.update(filters)

    app.jinja_env.globals["run_hook"] = template_hook
    app.jinja_env.globals["NavigationContentType"] = NavigationContentType

    app.pluggy.hook.flaskbb_jinja_directives(app=app)