Save calculated duration to database

This commit is contained in:
Lukáš Kucharczyk 2023-01-04 17:25:19 +01:00
parent bf61326c18
commit b3842504af
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
2 changed files with 6 additions and 0 deletions

View File

@ -3,3 +3,4 @@
* Set default version to "git-main" to indicate development environment
* Add homepage, link to it from the logo
* Make it possible to add a new platform
* Save calculated duration to database if both timestamps are set

View File

@ -52,3 +52,8 @@ class Session(models.Model):
if self.duration_manual == None
else self.duration_manual + self.calculated_duration()
)
def save(self, *args, **kwargs):
if self.timestamp_start != None and self.timestamp_end != None:
self.duration_calculated = self.timestamp_end - self.timestamp_start
super(Session, self).save(*args, **kwargs)