Fix booking models
Indentation, line breaks, etc.
This commit is contained in:
parent
cdce3803a5
commit
0678db84df
@ -59,11 +59,11 @@ class Duck(models.Model):
|
||||
comps = models.ManyToManyField(Competence, through='DuckCompetence')
|
||||
donated_by = models.ForeignKey(User)
|
||||
donated_at = models.DateTimeField(default=timezone.now)
|
||||
adopted_by = models.ForeignKey(User, related_name = 'adopted_ducks', null = True)
|
||||
adopted_at = models.DateTimeField(null = True)
|
||||
adopted_by = models.ForeignKey(User, related_name='adopted_ducks', null=True, blank=True)
|
||||
adopted_at = models.DateTimeField(null=True, blank=True)
|
||||
bookings = models.ManyToManyField(User, through='Booking', related_name='+')
|
||||
on_holiday_since = models.DateTimeField(null = True)
|
||||
on_holiday_until = models.DateTimeField(null = True)
|
||||
on_holiday_since = models.DateTimeField(null=True, blank=True)
|
||||
on_holiday_until = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
if self.name == None or self.name == '':
|
||||
@ -144,8 +144,20 @@ class Booking(models.Model):
|
||||
|
||||
@classmethod
|
||||
def total_booking_time(cls):
|
||||
return cls.objects.filter(start_ts__isnull = False, end_ts__isnull = False).extra(select = {'amount': 'sum(strftime(%s, end_ts) - strftime(%s, start_ts))'}, select_params = ('%s', '%s'))[0].amount
|
||||
return cls.objects.filter(
|
||||
start_ts__isnull=False,
|
||||
end_ts__isnull=False).extra(
|
||||
select={
|
||||
'amount': 'sum(strftime(%s, end_ts) - strftime(%s, start_ts))'
|
||||
},
|
||||
select_params=('%s', '%s'))[0].amount
|
||||
|
||||
@classmethod
|
||||
def duck_booking_time(cls, duck):
|
||||
return cls.objects.filter(start_ts__isnull = False, end_ts__isnull = False, duck = duck).extra(select = {'amount': 'sum(strftime(%s, end_ts) - strftime(%s, start_ts))'}, select_params = ('%s', '%s'))[0].amount
|
||||
return cls.objects.filter(
|
||||
start_ts__isnull=False,
|
||||
end_ts__isnull=False, duck = duck).extra(
|
||||
select={
|
||||
'amount': 'sum(strftime(%s, end_ts) - strftime(%s, start_ts))'
|
||||
},
|
||||
select_params=('%s', '%s'))[0].amount
|
||||
|
Loading…
Reference in New Issue
Block a user