Added list selection on index
This commit is contained in:
parent
2d4a35814d
commit
7082dc86fe
16
shop.py
16
shop.py
@ -123,8 +123,15 @@ def index():
|
||||
if session.get('id') is None:
|
||||
data = {"title":"Login"}
|
||||
return render_template("auth.html", data=data)
|
||||
|
||||
#Get initial data, contains all lists the user is apart of
|
||||
try:
|
||||
if request.args["list"]:
|
||||
print(request.args["list"])
|
||||
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:
|
||||
@ -134,6 +141,7 @@ def index():
|
||||
|
||||
@app.route('/post', methods=['POST'])
|
||||
def handle_data():
|
||||
|
||||
if "addValue" in request.form:
|
||||
for x in request.form:
|
||||
if request.form[x] == '':
|
||||
@ -177,6 +185,10 @@ def handle_data():
|
||||
|
||||
if "logout" in request.form:
|
||||
session.clear()
|
||||
|
||||
if "changeList" in request.form:
|
||||
pprint(request.form["changeList"])
|
||||
|
||||
return redirect(url_for('index'))
|
||||
|
||||
@app.route("/admin")
|
||||
|
||||
@ -1,7 +1,21 @@
|
||||
{% include "header.html" %}
|
||||
|
||||
<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> -->
|
||||
<div id="addForm">
|
||||
{% include "addForm.html" %}
|
||||
@ -26,7 +40,7 @@
|
||||
</i></button></a>
|
||||
</div>
|
||||
<div>
|
||||
{{data["list_ids"]}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- jQuery library -->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user