cleaner fix

This commit is contained in:
Aurélien Delobelle 2017-04-04 01:36:19 +02:00
parent df467767f4
commit 7989a07b5f

View file

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