42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from flask import Blueprint, render_template
|
|
from flask_login import login_required
|
|
|
|
from app.guides import GUIDES
|
|
from app.models import ApplyLog, SystemState, TestResult
|
|
from app.services.applier import get_system_status
|
|
|
|
main_bp = Blueprint("main", __name__)
|
|
|
|
|
|
@main_bp.route("/")
|
|
@login_required
|
|
def dashboard():
|
|
state = SystemState.query.first()
|
|
pending = None
|
|
if state and state.pending_apply_log_id:
|
|
pending = ApplyLog.query.get(state.pending_apply_log_id)
|
|
|
|
recent_tests = (
|
|
TestResult.query.order_by(TestResult.tested_at.desc()).limit(10).all()
|
|
)
|
|
status = get_system_status()
|
|
guide = GUIDES.get("dashboard", {})
|
|
|
|
return render_template(
|
|
"dashboard.html",
|
|
status=status,
|
|
state=state,
|
|
pending=pending,
|
|
recent_tests=recent_tests,
|
|
guide=guide,
|
|
)
|
|
|
|
|
|
@main_bp.route("/guide/<section>")
|
|
@login_required
|
|
def guide(section):
|
|
guide_data = GUIDES.get(section)
|
|
if not guide_data:
|
|
guide_data = {"title": "راهنما", "summary": "", "content": "<p>راهنما یافت نشد.</p>"}
|
|
return render_template("guide.html", guide=guide_data, section=section)
|