From d15bbfa0c568999bf1b3f9c183b2552dc6bb15b3 Mon Sep 17 00:00:00 2001 From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de> Date: Sat, 17 Mar 2018 13:38:39 +0100 Subject: [PATCH] Replace page_link macros by generic version --- templates/decisions-list.html | 4 ++-- templates/macros.html | 12 ++++++++++++ templates/pagination-footer.html | 1 + templates/protocols-list.html | 12 ------------ templates/todos-list.html | 10 ---------- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/templates/decisions-list.html b/templates/decisions-list.html index 667eef2..9cf5721 100644 --- a/templates/decisions-list.html +++ b/templates/decisions-list.html @@ -2,7 +2,7 @@ {% from "macros.html" import render_table, render_form %} {% block title %}Beschlüsse{% endblock %} -{% macro page_link(text, _page=None, _page_length=None) %} +{#{% macro page_link(text, _page=None, _page_length=None) %} {% if _page is none %} {% set _page = page %} {% endif %} @@ -10,7 +10,7 @@ {% set _page_length = page_length %} {% endif %} <a href="{{url_for(request.endpoint, page=_page, protocoltype_id=protocoltype_id, search=search_term, decisioncategory_id=decisioncategory_id, page_length=_page_length)}}">{{text}}</a> -{% endmacro %} +{% endmacro %}#} {% block content %} <div class="container"> diff --git a/templates/macros.html b/templates/macros.html index e6d0edd..230a100 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -165,6 +165,18 @@ to not render a label for the CRSFTokenField --> </table> {%- endmacro %} +{% macro page_link(text, _page=None, _page_length=None) -%} + {% set args = request.view_args.copy() %} + {% set _ = args.update(request.args) %} + {% if _page is not none %} + {% set _ = args.update({"page": _page}) %} + {% endif %} + {% if _page_length is not none %} + {% set _ = args.update({"page_length": _page_length}) %} + {% endif %} + <a href="{{url_for(request.endpoint, **args)}}">{{text}}</a> +{%- endmacro %} + {% macro render_likes(likes) -%} {% set timestamp = now() %} {% if timestamp.month == 4 and timestamp.day == 1 %} diff --git a/templates/pagination-footer.html b/templates/pagination-footer.html index 1f34556..19ae96b 100644 --- a/templates/pagination-footer.html +++ b/templates/pagination-footer.html @@ -1,3 +1,4 @@ +{% from "macros.html" import page_link %} <div class="centered"> {% if page > page_diff %} {{page_link("<<", _page=0)}} diff --git a/templates/protocols-list.html b/templates/protocols-list.html index 02d3c81..e019a25 100644 --- a/templates/protocols-list.html +++ b/templates/protocols-list.html @@ -2,18 +2,6 @@ {% from "macros.html" import render_table, render_form %} {% block title %}Protokolle{% endblock %} -{% macro page_link(text, _page=None, _page_length=None) %} - {% if _page is none %} - {% set _page = page %} - {% endif %} - {% if _page_length is none %} - {% set _page_length = page_length %} - {% endif %} - <a href="{{url_for(request.endpoint, page=_page, protocoltype_id=protocoltype_id, search=search_term, state_open=state_open, page_length=_page_length)}}">{{text}}</a> -{% endmacro %} - - - {% block content %} <div class="container"> {{render_form(search_form, class_="form-inline", action_url=url_for("list_protocols"), action_text="Suchen", labels_visible=False, method="GET")}} diff --git a/templates/todos-list.html b/templates/todos-list.html index 0734992..0c9923e 100644 --- a/templates/todos-list.html +++ b/templates/todos-list.html @@ -2,16 +2,6 @@ {% from "macros.html" import render_table, render_form %} {% block title %}Todos{% endblock %} -{% macro page_link(text, _page=None, _page_length=None) %} - {% if _page is none %} - {% set _page = page %} - {% endif %} - {% if _page_length is none %} - {% set _page_length = page_length %} - {% endif %} - <a href="{{url_for(request.endpoint, page=_page, protocoltype_id=protocoltype_id, search=search_term, state_open=state_open, page_length=_page_length)}}">{{text}}</a> -{% endmacro %} - {% block content %} <div class="container"> {{render_form(search_form, class_="form-inline", action_url=url_for("list_todos"), action_text="Suchen", labels_visible=False, method="GET")}} -- GitLab