From 7989a07b5f61d7f4acb5165811b5c4765e43934f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Tue, 4 Apr 2017 01:36:19 +0200 Subject: [PATCH] cleaner fix --- kfet/views.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kfet/views.py b/kfet/views.py index 8f5cdb3a..69126634 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -2305,16 +2305,17 @@ class AccountStatOperation(ScaleMixin, PkUrlMixin, JSONDetailView): context_object_name = 'account' id_prefix = "" - def get_operations(self, types, scale): + def get_operations(self, scale, types=None): # On selectionne les opérations qui correspondent # à l'article en question et qui ne sont pas annulées # puis on choisi pour chaques intervalle les opérations # effectuées dans ces intervalles de temps all_operations = (Operation.objects - .filter(type__in=types) .filter(group__on_acc=self.object) .filter(canceled_at=None) ) + if types is not None: + all_operations = all_operations.filter(type__in==types) chunks = self.chunkify_qs(all_operations, scale, field='group__at') return chunks @@ -2324,9 +2325,7 @@ class AccountStatOperation(ScaleMixin, PkUrlMixin, JSONDetailView): scale = self.scale types = self.request.GET.get('types', None) - if types is None: - types = [] - else: + if types is not None: types = ast.literal_eval(types) operations = self.get_operations(types=types, scale=scale)