migrate to table based tinydb

NOTE to migrate database install tinydb & run migrate.py

- added new functions to filter data with db queries
- in the storage module
This commit is contained in:
2025-08-27 20:39:04 +02:00
parent 0339da1668
commit 36f7f6d278
9 changed files with 2073 additions and 2335 deletions

View File

@@ -2,18 +2,14 @@
from __future__ import annotations
import time
from flask import Blueprint, render_template, redirect, url_for
from webapp.storage.orders import load_orders, update_order
from webapp.storage.orders import load_archived, mark_archived
bp = Blueprint("archive", __name__)
@bp.get("/archiv")
def archive_index():
"""Zeigt ausschließlich Aufträge mit status == 'archived'."""
archived = [o for o in load_orders() if o.get("status") == "archived"]
archived.sort(
key=lambda o: (o.get("archived_at") or o.get("done_at") or o.get("created_at") or ""),
reverse=True,
)
archived = load_archived()
return render_template("archive.html", archived_orders=archived)
@bp.post("/archiv/add/<order_id>")
@@ -23,5 +19,5 @@ def archive_add(order_id: str):
Danach BLEIBEN wir auf der Strukturen-Seite (kein Wechsel zur Archiv-Seite).
"""
now = time.strftime("%Y-%m-%dT%H:%M:%S%z", time.gmtime())
update_order(order_id, {"status": "archived", "archived_at": now})
mark_archived(order_id)
return redirect(url_for("structures.structures")) # zurück zu /strukturen