Added parts (fixed #6)
This commit is contained in:
parent
4a3ca9f933
commit
431fb8ce0e
30
app.py
30
app.py
@ -368,7 +368,7 @@ def new_set(set_num):
|
||||
def missing():
|
||||
conn = sqlite3.connect('app.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('SELECT id, part_num, color_id, element_id, SUM(quantity) AS total_quantity FROM missing GROUP BY id, part_num, color_id, element_id;')
|
||||
cursor.execute('SELECT id, part_num, color_id, element_id, part_img_url_id, SUM(quantity) AS total_quantity FROM missing GROUP BY id, part_num, color_id, element_id;')
|
||||
|
||||
results = cursor.fetchall()
|
||||
missing_list = [list(i) for i in results]
|
||||
@ -378,6 +378,20 @@ def missing():
|
||||
|
||||
return render_template('missing.html',missing_list=missing_list)
|
||||
|
||||
@app.route('/parts',methods=['POST','GET'])
|
||||
def parts():
|
||||
conn = sqlite3.connect('app.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('SELECT id, part_num, color_id, element_id, part_img_url_id, SUM(quantity) AS total_quantity FROM inventory GROUP BY id, part_num, part_img_url_id, color_id, element_id;')
|
||||
|
||||
results = cursor.fetchall()
|
||||
missing_list = [list(i) for i in results]
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
|
||||
return render_template('parts.html',missing_list=missing_list)
|
||||
|
||||
@app.route('/minifigs',methods=['POST','GET'])
|
||||
def minifigs():
|
||||
conn = sqlite3.connect('app.db')
|
||||
@ -512,6 +526,7 @@ def inventory(tmp,u_id):
|
||||
cursor.execute("SELECT * from missing where u_id = '" + u_id + "';")
|
||||
results = cursor.fetchall()
|
||||
missing_list = [list(i) for i in results]
|
||||
print(missing_list)
|
||||
|
||||
# Get minifigures
|
||||
cursor.execute("SELECT * from minifigures where set_num = '" + tmp + "' and u_id = '" + u_id + "';")
|
||||
@ -536,6 +551,7 @@ def inventory(tmp,u_id):
|
||||
set_num = request.form.get('set_num')
|
||||
id = request.form.get('id')
|
||||
part_num = request.form.get('part_num')
|
||||
part_img_url_id = request.form.get('part_img_url_id')
|
||||
color_id = request.form.get('color_id')
|
||||
element_id = request.form.get('element_id')
|
||||
u_id = request.form.get('u_id')
|
||||
@ -551,12 +567,14 @@ def inventory(tmp,u_id):
|
||||
WHERE set_num = ? AND
|
||||
id = ? AND
|
||||
part_num = ? AND
|
||||
part_img_url_id = ? AND
|
||||
color_id = ? AND
|
||||
element_id = ? AND
|
||||
u_id = ?''',
|
||||
(set_num, id, part_num, color_id, element_id, u_id))
|
||||
(set_num, id, part_num, part_img_url_id, color_id, element_id, u_id))
|
||||
|
||||
existing_quantity = cursor.fetchone()
|
||||
conn.commit()
|
||||
|
||||
#If there's an existing entry or if entry isn't the same as the new value
|
||||
if existing_quantity is None or existing_quantity[0] != missing:
|
||||
@ -564,12 +582,13 @@ def inventory(tmp,u_id):
|
||||
set_num,
|
||||
id,
|
||||
part_num,
|
||||
part_img_url_id,
|
||||
color_id,
|
||||
quantity,
|
||||
element_id,
|
||||
u_id
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?) ''',
|
||||
(set_num, id, part_num, color_id, missing, element_id, u_id))
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(set_num, id, part_num, part_img_url_id, color_id, missing, element_id, u_id))
|
||||
|
||||
conn.commit()
|
||||
|
||||
@ -579,10 +598,11 @@ def inventory(tmp,u_id):
|
||||
WHERE set_num = ? AND
|
||||
id = ? AND
|
||||
part_num = ? AND
|
||||
part_img_url_id = ? AND
|
||||
color_id = ? AND
|
||||
element_id = ? AND
|
||||
u_id = ?''',
|
||||
(set_num, id, part_num, color_id, element_id, u_id))
|
||||
(set_num, id, part_num, part_img_url_id, color_id, element_id, u_id))
|
||||
|
||||
conn.commit()
|
||||
|
||||
|
75
templates/parts.html
Normal file
75
templates/parts.html
Normal file
@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html data-theme="light" class="has-navbar-fixed-top">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Set Overview</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/bulma@1.0.0/css/bulma.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar is-dark is-fixed-top" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="/">
|
||||
Home
|
||||
</a>
|
||||
|
||||
<a class="navbar-item" href="/create">
|
||||
Add Set
|
||||
</a>
|
||||
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navMenu">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
<div id="navMenu" class="navbar-menu">
|
||||
<div class="navbar-start">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="navbar-end">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<center>
|
||||
<div class="center-table" >
|
||||
<table id="data" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th ></th>
|
||||
<th >id</th>
|
||||
<th >part_num</th>
|
||||
<th >color_id</th>
|
||||
<th >element_id</th>
|
||||
<th >total_quantity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for brick in missing_list %}
|
||||
<tr>
|
||||
{% if brick[4] == 'nil' %}
|
||||
<td><img src="{{ '/static/none.jpg' }}" class="lightbox-trigger" style="height: 50px; width: 50px;margin:0;padding: 0;" loading="lazy"></td>
|
||||
{% else %}
|
||||
<td><img src="{{ '/static/parts/' + brick[4] + '.jpg' }}" class="lightbox-trigger" style="height: 50px; width: 50px;margin:0;padding: 0;" loading="lazy"></td>
|
||||
{% endif %}
|
||||
<td>{{ brick[0] }}</td>
|
||||
<td>{{ brick[1] }}</td>
|
||||
<td>{{ brick[2] }}</td>
|
||||
<td>{{ brick[3] }}</td>
|
||||
<td>{{ brick[5] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</center>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user