feat: add id match rule
This commit is contained in:
@@ -3,6 +3,7 @@ from sort_rule import sort_by_rule
|
|||||||
import csv
|
import csv
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@@ -84,10 +85,10 @@ def upload_score():
|
|||||||
and "time" in data
|
and "time" in data
|
||||||
and "project" in data # 新增项目名称字段
|
and "project" in data # 新增项目名称字段
|
||||||
):
|
):
|
||||||
if data["name"] == "test_name":
|
if not re.fullmatch(r"^\d{12}$", data["id"]):
|
||||||
|
return jsonify({"message": "学号不合规,不记录成绩!"}), 400
|
||||||
|
elif data["name"] == "test_name" or data["name"] == "":
|
||||||
return jsonify({"message": "请完善姓名,默认名字不记录成绩!"}), 400
|
return jsonify({"message": "请完善姓名,默认名字不记录成绩!"}), 400
|
||||||
elif data["id"] == "202210423xxx":
|
|
||||||
return jsonify({"message": "请完善学号,默认学号不记录成绩!"}), 400
|
|
||||||
data["details"] = data["details"].replace("\n", "<br>")
|
data["details"] = data["details"].replace("\n", "<br>")
|
||||||
write_to_csv(data, data["project"])
|
write_to_csv(data, data["project"])
|
||||||
return jsonify({"message": "上传成绩成功!"}), 200
|
return jsonify({"message": "上传成绩成功!"}), 200
|
||||||
|
|||||||
Reference in New Issue
Block a user