Do not save non-durations as manual
This commit is contained in:
parent
e174850262
commit
86fd40cc4a
|
@ -203,7 +203,7 @@ class Session(models.Model):
|
||||||
def duration_seconds(self) -> timedelta:
|
def duration_seconds(self) -> timedelta:
|
||||||
manual = timedelta(0)
|
manual = timedelta(0)
|
||||||
calculated = timedelta(0)
|
calculated = timedelta(0)
|
||||||
if self.is_manual():
|
if self.is_manual() and isinstance(self.duration_manual, timedelta):
|
||||||
manual = self.duration_manual
|
manual = self.duration_manual
|
||||||
if self.timestamp_end != None and self.timestamp_start != None:
|
if self.timestamp_end != None and self.timestamp_start != None:
|
||||||
calculated = self.timestamp_end - self.timestamp_start
|
calculated = self.timestamp_end - self.timestamp_start
|
||||||
|
@ -226,6 +226,9 @@ class Session(models.Model):
|
||||||
else:
|
else:
|
||||||
self.duration_calculated = timedelta(0)
|
self.duration_calculated = timedelta(0)
|
||||||
|
|
||||||
|
if not isinstance(self.duration_manual, timedelta):
|
||||||
|
self.duration_manual = timedelta(0)
|
||||||
|
|
||||||
if not self.device:
|
if not self.device:
|
||||||
default_device, _ = Device.objects.get_or_create(
|
default_device, _ = Device.objects.get_or_create(
|
||||||
type=Device.UNKNOWN, defaults={"name": "Unknown"}
|
type=Device.UNKNOWN, defaults={"name": "Unknown"}
|
||||||
|
|
Loading…
Reference in New Issue