mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-30 04:13:01 +00:00
21 lines
692 B
Python
21 lines
692 B
Python
#!/usr/bin/env python
|
|
import django_tables2 as tables
|
|
from .models.transactions import Transaction
|
|
|
|
|
|
class HistoryTable(tables.Table):
|
|
class Meta:
|
|
attrs = {'class':'table table-bordered table-condensed table-striped table-hover'}
|
|
model = Transaction
|
|
template_name = 'django_tables2/bootstrap.html'
|
|
sequence = ('...','total','valid')
|
|
|
|
total = tables.Column() #will use Transaction.total() !!
|
|
|
|
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)
|