brmbar-web: Color rows by balance

This commit is contained in:
Petr Baudis 2014-04-06 21:18:36 +02:00
parent 400ef9e969
commit ae82675a60

View file

@ -16,7 +16,13 @@ def stock():
# FIXME: XSS protection.
response = '<table border="1"><tr><th>Id</th><th>Item Name</th><th>Bal.</th></tr>'
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>'
return response