Fix @staticmethod problem for Python 2.7

This commit is contained in:
Gergely Polonkai 2015-05-27 22:35:14 +02:00
parent 06a4d2b395
commit 606ef7df9e

View File

@ -35,9 +35,9 @@ class Competence(models.Model):
def __str__(self): def __str__(self):
return self.name return self.name
@staticmethod @classmethod
def get_similar_comps(name): def get_similar_comps(cls, name):
comps = __class__.objects.values_list('name', flat = True) comps = cls.objects.values_list('name', flat = True)
ret = () ret = ()
for c in comps: for c in comps:
@ -142,10 +142,10 @@ class Booking(models.Model):
end_ts = models.DateTimeField(null = True, blank = True) end_ts = models.DateTimeField(null = True, blank = True)
successful = models.BooleanField(default = True) successful = models.BooleanField(default = True)
@staticmethod @classmethod
def total_booking_time(): def total_booking_time(cls):
return Booking.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
@staticmethod @classmethod
def duck_booking_time(duck): def duck_booking_time(cls, duck):
return Booking.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