Prevent error from empty timestamps
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Lukáš Kucharczyk 2023-01-03 20:23:49 +01:00
parent 126e758172
commit c6bb60bbbb
1 changed files with 4 additions and 1 deletions

View File

@ -41,7 +41,10 @@ class Session(models.Model):
return f"{str(self.purchase)} {str(self.timestamp_start.date())} ({self.total_duration()}{mark})" return f"{str(self.purchase)} {str(self.timestamp_start.date())} ({self.total_duration()}{mark})"
def calculated_duration(self): def calculated_duration(self):
return self.timestamp_end - self.timestamp_start if self.timestamp_end == None or self.timestamp_start == None:
return 0
else:
return self.timestamp_end - self.timestamp_start
def total_duration(self): def total_duration(self):
return ( return (