feat: human readable duration

This commit is contained in:
relikd
2023-10-08 18:24:27 +02:00
parent 7c64e898f4
commit e4f1d2b8d3
3 changed files with 15 additions and 4 deletions

View File

@@ -72,6 +72,17 @@ class Booking(models.Model):
return round(diff.total_seconds() / 60)
return None
@property
def human_duration(self) -> 'str|None':
total = self.duration
if total is None:
return None
if total > 1440:
return f'> {total // 1440}T'
min = total % 60
hour = (total - min) // 60
return f'{hour}:{min:02d}'
@property
def calculated_price(self):
traits = self.user.traits_at_date(self.begin_time).values_list('trait')