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)
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue