From ee01ef400dc09168d9f2032470e372fb9edd05b6 Mon Sep 17 00:00:00 2001 From: Jan Mach <jan.mach@cesnet.cz> Date: Thu, 20 Feb 2020 19:33:13 +0100 Subject: [PATCH] Fix: Fixed issue with invalid time windows when linking between event search and timeline views. As it turned out the timepager component was modifiing request parameters to generate the links and subsequent components were unable to access original values. (Redmine issue: #4609) --- lib/hawat/app.py | 9 ++++++++- lib/hawat/blueprints/design/templates/_macros_site.html | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/hawat/app.py b/lib/hawat/app.py index 40505158c..16f6cf7bb 100644 --- a/lib/hawat/app.py +++ b/lib/hawat/app.py @@ -490,6 +490,12 @@ def _setup_app_core(app): res = json.load(fp) return res + def make_copy_deep(data): + """ + Make a deep copy of given data structure. + """ + return copy.deepcopy(data) + return dict( get_endpoints_dict = get_endpoints_dict, get_endpoint_class = get_endpoint_class, @@ -521,7 +527,8 @@ def _setup_app_core(app): json_to_yaml = json_to_yaml, get_uuid4 = get_uuid4, get_limit_counter = get_limit_counter, - load_json_from_file = load_json_from_file + load_json_from_file = load_json_from_file, + make_copy_deep = make_copy_deep ) class HawatJSONEncoder(flask.json.JSONEncoder): diff --git a/lib/hawat/blueprints/design/templates/_macros_site.html b/lib/hawat/blueprints/design/templates/_macros_site.html index f288bf8e5..2e05d7c98 100644 --- a/lib/hawat/blueprints/design/templates/_macros_site.html +++ b/lib/hawat/blueprints/design/templates/_macros_site.html @@ -184,7 +184,11 @@ ----------------------------------------------------------------------------- #} -{%- macro render_timepager(qparams, dt_from, tiid) %} +{%- macro render_timepager(qparams_p, dt_from_p, tiid) %} +{%- if dt_from_p %} + {%- set qparams = make_copy_deep(qparams_p) %} + {%- set dt_from = make_copy_deep(dt_from_p) %} + {%- set dt_from = dt_from.replace(tzinfo = None) %} {%- set dt_to = get_datetime_window(tiid, 'next', dt_from) %} {%- if dt_from and dt_to %} @@ -216,6 +220,7 @@ </ul> </nav> {%- endif %} +{%- endif %} {%- endmacro %} -- GitLab