Commit abf3cf9a authored by Sandro Lutz's avatar Sandro Lutz
Browse files

Fix issue #3

parent 90be8085
Pipeline #2685 skipped with stage
......@@ -16,11 +16,13 @@ def index():
# Fetch list of burgers with corresponding vote info
# Could probably also be done with SQLAlchemy but too lazy to look up how
# TODO: Query has a bug. Only burgers created by the user himself are returned.
querystring = text('SELECT burger.id AS id, name, description, burger.nethz AS nethz, timestamp, bread, patty, toppings, side, COUNT(vote_1.id) AS vote_count, vote_2.id AS vote_id '
'FROM burger '
'LEFT JOIN vote AS vote_1 ON vote_1.burger_id=burger.id '
'LEFT JOIN vote AS vote_2 ON vote_2.burger_id=burger.id AND vote_2.nethz = :nethz '
'ORDER BY vote_count ')
querystring = text('SELECT burger.id AS id, name, description, burger.nethz AS nethz, timestamp, '
'bread, patty, toppings, side, COUNT(vote_1.id) as vote_count, vote_2.id as vote_id '
'FROM burger '
'LEFT JOIN vote AS vote_1 ON vote_1.burger_id=burger.id '
'LEFT JOIN vote AS vote_2 ON vote_2.burger_id=burger.id AND vote_2.nethz= :nethz '
'GROUP BY burger.id '
'ORDER BY vote_count DESC')
burger_list = db.engine.execute(querystring, nethz=g.user).fetchall()
return render_template('vote.html',
burger_list=burger_list,
......@@ -78,18 +80,18 @@ def vote():
return redirect(url_for('index'))
@app.before_request
def load_user():
'''
Load user data before any request processing
'''
try:
if session['nethz']:
g.user = session['nethz']
return
except KeyError:
pass
g.user = None
# @app.before_request
# def load_user():
# '''
# Load user data before any request processing
# '''
# try:
# if session['nethz']:
# g.user = session['nethz']
# return
# except KeyError:
# pass
# g.user = None
@app.route('/login', methods=['GET', 'POST'])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment