Files
TermiNexus f8d356f3ff chore(baseline): 注册 RollCall/Viper/Venom 子域与站点,补 rollcall 应用
Main.py:WHITE_HOSTS 增 rollcall/viper/venom 主机,STATIC_SITES 增 rollcall/venom 静态根,静态站点路由下 /API/ 前缀请求转交 Django 处理。

gvsds:settings.py 注册 gvsds.apps.rollcall,urls.py 挂载 API/RollCall/;新增 rollcall 应用(模型/视图/路由/迁移 + RollCallManager 数据访问层)与 TempLate/rollcall 前端站点。

.gitignore:排除 Viper/Venom 前端工程与部署产物、TempLate/FTP 二进制分发目录。
2026-09-14 12:30:06 +08:00

50 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""RollCall API 视图——整体读写点名数据(学生/题目/课堂记录)。
- GET /API/RollCall/Data 读取全部数据(无记录返回空数组)
- POST /API/RollCall/Data 整体覆盖保存(body: {students, questions, history})
- DELETE /API/RollCall/Data 清空数据
点名站点为公开教学场景,未做登录鉴权(如需保护可在 Main.py 层或后续加 token)。
"""
from rest_framework.response import Response
from rest_framework.views import APIView
from .manager import RollCallManager
DATA_KEY = 'main'
class RollCallDataView(APIView):
authentication_classes = []
permission_classes = []
def get(self, request):
row = RollCallManager.GetData(DATA_KEY)
if row is None:
return Response({'students': [], 'questions': [], 'history': []})
return Response({
'students': row.Students or [],
'questions': row.Questions or [],
'history': row.History or [],
})
def post(self, request):
data = request.data if isinstance(request.data, dict) else {}
students = data.get('students')
questions = data.get('questions')
history = data.get('history')
if not isinstance(students, list) or not isinstance(questions, list):
return Response({'error': 'students/questions 必须为数组'}, status=400)
row = RollCallManager.SaveData(
DATA_KEY,
Students=students,
Questions=questions,
History=history if isinstance(history, list) else [],
)
return Response({'ok': True, 'updatedAt': row.UpdatedAt})
def delete(self, request):
deleted = RollCallManager.ClearData(DATA_KEY)
return Response({'ok': True, 'deleted': deleted})