Browse Source

Refactor used()/unused() to AbstractResource

Jocelyn Delande 9 years ago
parent
commit
0751e1d76b
1 changed files with 0 additions and 22 deletions
  1. 0 22
      costs/models.py

+ 0 - 22
costs/models.py

@@ -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