Fix formatting issues

This commit is contained in:
Alexandre Iooss 2020-02-18 21:14:29 +01:00
parent cd98f96cd0
commit e679a4b629
No known key found for this signature in database
GPG key ID: 6C79278F3FCDCC02
16 changed files with 63 additions and 72 deletions

View file

@ -1,4 +1,3 @@
#!/usr/bin/env python
import django_tables2 as tables
from django.db.models import F
@ -15,11 +14,10 @@ class HistoryTable(tables.Table):
template_name = 'django_tables2/bootstrap.html'
sequence = ('...', 'total', 'valid')
total = tables.Column() #will use Transaction.total() !!
total = tables.Column() # will use Transaction.total() !!
def order_total(self, QuerySet, is_descending):
def order_total(self, queryset, is_descending):
# needed for rendering
QuerySet = QuerySet.annotate(
total=F('amount') *
F('quantity')).order_by(('-' if is_descending else '') + 'total')
return (QuerySet, True)
queryset = queryset.annotate(total=F('amount') * F('quantity')) \
.order_by(('-' if is_descending else '') + 'total')
return (queryset, True)