From 2f7dc9ec1959ba8d39442504f0638081213a5f02 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Thu, 8 Sep 2016 04:15:34 +0200 Subject: [PATCH] Used lambda function in user detail --- core/views/user.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/core/views/user.py b/core/views/user.py index 39ff5e68..b239284c 100644 --- a/core/views/user.py +++ b/core/views/user.py @@ -345,18 +345,12 @@ class UserAccountView(UserAccountBase): return stats - def buyings_calc(self, query): - return query.unit_price * query.quantity - def invoices_calc(self, query): t = 0 for it in query.items.all(): t += it.quantity * it.product_unit_price return t - def refilling_calc(self, query): - return query.amount - def get_context_data(self, **kwargs): kwargs = super(UserAccountView, self).get_context_data(**kwargs) kwargs['profile'] = self.object @@ -364,7 +358,7 @@ class UserAccountView(UserAccountBase): kwargs['customer'] = self.object.customer kwargs['buyings_month'] = self.expense_by_month( self.object.customer.buyings, - self.buyings_calc + (lambda q: q.unit_price * q.quantity) ) kwargs['invoices_month'] = self.expense_by_month( self.object.customer.user.invoices, @@ -372,7 +366,7 @@ class UserAccountView(UserAccountBase): ) kwargs['refilling_month'] = self.expense_by_month( self.object.customer.refillings, - self.refilling_calc + (lambda q: q.amount) ) except: pass