mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 01:48:21 +02:00
Format code
This commit is contained in:
@ -7,16 +7,19 @@ from .models.transactions import Transaction
|
||||
|
||||
class HistoryTable(tables.Table):
|
||||
class Meta:
|
||||
attrs = {'class':'table table-bordered table-condensed table-striped table-hover'}
|
||||
attrs = {
|
||||
'class':
|
||||
'table table-bordered table-condensed table-striped table-hover'
|
||||
}
|
||||
model = Transaction
|
||||
template_name = 'django_tables2/bootstrap.html'
|
||||
sequence = ('...','total','valid')
|
||||
sequence = ('...', 'total', 'valid')
|
||||
|
||||
total = tables.Column() #will use Transaction.total() !!
|
||||
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')
|
||||
total=F('amount') *
|
||||
F('quantity')).order_by(('-' if is_descending else '') + 'total')
|
||||
return (QuerySet, True)
|
||||
|
Reference in New Issue
Block a user