bump project
This commit is contained in:
1
app/main/__init__.py
Normal file
1
app/main/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
28
app/main/routes.py
Normal file
28
app/main/routes.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from flask import Blueprint, redirect, render_template, url_for
|
||||
from flask_login import current_user, login_required
|
||||
|
||||
from app.models import Account, AttendanceEvent, Person
|
||||
|
||||
bp = Blueprint("main", __name__)
|
||||
|
||||
|
||||
@bp.get("/")
|
||||
def index():
|
||||
if current_user.is_authenticated:
|
||||
return redirect(url_for("main.dashboard"))
|
||||
return redirect(url_for("auth.login"))
|
||||
|
||||
|
||||
@bp.get("/dashboard")
|
||||
@login_required
|
||||
def dashboard():
|
||||
stats = {
|
||||
"people": Person.query.count(),
|
||||
"active_people": Person.query.filter_by(active=True).count(),
|
||||
"events": AttendanceEvent.query.count(),
|
||||
"accounts": Account.query.count(),
|
||||
}
|
||||
latest_events = AttendanceEvent.query.order_by(AttendanceEvent.occurred_at.desc()).limit(8).all()
|
||||
return render_template("dashboard.html", stats=stats, latest_events=latest_events)
|
||||
Reference in New Issue
Block a user