modified: app.py
modified: static/styleIndex.css modified: templates/index.html
This commit is contained in:
27
app.py
27
app.py
@@ -189,6 +189,33 @@ def scan():
|
||||
def serve_cache(filename):
|
||||
return send_from_directory(CACHE_DIR, filename)
|
||||
|
||||
@app.route('/bulk_delete', methods=['POST'])
|
||||
@login_required
|
||||
def bulk_delete():
|
||||
barcodes = request.json.get('barcodes', [])
|
||||
with sqlite3.connect(DB_FILE) as conn:
|
||||
conn.executemany('DELETE FROM products WHERE barcode = ?', [(b,) for b in barcodes])
|
||||
conn.commit()
|
||||
# Optional: Logic to delete cached images could go here
|
||||
return jsonify({"status": "ok"})
|
||||
|
||||
@app.route('/bulk_edit_price', methods=['POST'])
|
||||
@login_required
|
||||
def bulk_edit_price():
|
||||
data = request.json
|
||||
barcodes = data.get('barcodes', [])
|
||||
new_price = data.get('price')
|
||||
|
||||
try:
|
||||
price = float(new_price)
|
||||
with sqlite3.connect(DB_FILE) as conn:
|
||||
conn.executemany('UPDATE products SET price = ? WHERE barcode = ?',
|
||||
[(price, b) for b in barcodes])
|
||||
conn.commit()
|
||||
return jsonify({"status": "ok"})
|
||||
except ValueError:
|
||||
return jsonify({"status": "error", "message": "Invalid price"}), 400
|
||||
|
||||
if __name__ == '__main__':
|
||||
init_db()
|
||||
socketio.run(app, host='0.0.0.0', port=5000, debug=True)
|
||||
|
||||
Reference in New Issue
Block a user