Added list selection on index
This commit is contained in:
parent
2d4a35814d
commit
7082dc86fe
20
shop.py
20
shop.py
@ -123,10 +123,17 @@ def index():
|
|||||||
if session.get('id') is None:
|
if session.get('id') is None:
|
||||||
data = {"title":"Login"}
|
data = {"title":"Login"}
|
||||||
return render_template("auth.html", data=data)
|
return render_template("auth.html", data=data)
|
||||||
|
try:
|
||||||
#Get initial data, contains all lists the user is apart of
|
if request.args["list"]:
|
||||||
res = get_items(session["id"])
|
print(request.args["list"])
|
||||||
data = {"title": "Shopping List", "results": res, "username": session["username"], "list_ids": session["list_ids"]}
|
res = get_items(session["id"], request.args["list"])
|
||||||
|
else:
|
||||||
|
res = get_items(session["id"])
|
||||||
|
data = {"title": "Shopping List", "results": res, "username": session["username"], "list_ids": session["list_ids"]}
|
||||||
|
except KeyError:
|
||||||
|
#Get initial data, contains all lists the user is apart of unless list is defined
|
||||||
|
res = get_items(session["id"])
|
||||||
|
data = {"title": "Shopping List", "results": res, "username": session["username"], "list_ids": session["list_ids"]}
|
||||||
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)
|
||||||
@ -134,6 +141,7 @@ def index():
|
|||||||
|
|
||||||
@app.route('/post', methods=['POST'])
|
@app.route('/post', methods=['POST'])
|
||||||
def handle_data():
|
def handle_data():
|
||||||
|
|
||||||
if "addValue" in request.form:
|
if "addValue" in request.form:
|
||||||
for x in request.form:
|
for x in request.form:
|
||||||
if request.form[x] == '':
|
if request.form[x] == '':
|
||||||
@ -177,6 +185,10 @@ def handle_data():
|
|||||||
|
|
||||||
if "logout" in request.form:
|
if "logout" in request.form:
|
||||||
session.clear()
|
session.clear()
|
||||||
|
|
||||||
|
if "changeList" in request.form:
|
||||||
|
pprint(request.form["changeList"])
|
||||||
|
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@app.route("/admin")
|
@app.route("/admin")
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
* {
|
* {
|
||||||
color: azure;
|
color: azure;
|
||||||
}
|
}
|
||||||
aside {
|
aside {
|
||||||
width: 20%;
|
width: 20%;
|
||||||
|
|||||||
@ -1,7 +1,21 @@
|
|||||||
{% include "header.html" %}
|
{% include "header.html" %}
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1 class="container" style="text-align: center">{{ data["title"] }}, {{data["username"].title()}}</h1>
|
<h1 class="container" style="text-align: center">{{ data["title"] }}, {{data["username"].title()}}
|
||||||
|
<div class="dropdown">
|
||||||
|
<form action="/" method="get" id="test">
|
||||||
|
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
Lists
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
||||||
|
<button class="dropdown-item" type="submit" value="" id="" name="list">All</button>
|
||||||
|
{% for id, name in data["list_ids"] %}
|
||||||
|
<button class="dropdown-item" type="submit" value="{{id}}" id="{{id}}" name="list">{{name}}</button>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</h1>
|
||||||
<!-- <aside> -->
|
<!-- <aside> -->
|
||||||
<div id="addForm">
|
<div id="addForm">
|
||||||
{% include "addForm.html" %}
|
{% include "addForm.html" %}
|
||||||
@ -26,7 +40,7 @@
|
|||||||
</i></button></a>
|
</i></button></a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{data["list_ids"]}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- jQuery library -->
|
<!-- jQuery library -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user