SQL now correctly filters based on user_meta
This commit is contained in:
parent
32c0baedaf
commit
0bb5a5823b
14
shop.py
14
shop.py
@ -99,6 +99,15 @@ def update_pass(user_id, newpass):
|
|||||||
data = (newpass, user_id)
|
data = (newpass, user_id)
|
||||||
runQuery(query, data)
|
runQuery(query, data)
|
||||||
|
|
||||||
|
def get_items(user_id, list_id=None):
|
||||||
|
if list_id != None:
|
||||||
|
query = "select SHOPLIST.id, SHOPLIST.item, SHOPLIST.gotten, USERS.username from SHOPLIST inner join USERS on SHOPLIST.user_id = USERS.id inner join USER_META on SHOPLIST.list_id = USER_META.list_id where USER_META.user_id = %s and SHOPLIST.list_id = %s"
|
||||||
|
data = (user_id, list_id)
|
||||||
|
return runQuery(query, data)
|
||||||
|
query = "select SHOPLIST.id, SHOPLIST.item, SHOPLIST.gotten, USERS.username from SHOPLIST inner join USERS on SHOPLIST.user_id = USERS.id inner join USER_META on SHOPLIST.list_id = USER_META.list_id where USER_META.user_id = %s"
|
||||||
|
data = (user_id,)
|
||||||
|
return runQuery(query, data)
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config["DEBUG"] = True
|
app.config["DEBUG"] = True
|
||||||
app.secret_key = b'*$#@U9423jr92jioJKL_)_;dasfj()12'
|
app.secret_key = b'*$#@U9423jr92jioJKL_)_;dasfj()12'
|
||||||
@ -109,8 +118,9 @@ def index():
|
|||||||
data = {"title":"Login"}
|
data = {"title":"Login"}
|
||||||
return render_template("auth.html", data=data)
|
return render_template("auth.html", data=data)
|
||||||
|
|
||||||
query = readFromDB()
|
#Get initial data, contains all lists the user is apart of
|
||||||
data = {"title": "Shopping List", "results": query, "username": session["username"]}
|
res = get_items(session["id"])
|
||||||
|
data = {"title": "Shopping List", "results": res, "username": session["username"]}
|
||||||
for device in MOBILES:
|
for device in MOBILES:
|
||||||
if device in request.user_agent.platform:
|
if device in request.user_agent.platform:
|
||||||
return render_template('mobile.html', data=data)
|
return render_template('mobile.html', data=data)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user