mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-07 21:04:00 +02:00
brmbar-web: Color rows by balance
This commit is contained in:
parent
400ef9e969
commit
ae82675a60
1 changed files with 7 additions and 1 deletions
|
@ -16,7 +16,13 @@ def stock():
|
||||||
# FIXME: XSS protection.
|
# FIXME: XSS protection.
|
||||||
response = '<table border="1"><tr><th>Id</th><th>Item Name</th><th>Bal.</th></tr>'
|
response = '<table border="1"><tr><th>Id</th><th>Item Name</th><th>Bal.</th></tr>'
|
||||||
for a in shop.account_list("inventory"):
|
for a in shop.account_list("inventory"):
|
||||||
response += '<tr><td>%d</td><td>%s</td><td>%d</td></tr>' % (a.id, a.name, a.balance())
|
style = ''
|
||||||
|
balance = a.balance()
|
||||||
|
if balance == 0:
|
||||||
|
style = 'color: grey; font-style: italic'
|
||||||
|
elif balance < 0:
|
||||||
|
style = 'color: red'
|
||||||
|
response += '<tr style="%s"><td>%d</td><td>%s</td><td>%d</td></tr>' % (style, a.id, a.name, balance)
|
||||||
response += '</table>'
|
response += '</table>'
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue