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