diff --git a/app.py b/app.py index e9c967d..7b0b3cd 100644 --- a/app.py +++ b/app.py @@ -153,6 +153,9 @@ def manageProcess(fCommand, fData): if not h[0] in absData[p]: absData[p][h[0]] = {} absData[p][h[0]][h[1]] = {} + if 'notes' in tmpAbsData[currDate][p]: + absData[p][h[0]][h[1] + ]['notes'] = tmpAbsData[currDate][p]['notes'] for num in hrData: if (cclass['category'] in hrData[num]['GP_Class'] and hrData[num]['GP_Class'][cclass['category']] == cclass['class_id']): @@ -270,6 +273,11 @@ def group_teach_publish(): date = request.form['date'] period = request.form['period'] signature = request.form['signatureData'] + formData = request.form.to_dict() + notes = "" + if 'notes' in request.form: + notes = request.form['notes'] + formData.pop('notes') signature = signature.removeprefix('data:image/png;base64,') signature = bytes(signature, 'utf-8') rand = str(randint(100000000000000, 999999999999999)) @@ -278,8 +286,6 @@ def group_teach_publish(): fh.write(base64.decodebytes(signature)) storage.child(os.path.join('signatures', rand) ).put(os.path.join('temp', rand)) - - formData = request.form.to_dict() formData.pop('signatureData') formData.pop('date') formData.pop('period') @@ -291,6 +297,15 @@ def group_teach_publish(): h = h.split('^') db.child("Homerooms").child(h[0]).child(h[1]).child( "Absent").child(date).child(period).child("signature").update({cclass['class_id']: str(storage.child(os.path.join('signatures', rand)).get_url(None))}) + # upload notes + currPeriodData = db.child("Homerooms").child(h[0]).child(h[1]).child( + "Absent").child(date).child(period).get().val() + if 'notes' in currPeriodData: + db.child("Homerooms").child(h[0]).child(h[1]).child( + "Absent").child(date).child(period).update({'notes': currPeriodData['notes']+'; '+notes}) + else: + db.child("Homerooms").child(h[0]).child(h[1]).child( + "Absent").child(date).child(period).update({'notes': notes}) os.remove(os.path.join('temp', rand)) return redirect('/manage') @@ -299,11 +314,15 @@ def group_teach_publish(): def homeroom_abs_publish(): if (check_login_status()): return redirect('/logout') - date = request.form['date'] homeroom = request.form['homeroom'].split('^') period = request.form['period'] signature = request.form['signatureData'] + formData = request.form.to_dict() + notes = "" + if 'notes' in request.form: + notes = request.form['notes'] + formData.pop('notes') signature = signature.removeprefix('data:image/png;base64,') signature = bytes(signature, 'utf-8') rand = str(randint(100000000000000, 999999999999999)) @@ -312,7 +331,6 @@ def homeroom_abs_publish(): fh.write(base64.decodebytes(signature)) storage.child(os.path.join('signatures', rand) ).put(os.path.join('temp', rand)) - formData = request.form.to_dict() formData.pop('signatureData') formData.pop('date') formData.pop('homeroom') @@ -323,6 +341,8 @@ def homeroom_abs_publish(): homeroom[1]).child("Absent").child(date).child(period).update({i[1]: int(i[0])}) db.child("Homerooms").child(homeroom[0]).child(homeroom[1]).child( "Absent").child(date).child(period).update({'signature': str(storage.child(os.path.join('signatures', rand)).get_url(None))}) + db.child("Homerooms").child(homeroom[0]).child(homeroom[1]).child( + "Absent").child(date).child(period).update({'notes': notes}) os.remove(os.path.join('temp', rand)) return redirect('/manage') diff --git a/templates/group_teach.html b/templates/group_teach.html index 4799217..fc97e46 100644 --- a/templates/group_teach.html +++ b/templates/group_teach.html @@ -29,8 +29,8 @@ {% endfor %} - {% set alr_fill = namespace(found=false) %} {% for i in absData %} + {% set alr_fill = namespace(found=false) %}
@@ -105,6 +105,9 @@

Please Sign Below

+

Notes 備註欄

+ diff --git a/templates/homeroom.html b/templates/homeroom.html index 4306663..7348918 100644 --- a/templates/homeroom.html +++ b/templates/homeroom.html @@ -132,6 +132,7 @@ +
{% if 'confirm' in absData[currDate] %} @@ -146,16 +147,19 @@ -

Please Sign Below
+

Please Sign Below 請在底下簽名
Period:
Subject:

+

Notes 備註欄

+ {% for c in range(periods|length + 1) %} - {% if c % 2 == 0 %} + {% if c % 4 == 0 %}
{% endif %}
@@ -167,7 +171,8 @@ {% if 'signature' in absData[currDate][periods[c-1]] %} {% for i in absData[currDate][periods[c-1]]['signature'] %}
{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['teacher']}}: {{i}}
-
+

備註: + {{absData[currDate][periods[c-1]]['notes']}}
{% endfor %} {% else %}
{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['teacher']}}: No Signature @@ -178,11 +183,12 @@
{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['name']}}: {{absData[currDate][periods[c-1]]['teacher']}}
-
+

備註: + {{absData[currDate][periods[c-1]]['notes']}}
{% endif %} {% endif %}
- {% if c % 2 == 1 %} + {% if c % 4 == 3 %}
{% endif %} {% endfor %} @@ -226,7 +232,9 @@ $('#hrCfrm-sign').val(data); document.getElementById('homeroom_confirm').submit() } else { + var notes = $('#subjectNotes').val(); document.getElementById('HR-signatureData').value = data; + document.getElementById('HR-notes').value = notes; document.getElementById('postHomeroomAbs').submit(); } }