rollerverbrauch/app/routes/misc.py

23 lines
518 B
Python
Raw Permalink Normal View History

2016-11-01 18:01:52 +01:00
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
2021-06-20 08:43:46 +02:00
@app.route("/statistics", methods=["GET"])
2016-11-01 18:01:52 +01:00
@login_required
def get_statistics():
stats = []
2021-06-20 08:43:46 +02:00
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)
2016-11-01 18:01:52 +01:00