diff --git a/manage.py b/manage.py index af25a95..67c952b 100644 --- a/manage.py +++ b/manage.py @@ -201,6 +201,49 @@ def manage_admin(g, r, date): return manageProcess("admin", data) +@manage.route('/swapClass///', methods=["GET"]) +def viewSwapClass(g, r, date): + if (check_login_status()): + return redirect('/logout') + refresh_token() + homeroom = [g, r] + data = db.child("Homerooms").child(g).child( + r).child("Absent").child(date).get(session['token']).val() + data.pop('dow') + if 'confirm' in data: + data.pop('notes') + data.pop('confirm') + realData = {} + for d in data: + if 'signature' in data[d] or 'confirm' in data[d]: + realData[d] = 'aCfrm' + else: + realData[d] = data[d] + return render_template("swapclass.html", data=realData, homeroom=homeroom, date=date) + + +@manage.route('/swapClass', methods=['POST']) +def swapClass(): + if (check_login_status()): + return redirect('/logout') + refresh_token() + formData = request.form.to_dict() + date = formData.pop('date') + homeroom = formData.pop('homeroom').split('^') + print(homeroom) + origData = db.child("Homerooms").child(homeroom[0]).child( + homeroom[1]).child("Absent").child(date).get(session['token']).val() + for k in formData: + k = k.split('^') + if ((not k[1] in origData[k[0]]) or formData[k[0]+'^'+k[1]] == origData[k[0]][k[1]]): + continue + db.child("Homerooms").child(homeroom[0]).child( + homeroom[1]).child("Absent").child(date).child(k[0]).update({k[1]: formData[k[0]+'^'+k[1]]}, session['token']) + db.child("Homerooms").child(homeroom[0]).child( + homeroom[1]).child("Absent").child(date).child(k[0]).update({'changed': '1'}, session['token']) + return redirect('/manage/admin/' + homeroom[0] + '/' + homeroom[1] + '/' + date) + + @manage.route('/manage/group_teach_publish', methods=['POST']) def group_teach_publish(): if (check_login_status()): diff --git a/templates/swapclass.html b/templates/swapclass.html new file mode 100644 index 0000000..bb1ee78 --- /dev/null +++ b/templates/swapclass.html @@ -0,0 +1,88 @@ + + + + + + + + Admin 管理員 - Attendance 點名 + + + + + + + + + + + +
+
+

Swap Class | 改、換課

+

{{homeroom[0]}} {{homeroom[1]}}

+

[{{date}}]

+ +
+ + + + + + + + + {% for d in data %} + + {% if data[d] == 'aCfrm' %} + + + + {% else %} + + + + {% endif %} + + {% endfor %} +
Period 節Class 課Teacher 老師
{{d}}Cannot Change無法變更{{d}}
+

如果是分組課,請記得要去每個會變動的班更改

+ +
+
+ + + {% include 'footer.html' %} + + \ No newline at end of file