feat: 问题数据迁移到数据库;学员详情页URL导航改造;侧边栏统一
- 问题从文件系统迁移到数据库 problems 表 - 移除 PROBLEMS_DIR 配置和文件读取逻辑 - student.html 完整重写:编辑/添加/删除问题,生成方案进度显示 - 学员详情页支持独立URL访问 (/student/<id>) - 统一侧边栏到 base.html - 更新文档:DEPLOYMENT_SOP, MODELS, STRUCTURE, FRONTEND_ARCH - 部署到生产环境 v1.2.0
This commit is contained in:
+31
-2
@@ -15,18 +15,46 @@ from app.routes import main_bp
|
||||
from app.models import (
|
||||
db,
|
||||
Student,
|
||||
Class,
|
||||
PracticePlan,
|
||||
PROBLEM_LIST,
|
||||
SEVERITY_LEVELS,
|
||||
PRACTICE_TIME_OPTIONS,
|
||||
User,
|
||||
Class,
|
||||
)
|
||||
from app.routes.auth import login_required_json, check_login
|
||||
|
||||
|
||||
@main_bp.route("/")
|
||||
def index():
|
||||
"""首页 - 学员列表"""
|
||||
"""首页"""
|
||||
if not check_login():
|
||||
return redirect("/login")
|
||||
|
||||
student_count = Student.query.count()
|
||||
class_count = Class.query.count()
|
||||
plan_count = PracticePlan.query.count()
|
||||
|
||||
return render_template(
|
||||
"home.html",
|
||||
student_count=student_count,
|
||||
class_count=class_count,
|
||||
plan_count=plan_count,
|
||||
active_nav="home",
|
||||
)
|
||||
|
||||
|
||||
@main_bp.route("/student/<int:student_id>")
|
||||
@login_required_json
|
||||
def student_detail_page(student_id):
|
||||
"""学员详情页"""
|
||||
student = Student.query.get_or_404(student_id)
|
||||
return render_template("student.html", student=student, active_nav="students")
|
||||
|
||||
|
||||
@main_bp.route("/students")
|
||||
def students_page():
|
||||
"""学员列表页"""
|
||||
if not check_login():
|
||||
return redirect("/login")
|
||||
|
||||
@@ -35,6 +63,7 @@ def index():
|
||||
problem_list=PROBLEM_LIST,
|
||||
severity_levels=SEVERITY_LEVELS,
|
||||
practice_time_options=PRACTICE_TIME_OPTIONS,
|
||||
active_nav="students",
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user