From e6e8e5e2388c54d1e177d6e72f37aa37a79cb75f Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Wed, 20 Oct 2021 15:42:54 +0800 Subject: Adjust Flask server to new database methods --- jimbrella/web.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/jimbrella/web.py b/jimbrella/web.py index 006c66c..8b45309 100644 --- a/jimbrella/web.py +++ b/jimbrella/web.py @@ -1,6 +1,5 @@ from flask import Flask, request, render_template from .database import Database -from .utils import group_by_status, find_overdue from .config import * db = Database(DATABASE_PATH) @@ -8,16 +7,16 @@ db = Database(DATABASE_PATH) app = Flask("jimbrella") -@app.route("/") +@app.route("/admin") def index(): umbrellas = db.read() - statuses = group_by_status(umbrellas) + statuses = Database.group_by_status(umbrellas) return render_template( - "index.html", - total=len(umbrellas), - available=len(statuses["available"]), - lent=len(statuses["lent"]), - overdue=len(find_overdue(umbrellas)), + "admin/index.html", + umbrellas=umbrellas, + available=statuses["available"], + lent=statuses["lent"], + overdue=Database.find_overdue(statuses["lent"]), ) -- cgit v1.2.3