In sync with dev

Added mobile view
This commit is contained in:
Benjamyn Love 2020-01-22 21:53:08 +11:00
parent cf077fe892
commit dc787e4d94
4 changed files with 65 additions and 3 deletions

View File

@ -4,6 +4,8 @@ import sqlite3
import os.path
DBNAME = "list.db"
MOBILES = ["android", "iphone", "blackberry"]
def doesDBExist(DBNAME):
try:
@ -61,7 +63,10 @@ app.config["DEBUG"] = True
@app.route('/')
def index():
query = readFromDB()
data = {"title":"Cart", "results":query}
data = {"title":"Shopping List", "results":query}
for device in MOBILES:
if device in request.user_agent.platform:
return render_template('mobile.html', data=data)
return render_template('index.html', data=data)
@app.route('/post', methods=['POST'])
@ -84,4 +89,4 @@ def handle_data():
if __name__ == '__main__':
doesDBExist(DBNAME)
app.run(host="0.0.0.0")
app.run()

View File

@ -5,7 +5,7 @@
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="/static/css/index.css"/>
<link rel="stylesheet" content="text/css" href="/static/css/main.css"/>
</head>
<body>
<h1 class="container" style="text-align: center">{{ data["title"] }}</h1>

57
templates/mobile.html Normal file
View File

@ -0,0 +1,57 @@
<!doctype html>
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Shopping List</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" content="text/css" href="/static/css/main.css"/>
</head>
<body>
<h1 class="container" style="text-align: center">{{ data["title"] }}</h1>
<div class="" style="; text-align: center">
<form action="/post" method="post">
Name: <input type="text" name="name" value=""><br>
Item: <input type="text" name="item" value=""><br><br>
<input type="submit" name="addValue" value="Submit"/>
</form>
</div>
<div class="container" id="memes">
<table class="table-striped table">
<thead class="thead-dark">
<tr>
<th scope="col">Item</th>
<th scope="col">Requester</th>
<th scope="col">Gottem?</th>
<th scope="col">Remove</th>
</tr>
{% for x in data["results"] %}
<tr id="row-{{x[0]}}">
<td>{{x[1]}}</td>
<td>{{x[4]}}</td>
<td> {% if x[3] == 0 %}
<form><button type="submit" formaction="/post" formmethod="POST" name="got" value="{{x[0]}}">No</button></form>
{% else %}
yes
{% endif %}</td>
<td><form>
<button type="submit" formaction="/post" formmethod="POST" name="rem" value="{{x[0]}}">Remove</button>
</form>
</td>
</tr>
{% endfor %}
</table>
</div>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</body>
</html>