From 89428f773b02075ed4728a71bdfb04baee55b7d1 Mon Sep 17 00:00:00 2001 From: Xiao Furen Date: Tue, 4 Aug 2026 07:17:23 +0800 Subject: [PATCH] feat: add weekly schedule management page with Drag-and-Drop support and custom context processors --- point_system/students/context_processors.py | 5 + .../templates/students/weekly_schedule.html | 461 ++++++++++-------- 2 files changed, 252 insertions(+), 214 deletions(-) diff --git a/point_system/students/context_processors.py b/point_system/students/context_processors.py index e44f670..686554c 100644 --- a/point_system/students/context_processors.py +++ b/point_system/students/context_processors.py @@ -1,9 +1,14 @@ +from django.utils import translation + def language_processor(request): """ Context processor to make current_lang available across all template renders. + Also activates Django's gettext translation so {% trans %} tags render correctly. Defaults to 'zh' (Traditional Chinese). """ lang = request.session.get('lang', 'zh') + target_lang = 'en' if lang == 'en' else 'zh-hant' + translation.activate(target_lang) return { 'current_lang': lang } diff --git a/point_system/students/templates/students/weekly_schedule.html b/point_system/students/templates/students/weekly_schedule.html index a0b6f64..bec2fba 100644 --- a/point_system/students/templates/students/weekly_schedule.html +++ b/point_system/students/templates/students/weekly_schedule.html @@ -16,12 +16,13 @@ {{ m1_year }}年{{ m1_month }}月 & {{ m2_year }}年{{ m2_month }}月 {% if user.is_authenticated %} -
- {% csrf_token %} - -
+
+ {% csrf_token %} + +
{% endif %} @@ -59,6 +60,11 @@ +
+ + {% trans "經調整後但仍未能報告者,須準備一小時之進度簡報,當週向指導教授當面報告,次週週會補報。若連續兩次應報告而未報告,將視同解除指導關係。" %} +
+ {% if user.is_authenticated %}
@@ -78,61 +84,74 @@
{% for item in schedule_m1 %} -
-
-
-
- {{ item.formatted }} (星期一) -
- {{ item.students|length }} 位報告者 -
-
- {% if item.students %} -
- - - - - - - - - - - {% for student in item.students %} - - - - - - - {% endfor %} - -
學號姓名學位類別身分類別
- {% if user.is_authenticated %}{% endif %} - {{ student.student_id }} - {{ student.name }} - {% if student.degree_type == '博士生' %} - 博士生 - {% else %} - 碩士生 - {% endif %} - - {% if student.student_category == '在職生' %} - 在職生 - {% elif student.student_category == '交換中' %} - 交換中 - {% else %} - 一般生 - {% endif %} -
-
- {% else %} -

當日無排定報告者 (可拖曳學生至此)

- {% endif %} +
+
+
+
+ {{ item.formatted }} (星期一) +
+ {{ item.students|length }} 位報告者 +
+
+ {% if item.students %} +
+ + + + + + + + + + + {% for student in item.students %} + {% if user.is_authenticated %} + + {% else %} + + {% endif %} + + + + + + {% endfor %} + +
學號姓名學位類別身分類別
+ {% if user.is_authenticated %}{% endif %} + {{ student.student_id }} + {{ student.name }} + {% if student.degree_type == '博士生' %} + 博士生 + {% else %} + 碩士生 + {% endif %} + + {% if student.student_category == '在職生' %} + 在職生 + {% elif student.student_category == '交換中' %} + 交換中 + {% else %} + 一般生 + {% endif %} +
+ {% else %} +

當日無排定報告者 (可拖曳學生至此)

+ {% endif %}
+
{% endfor %}
@@ -144,61 +163,74 @@
{% for item in schedule_m2 %} -
-
-
-
- {{ item.formatted }} (星期一) -
- {{ item.students|length }} 位報告者 -
-
- {% if item.students %} -
- - - - - - - - - - - {% for student in item.students %} - - - - - - - {% endfor %} - -
學號姓名學位類別身分類別
- {% if user.is_authenticated %}{% endif %} - {{ student.student_id }} - {{ student.name }} - {% if student.degree_type == '博士生' %} - 博士生 - {% else %} - 碩士生 - {% endif %} - - {% if student.student_category == '在職生' %} - 在職生 - {% elif student.student_category == '交換中' %} - 交換中 - {% else %} - 一般生 - {% endif %} -
-
- {% else %} -

當日無排定報告者 (可拖曳學生至此)

- {% endif %} +
+
+
+
+ {{ item.formatted }} (星期一) +
+ {{ item.students|length }} 位報告者 +
+
+ {% if item.students %} +
+ + + + + + + + + + + {% for student in item.students %} + {% if user.is_authenticated %} + + {% else %} + + {% endif %} + + + + + + {% endfor %} + +
學號姓名學位類別身分類別
+ {% if user.is_authenticated %}{% endif %} + {{ student.student_id }} + {{ student.name }} + {% if student.degree_type == '博士生' %} + 博士生 + {% else %} + 碩士生 + {% endif %} + + {% if student.student_category == '在職生' %} + 在職生 + {% elif student.student_category == '交換中' %} + 交換中 + {% else %} + 一般生 + {% endif %} +
+ {% else %} +

當日無排定報告者 (可拖曳學生至此)

+ {% endif %}
+
{% endfor %}
@@ -222,31 +254,32 @@ {% for row in summary_data %} - - {{ row.student.student_id }} - {{ row.student.name }} - {{ row.rule_desc }} - - {% if row.assigned_dates %} - {% for d in row.assigned_dates %} - {{ d }} - {% endfor %} - {% else %} - 免報告 - {% endif %} - - - {% if row.total_count > 0 %} - {{ row.total_count }} 次 - {% else %} - 0 次 - {% endif %} - - + + {{ row.student.student_id }} + {{ row.student.name }} + {{ row.rule_desc }} + + {% if row.assigned_dates %} + {% for d in row.assigned_dates %} + {{ d + }} + {% endfor %} + {% else %} + 免報告 + {% endif %} + + + {% if row.total_count > 0 %} + {{ row.total_count }} 次 + {% else %} + 0 次 + {% endif %} + + {% empty %} - - 無在學學生資料 - + + 無在學學生資料 + {% endfor %} @@ -258,94 +291,94 @@ {% block scripts %} {% if user.is_authenticated %} {% endif %} -{% endblock %} +{% endblock %} \ No newline at end of file