Add machine filter on trade records and review list.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+16
-3
@@ -594,12 +594,25 @@ def register_routes(app: Flask) -> None:
|
||||
@login_required
|
||||
def records_page():
|
||||
u = current_user()
|
||||
machine_raw = (request.args.get("machine_id") or "").strip()
|
||||
machine_id = int(machine_raw) if machine_raw.isdigit() else None
|
||||
with database.get_db() as conn:
|
||||
machines = database.list_machines_for_user(conn, u)
|
||||
allowed_ids = {int(m["id"]) for m in machines}
|
||||
if machine_id is not None and machine_id not in allowed_ids:
|
||||
machine_id = None
|
||||
if u["role"] == "admin":
|
||||
trades = database.list_trades(conn, 300)
|
||||
trades = database.list_trades(conn, 300, machine_id=machine_id)
|
||||
else:
|
||||
trades = database.list_trades(conn, 300, account_id=u.get("account_id"))
|
||||
return render_template("records.html", trades=trades)
|
||||
trades = database.list_trades(
|
||||
conn, 300, account_id=u.get("account_id"), machine_id=machine_id
|
||||
)
|
||||
return render_template(
|
||||
"records.html",
|
||||
trades=trades,
|
||||
machines=machines,
|
||||
selected_machine_id=machine_id,
|
||||
)
|
||||
|
||||
@app.get("/records/<int:tid>")
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user