From 16c03bc19a2252e64fe90acffac34e2615b53784 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Tue, 9 Aug 2022 07:20:30 +0100 Subject: [PATCH] Only parse dates if the field is valid --- core/views/ui/drilldown.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/core/views/ui/drilldown.py b/core/views/ui/drilldown.py index 4c96ffd..93c00cf 100644 --- a/core/views/ui/drilldown.py +++ b/core/views/ui/drilldown.py @@ -34,10 +34,8 @@ class DrilldownTableView(View, SingleTableMixin): return render(request, self.template_name, context) if self.request.htmx: - print("IS HTMX") template_name = "ui/drilldown/table_results.html" else: - print("IS NOT HTMX") template_name = "ui/drilldown/table_results_partial.html" if context: @@ -64,10 +62,6 @@ def parse_dates(dates): "from_time": from_time, "to_time": to_time, } - else: - message = "Invalid dates" - message_class = "danger" - return {"message": message, "class": message_class} def create_tags(query): @@ -92,12 +86,13 @@ def drilldown_search(request): if "dates" in query_params: dates = parse_dates(query_params["dates"]) del query_params["dates"] - if "message" in dates: - return render(request, template_name, dates) - query_params["from_date"] = dates["from_date"] - query_params["to_date"] = dates["to_date"] - query_params["from_time"] = dates["from_time"] - query_params["to_time"] = dates["to_time"] + if dates: + if "message" in dates: + return render(request, template_name, dates) + query_params["from_date"] = dates["from_date"] + query_params["to_date"] = dates["to_date"] + query_params["from_time"] = dates["from_time"] + query_params["to_time"] = dates["to_time"] if request.GET: context = query_results(request, query_params)