|
@@ -33,28 +33,6 @@ class AbstractItem(models.Model):
|
|
|
def __str__(self):
|
|
|
return self.name
|
|
|
|
|
|
- def get_use_class(self):
|
|
|
- raise NotImplemented
|
|
|
-
|
|
|
- def used(self, except_by=None):
|
|
|
- """ Return the used fraction of an item
|
|
|
-
|
|
|
- :type: Service
|
|
|
- :param except_by: exclude this service from the math
|
|
|
- :rtype: float
|
|
|
- """
|
|
|
- sharing_costs = self.get_use_class().objects.filter(resource=self)
|
|
|
- if except_by:
|
|
|
- sharing_costs = sharing_costs.exclude(service=except_by)
|
|
|
-
|
|
|
- existing_uses_sum = sum(
|
|
|
- sharing_costs.values_list('share', flat=True))
|
|
|
-
|
|
|
- return existing_uses_sum
|
|
|
-
|
|
|
- def unused(self):
|
|
|
- return 1-self.used()
|
|
|
-
|
|
|
class Meta:
|
|
|
abstract = True
|
|
|
|