{# # This file is part of Invenio. # Copyright (C) 2015 CERN. # # Invenio is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # Invenio is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Invenio; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} {# Pagination Macro Leverages Twitter-Bootstrap paginate class and Flask-SQLAlchemy Pagination object Args: obj: Flask-SQLAlchemy Pagination object endpoint: redirect enpoint small: wheather should be rendered as small or not Returns: Pagination component It assumes that page exists in the current context. #} {%- macro paginate(obj, small) %} {%- set args = request.args.copy().to_dict() -%} {%- do args.update(request.view_args.copy()) -%} {%- set endpoint = request.endpoint -%}
{%- endmacro %} {# List Status Indicator Macro Args: obj: Flask-SQLAlchemy Pagination object Returns: List Status Indicator component It assumes that page and per_page exists in the current context. #} {%- macro list_status(obj) %} {{ _("Displaying items %(start)d - %(stop)d out of %(total)d", start=(page - 1) * per_page, stop=((page - 1) * per_page) + obj.items|count, total=obj.total) }} {%- endmacro %}