Only parse dates if the field is valid
This commit is contained in:
parent
648526a6bf
commit
16c03bc19a
|
@ -34,10 +34,8 @@ class DrilldownTableView(View, SingleTableMixin):
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
if self.request.htmx:
|
if self.request.htmx:
|
||||||
print("IS HTMX")
|
|
||||||
template_name = "ui/drilldown/table_results.html"
|
template_name = "ui/drilldown/table_results.html"
|
||||||
else:
|
else:
|
||||||
print("IS NOT HTMX")
|
|
||||||
template_name = "ui/drilldown/table_results_partial.html"
|
template_name = "ui/drilldown/table_results_partial.html"
|
||||||
|
|
||||||
if context:
|
if context:
|
||||||
|
@ -64,10 +62,6 @@ def parse_dates(dates):
|
||||||
"from_time": from_time,
|
"from_time": from_time,
|
||||||
"to_time": to_time,
|
"to_time": to_time,
|
||||||
}
|
}
|
||||||
else:
|
|
||||||
message = "Invalid dates"
|
|
||||||
message_class = "danger"
|
|
||||||
return {"message": message, "class": message_class}
|
|
||||||
|
|
||||||
|
|
||||||
def create_tags(query):
|
def create_tags(query):
|
||||||
|
@ -92,6 +86,7 @@ def drilldown_search(request):
|
||||||
if "dates" in query_params:
|
if "dates" in query_params:
|
||||||
dates = parse_dates(query_params["dates"])
|
dates = parse_dates(query_params["dates"])
|
||||||
del query_params["dates"]
|
del query_params["dates"]
|
||||||
|
if dates:
|
||||||
if "message" in dates:
|
if "message" in dates:
|
||||||
return render(request, template_name, dates)
|
return render(request, template_name, dates)
|
||||||
query_params["from_date"] = dates["from_date"]
|
query_params["from_date"] = dates["from_date"]
|
||||||
|
|
Loading…
Reference in New Issue