28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
# webapp/routes/archive.py
|
|
from __future__ import annotations
|
|
import time
|
|
from flask import Blueprint, render_template, redirect, url_for
|
|
from webapp.storage.orders import load_orders, update_order
|
|
|
|
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,
|
|
)
|
|
return render_template("archive.html", archived_orders=archived)
|
|
|
|
@bp.post("/archiv/add/<order_id>")
|
|
def archive_add(order_id: str):
|
|
"""
|
|
Markiert einen Auftrag als archiviert.
|
|
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})
|
|
return redirect(url_for("structures.structures")) # zurück zu /strukturen
|