mirror of
https://github.com/aaronleetw/Attendance.git
synced 2024-11-14 19:11:39 -08:00
Notes ok
This commit is contained in:
parent
63a3ff1346
commit
1c86d3f2d2
3 changed files with 41 additions and 10 deletions
28
app.py
28
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')
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</form>
|
||||
{% set alr_fill = namespace(found=false) %}
|
||||
{% for i in absData %}
|
||||
{% set alr_fill = namespace(found=false) %}
|
||||
<form action="/manage/group_teach_publish" id="attendanceData^{{i}}" method="post">
|
||||
<input type="hidden" name="date" value="{{currDate}}">
|
||||
<input type="hidden" name="period" value="{{i}}">
|
||||
|
@ -105,6 +105,9 @@
|
|||
</div>
|
||||
<h3>Please Sign Below</h3>
|
||||
<div class="forSign"><canvas id="signature_pad^{{i}}"></canvas></div>
|
||||
<h3>Notes 備註欄</h3>
|
||||
<input class="form-control" name="notes" id="subjectNotes^{{i}}" placeholder="Enter Notes 請輸入備註"
|
||||
style="width: 80%; margin-left: 10%;">
|
||||
<button class="btn btn-secondary" type="button" onclick="signaturePad.clear()">Clear
|
||||
Signature</button><button class="btn btn-primary" type="button"
|
||||
onclick="submitForm()">Submit</button>
|
||||
|
|
|
@ -132,6 +132,7 @@
|
|||
<input type="text" id="HR-date" name="date" value="{{currDate}}">
|
||||
<input type="text" id="HR-period" name="period" value="">
|
||||
<input type="text" id="HR-signatureData" name="signatureData" value="">
|
||||
<input type="text" id="HR-notes" name="notes" value="">
|
||||
<input type="text" id="HR-homeroom" name="homeroom" value="{{homeroomCode[0]}}^{{homeroomCode[1]}}">
|
||||
</form>
|
||||
{% if 'confirm' in absData[currDate] %}
|
||||
|
@ -146,16 +147,19 @@
|
|||
<div class="alert alert-warning" id="allPresentWarning" role="alert" hidden="hidden">
|
||||
<h4 class="alert-heading">請確認是否全班全到!Please check if everyone is present!</h4>
|
||||
</div>
|
||||
<h3>Please Sign Below <br>
|
||||
<h3>Please Sign Below 請在底下簽名<br>
|
||||
Period: <span id="showSignPeriod"></span> <br>
|
||||
Subject: <span id="showSignSubjectName"></span>
|
||||
</h3>
|
||||
<div class="forSign"><canvas id="signature_pad"></canvas></div>
|
||||
<h3>Notes 備註欄</h3>
|
||||
<input type="textarea" class="form-control" name="notes" id="subjectNotes"
|
||||
placeholder="Enter Notes 請輸入備註" style="width: 80%; margin-left: 10%;" row="3">
|
||||
<button class="btn btn-secondary" type="button" onclick="signaturePad.clear()">Clear Signature</button>
|
||||
<button class="btn btn-primary" type="button" onclick="submitForm()">Submit</button>
|
||||
</div>
|
||||
{% for c in range(periods|length + 1) %}
|
||||
{% if c % 2 == 0 %}
|
||||
{% if c % 4 == 0 %}
|
||||
<div class="row signatures">
|
||||
{% endif %}
|
||||
<div class="col half">
|
||||
|
@ -167,7 +171,8 @@
|
|||
{% if 'signature' in absData[currDate][periods[c-1]] %}
|
||||
{% for i in absData[currDate][periods[c-1]]['signature'] %}
|
||||
<div class="row">{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['teacher']}}: {{i}}</div>
|
||||
<div class="row"><img src="{{absData[currDate][periods[c-1]]['signature'][i]}}" alt=""></div>
|
||||
<div class="row"><img src="{{absData[currDate][periods[c-1]]['signature'][i]}}" alt=""><br>備註:
|
||||
{{absData[currDate][periods[c-1]]['notes']}}</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="row">{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['teacher']}}: No Signature
|
||||
|
@ -178,11 +183,12 @@
|
|||
<div class="row">{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['name']}}:
|
||||
{{absData[currDate][periods[c-1]]['teacher']}}
|
||||
</div>
|
||||
<div class="row"><img src="{{absData[currDate][periods[c-1]]['signature']}}" alt=""></div>
|
||||
<div class="row"><img src="{{absData[currDate][periods[c-1]]['signature']}}" alt=""><br>備註:
|
||||
{{absData[currDate][periods[c-1]]['notes']}}</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if c % 2 == 1 %}
|
||||
{% if c % 4 == 3 %}
|
||||
</div>
|
||||
{% 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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue