rollerverbrauch/app/routes/misc.py

23 lines
518 B
Python

from flask import render_template
from flask_security import login_required
from flask_security.core import current_user
from ..tools import VehicleStats
from .. import app
@app.route("/statistics", methods=["GET"])
@login_required
def get_statistics():
stats = []
def key(v):
return (not v.is_active, v.name)
vehicles = sorted(current_user.vehicles, key=key)
for vehicle in vehicles:
stats.append(VehicleStats(vehicle))
return render_template("statistics.html", data=stats)