Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions routers/activities_v2_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def create_activity_v2(
result = await db.zvms_new.get_collection("activities").insert_one(activity)

log.with_text(
f'User {await get_user_name(user['id'])} (ID: {user['id']}) created activity {activity["name"]} at {datetime.now().isoformat()}. It\'s {activity["status"]} and the creator is {activity["creator"]}. The ID of the activity is {result.inserted_id}.'
f'User {await get_user_name(user['id'])} (ID: {user['id']}) created activity {activity["name"]} at {datetime.now().isoformat()} (ID: {result.inserted_id}).'
)
await log.insert_log()

Expand Down Expand Up @@ -345,7 +345,7 @@ async def add_activity_member_v2(
result = await db.zvms_new.get_collection("activity_members").insert_one(member)

log.with_text(
f'User {await get_user_name(user["id"])} added member {await get_user_name(target_user.id)} to activity {target_activity.name} at {datetime.now().isoformat()}. The ID of the activity is {activity_id}.'
f'User {await get_user_name(user["id"])} added member {target_user.name} to activity {target_activity.name} at {datetime.now().isoformat()}. The ID of the activity is {activity_id}.'
)
await log.insert_log()

Expand Down
2 changes: 0 additions & 2 deletions routers/users_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,6 @@ async def update_user(

pasts = []

if user_info["name"] != user_struct.name:
pasts.append(user_info["name"])
if user_info["id"] != user_struct.id:
pasts.append(user_info["id"])

Expand Down
55 changes: 4 additions & 51 deletions util/statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
TRANSLATIONS = {
"zh": {
"volunteer_statement": "义工明细",
"signature": "镇海中学义工管理平台 | 学生会实践部",
"signature": "镇海中学义工管理平台 | 学生会",
"name": "姓名",
"student_id": "学号",
"class": "班级",
Expand Down Expand Up @@ -64,7 +64,7 @@
"recording_mode": "记入模式",
"duration": "计入时长",
"person_in_charge": "负责人",
"sgn": "镇海中学团委 学生会实践部",
"sgn": "镇海中学团委 学生会",
"stmt": "本明细由平台数据导出自动生成,经团委审核、盖章后生效。未经审核的明细不具备证明效力。",
"spreadsheet": {
"_id": "数据库 ID",
Expand All @@ -83,7 +83,7 @@
},
"en": {
"volunteer_statement": "Volunteer Details",
"signature": "Zhenhai High School Volunteer Management System | Department of Practice, Student Union",
"signature": "Zhenhai High School Volunteer Management System | Student Union",
"name": "Name",
"student_id": "Student ID",
"class": "Class",
Expand Down Expand Up @@ -111,7 +111,7 @@
"recording_mode": "Recording Mode",
"duration": "Duration",
"person_in_charge": "Person in Charge",
"sgn": "Zhenhai High School Youth League Committee & Student Union Department of Practice",
"sgn": "Zhenhai High School Youth League Committee & Student Union",
"stmt": "This statement is automatically generated from platform data and is valid after review and stamping by the Youth League Committee. Unreviewed statements do not have proof of validity.",
"spreadsheet": {
"_id": "Database ID",
Expand All @@ -128,53 +128,6 @@
"filename": "Volunteer Details Sheet",
},
},
"jp": {
"volunteer_statement": "ボランティア明細",
"signature": "鎮海中学校ボランティア管理システム | 学生会実践部",
"name": "名前",
"student_id": "学生ID",
"class": "クラス",
"database_id": "データベースID",
"export_time": "エクスポート時間",
"export_period": "エクスポート期間",
"volunteer_statistics": "ボランティア時間統計",
"volunteer_statistics_this_year": "今年のボランティア時間統計",
"category": "統計項目",
"total_hours": "総時間",
"on_campus": "校内",
"off_campus": "校外",
"social_practice": "社会実践",
"effective_hours": "有効時間",
"volunteer_hours": "ボランティア時間",
"required_hours": "必要最低時間",
"reached_target": "目標達成",
"not_reached_target": "目標未達成",
"target_status": "目標状態",
"volunteer_hours_this_year": "今年のボランティア時間",
"hours": "時間",
"volunteer_service_records": "ボランティアサービス記録詳細",
"activity_name": "活動名",
"date": "日付",
"recording_mode": "記録モード",
"duration": "サービス時間",
"person_in_charge": "担当者",
"sgn": "鎮海中学校青年団委員会 学生会実践部",
"stmt": "この明細はプラットフォームデータから自動生成され、青年団委員会の審査とスタンプ後に有効になります。未審査の明細は証明力を持ちません。",
"spreadsheet": {
"_id": "データベースID",
"name": "名前",
"id": "学生ID",
"group": "クラス",
"on-campus": "校内",
"off-campus": "校外",
"social-practice": "社会実践",
"ay-on-campus": "今年の校内",
"ay-off-campus": "今年の校外",
"ay-social-practice": "今年の社会実践",
"description": "明細",
"filename": "ボランティア明細表",
},
},
}


Expand Down
23 changes: 0 additions & 23 deletions util/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,12 @@


def validate_activity_name(name: str):
"""
Validate activity name.
1. Should be only appear in Chinese, Latin Characters, numbers, spaces, slashes, dashes, and dots.
2. ASCII letters should be wrapped with spaces if inserted between Chinese characters.
3. Should not be empty.
4. Should not have space before or after the string.
"""
if not name.strip():
return False, "Should not be empty"

if name[0] == " " or name[-1] == " ":
return False, "Should not have space before or after the string"

# Should only contain Chinese, Latin Characters, numbers, spaces, slashes, and dots
if not re.match(r"^[-\u4e00-\u9fa5\u2013-\u2014a-zA-Z0-9 /-/.]+$", name):
return (
False,
"Should only appear in Chinese, Latin Characters, numbers, spaces, slashes, dashes (including en dash and em dash), and dots",
)

# ASCII letters should be wrapped with spaces if inserted between Chinese characters
if re.search(r"[\u4e00-\u9fa5][a-zA-Z0-9]", name) or re.search(
r"[a-zA-Z0-9][\u4e00-\u9fa5]", name
):
return (
False,
"ASCII letters should be wrapped with spaces if inserted between Chinese characters",
)

return True, ""


Expand Down