diff --git a/brmbar3/brmbar-web.py b/brmbar3/brmbar-web.py index 457a628..0ec70dc 100755 --- a/brmbar3/brmbar-web.py +++ b/brmbar3/brmbar-web.py @@ -10,8 +10,8 @@ from flask import * app = Flask(__name__) #app.debug = True -@app.route('/stock') -def stock(): +@app.route('/stock/') +def stock(show_all=False): # TODO: Use a fancy template. # FIXME: XSS protection. response = '' @@ -19,13 +19,23 @@ def stock(): style = '' balance = a.balance() if balance == 0: + if not show_all: + continue style = 'color: grey; font-style: italic' elif balance < 0: style = 'color: red' response += '' % (style, a.id, a.name, balance) response += '
IdItem NameBal.
%d%s%d
' + if show_all: + response += '

(hide out-of-stock items)

' + else: + response += '

(show all items)

' return response +@app.route('/stock/all') +def stockall(): + return stock(show_all=True) + db = Database.Database("dbname=brmbar") shop = brmbar.Shop.new_with_defaults(db)