def get_customer_points_ total self customer cache getattr self _total

1
2
3
4
5
6
7
def get_customer_points_total(self, customer):
cache = getattr(self, '_total_points_cache', {})
if customer.id not in cache:
cache[customer.id] = customer.customerpoints_set.total()
self._total_points_cache = cache
return cache[customer.id]