From 6678c15c2c0368ed6db21738b0268462eb591661 Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Wed, 22 Apr 2020 18:51:11 +0200 Subject: [PATCH] Fix date compare in machine history view --- logs/models.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/logs/models.py b/logs/models.py index 59466405..0c70c739 100644 --- a/logs/models.py +++ b/logs/models.py @@ -22,6 +22,8 @@ The models definitions for the Machines app """ from reversion.models import Version +from datetime import datetime + from machines.models import IpList from machines.models import Interface from machines.models import Machine @@ -72,6 +74,21 @@ class MachineHistory: self.end = params.get("e", None) search_type = params.get("t", 0) + # Convert dates to datetime objects + if self.start: + self.start = datetime.datetime( + self.start.year, + self.start.month, + self.start.day + ) + + if self.end: + self.end = datetime.datetime( + self.end.year, + self.end.month, + self.end.day + ) + self.events = [] if search_type == "ip": return self.__get_by_ip(search)