Added late option; Added chinese name to footer

This commit is contained in:
Aaron Lee 2021-09-13 22:42:12 +08:00
parent 4f9d727afb
commit 63a3ff1346
7 changed files with 107 additions and 76 deletions

16
app.py
View file

@ -97,7 +97,6 @@ def manageProcess(fCommand, fData):
absData = {} absData = {}
for h in homerooms: for h in homerooms:
h = h.split('^') h = h.split('^')
print(h)
hrData = db.child("Homerooms").child(h[0]).child(h[1]).get().val() hrData = db.child("Homerooms").child(h[0]).child(h[1]).get().val()
tmpAbsData = hrData['Absent'] tmpAbsData = hrData['Absent']
hrData.pop('Absent') hrData.pop('Absent')
@ -163,9 +162,8 @@ def manageProcess(fCommand, fData):
"eng_name": hrData[num]['eng_name'], "eng_name": hrData[num]['eng_name'],
"alr_fill": ('signature' in tmpAbsData[currDate][p] and "alr_fill": ('signature' in tmpAbsData[currDate][p] and
cclass['class_id'] in tmpAbsData[currDate][p]['signature']), cclass['class_id'] in tmpAbsData[currDate][p]['signature']),
"absent": num in tmpAbsData[currDate][p] "absent": False if not num in tmpAbsData[currDate][p] else tmpAbsData[currDate][p][num]
} }
print(absData)
return render_template('group_teach.html', cclass=cclass, absData=absData, dow=dow, currDate=currDate, tmpAbsData=tmpAbsData, confirmed=confirmed) return render_template('group_teach.html', cclass=cclass, absData=absData, dow=dow, currDate=currDate, tmpAbsData=tmpAbsData, confirmed=confirmed)
elif pl == 'homeroom': elif pl == 'homeroom':
homeroom = db.child("Users").child( homeroom = db.child("Users").child(
@ -204,7 +202,6 @@ def manageProcess(fCommand, fData):
currDate = i currDate = i
if i >= datetime.now(tz).strftime("%Y-%m-%d"): if i >= datetime.now(tz).strftime("%Y-%m-%d"):
break break
print(currPeriod)
return render_template('homeroom.html', absData=absData, homeroomCode=homeroom, homeroomData=homeroomData, return render_template('homeroom.html', absData=absData, homeroomCode=homeroom, homeroomData=homeroomData,
currDate=currDate, periods=['m', '1', '2', '3', '4', 'n', '5', '6', '7', '8', '9'], currPeriod=currPeriod) currDate=currDate, periods=['m', '1', '2', '3', '4', 'n', '5', '6', '7', '8', '9'], currPeriod=currPeriod)
else: else:
@ -270,7 +267,6 @@ def group_teach_publish():
"homerooms": db.child("Classes").child( "homerooms": db.child("Classes").child(
"GP_Class").child(i).child("Homerooms").get().val() "GP_Class").child(i).child("Homerooms").get().val()
} }
print("got class")
date = request.form['date'] date = request.form['date']
period = request.form['period'] period = request.form['period']
signature = request.form['signatureData'] signature = request.form['signatureData']
@ -289,8 +285,8 @@ def group_teach_publish():
formData.pop('period') formData.pop('period')
for i in formData: for i in formData:
i = i.split('^') i = i.split('^')
db.child("Homerooms").child(i[0]).child(i[1]).child( db.child("Homerooms").child(i[1]).child(i[2]).child(
"Absent").child(date).child(period).update({i[2]: 0}) "Absent").child(date).child(period).update({i[3]: int(i[0])})
for h in cclass['homerooms']: for h in cclass['homerooms']:
h = h.split('^') h = h.split('^')
db.child("Homerooms").child(h[0]).child(h[1]).child( db.child("Homerooms").child(h[0]).child(h[1]).child(
@ -322,8 +318,9 @@ def homeroom_abs_publish():
formData.pop('homeroom') formData.pop('homeroom')
formData.pop('period') formData.pop('period')
for i in formData: for i in formData:
i = i.split('^')
db.child("Homerooms").child(homeroom[0]).child( db.child("Homerooms").child(homeroom[0]).child(
homeroom[1]).child("Absent").child(date).child(period).update({i: 0}) homeroom[1]).child("Absent").child(date).child(period).update({i[1]: int(i[0])})
db.child("Homerooms").child(homeroom[0]).child(homeroom[1]).child( 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))}) "Absent").child(date).child(period).update({'signature': str(storage.child(os.path.join('signatures', rand)).get_url(None))})
os.remove(os.path.join('temp', rand)) os.remove(os.path.join('temp', rand))
@ -451,7 +448,6 @@ def upload_period_list():
periodCodes = csv_dict['Period Day'].tolist() periodCodes = csv_dict['Period Day'].tolist()
for i in range(5): for i in range(5):
tmp_csv = csv_dict[str(i+1)].tolist() tmp_csv = csv_dict[str(i+1)].tolist()
print(tmp_csv)
for j in range(len(tmp_csv)): for j in range(len(tmp_csv)):
if not (periodCodes[j].endswith('-t')): if not (periodCodes[j].endswith('-t')):
if type(tmp_csv[j]) == float: if type(tmp_csv[j]) == float:
@ -490,8 +486,6 @@ def upload_dates():
for i in temp[t]: for i in temp[t]:
periodData = db.child("Classes").child( periodData = db.child("Classes").child(
"Homeroom").child(t).child(i).get().val() "Homeroom").child(t).child(i).get().val()
print(type(t), t)
print(type(i), i)
db.child("Homerooms").child(t).child(i).child( db.child("Homerooms").child(t).child(i).child(
"Absent").child(h).update({"dow": row[h]}) "Absent").child(h).update({"dow": row[h]})
db.child("Homerooms").child(t).child(i).child( db.child("Homerooms").child(t).child(i).child(

View file

@ -50,11 +50,15 @@ p.highlightAbs.n-2 {
color: red; color: red;
} }
p.highlightAbs.n-3 {
color: rgb(15, 184, 0);
}
.margin-top { .margin-top {
margin-top: 20px; margin-top: 20px;
} }
input[type="checkbox"]{ input[type="checkbox"].absent, input[type="checkbox"].late {
-webkit-appearance: initial; -webkit-appearance: initial;
appearance: initial; appearance: initial;
background: rgb(207, 207, 207); background: rgb(207, 207, 207);
@ -64,16 +68,26 @@ input[type="checkbox"]{
margin-top: 3px; margin-top: 3px;
position: relative; position: relative;
} }
input[type="checkbox"]:checked { input[type="checkbox"].absent:checked {
background: red; background: red;
} }
input[type="checkbox"]:checked:after { input[type="checkbox"].absent:checked:after {
/* Heres your symbol replacement */
content: "X"; content: "X";
color: #fff; color: white;
/* The following positions my tick in the center, position: absolute;
* but you could just overlay the entire box left: 50%;
* with a full after element with a background if you want to */ top: 50%;
-webkit-transform: translate(-50%,-50%);
-moz-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
input[type="checkbox"].late:checked {
background: rgb(15, 184, 0);
}
input[type="checkbox"].late:checked:after {
content: "φ";
color: #fff;
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 50%; top: 50%;
@ -81,13 +95,4 @@ input[type="checkbox"]:checked:after {
-moz-transform: translate(-50%,-50%); -moz-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%); -ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%); transform: translate(-50%,-50%);
/*
* If you want to fully change the check appearance, use the following:
* content: " ";
* width: 100%;
* height: 100%;
* background: blue;
* top: 0;
* left: 0;
*/
} }

View file

@ -189,10 +189,10 @@
<footer> <footer>
<hr> <hr>
<p style="text-align: center;">&copy; 2021 Attendance (β) | Made by <a target="_blank" <p style="text-align: center;">&copy; 2021 Attendance (β) | Made by <a target="_blank"
href="https://github.com/aaronleetw">Aaron Lee</a> for <a target="_blank" href="https://github.com/aaronleetw">Aaron Lee 李翊愷</a> for <a target="_blank"
href="https://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a> href="https://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a>
<br> <br>
Consultants: Mr. Raymond Tsai, Alvin Tsao Consultants: Mr. Raymond Tsai 蔡瑋倫老師, Alvin Tsao 曹庭睿
</p> </p>
</footer> </footer>
<script> <script>

View file

@ -36,7 +36,7 @@
<input type="hidden" name="period" value="{{i}}"> <input type="hidden" name="period" value="{{i}}">
<input type="hidden" class="signatureData" name="signatureData" value=""> <input type="hidden" class="signatureData" name="signatureData" value="">
<div class="col"> <div class="col">
<div class="row title"> <div class="row title sticky-top" style="background-color: white">
<div class="col">Grade</div> <div class="col">Grade</div>
<div class="col">Class Code</div> <div class="col">Class Code</div>
<div class="col">Number</div> <div class="col">Number</div>
@ -56,10 +56,14 @@
<div class="col">{{ absData[i][grade][homeroom][student]['eng_name'] }}</div> <div class="col">{{ absData[i][grade][homeroom][student]['eng_name'] }}</div>
{% if absData[i][grade][homeroom][student]['alr_fill'] %} {% if absData[i][grade][homeroom][student]['alr_fill'] %}
{% set alr_fill.found = true %} {% set alr_fill.found = true %}
{% if absData[i][grade][homeroom][student]['absent'] %} {% if absData[i][grade][homeroom][student]['absent'] == 1 %}
<div class="col"> <div class="col">
<p class="highlightAbs n-2">X</p> <p class="highlightAbs n-2">X</p>
</div> </div>
{% elif absData[i][grade][homeroom][student]['absent'] == 2 %}
<div class="col">
<p class="highlightAbs n-3">φ</p>
</div>
{% else %} {% else %}
<div class="col"> <div class="col">
<p class="highlightAbs n-1">V</p> <p class="highlightAbs n-1">V</p>
@ -70,7 +74,14 @@
{% if [grade,homeroom] in confirmed %} {% if [grade,homeroom] in confirmed %}
<p class="highlightAbs">--</p> <p class="highlightAbs">--</p>
{% else %} {% else %}
<input type="checkbox" class="tobeform {{grade}}^{{homeroom}}^{{student}}"> <input type="checkbox" class="tobeform {{grade}}^{{homeroom}}^{{student}} late"
id="late^{{i}}^{{grade}}^{{homeroom}}^{{student}}"
name="2^{{grade}}^{{homeroom}}^{{student}}"
onchange="unCheckAbs('{{i}}^{{grade}}^{{homeroom}}^{{student}}')">
<input type="checkbox" class="tobeform {{grade}}^{{homeroom}}^{{student}} absent"
id="absent^{{i}}^{{grade}}^{{homeroom}}^{{student}}"
name="1^{{grade}}^{{homeroom}}^{{student}}"
onchange="unCheckLate('{{i}}^{{grade}}^{{homeroom}}^{{student}}')">
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
@ -108,6 +119,7 @@
var signaturePad, selPeriod; var signaturePad, selPeriod;
function submitForm() { function submitForm() {
if (!signaturePad.isEmpty()) { if (!signaturePad.isEmpty()) {
loadingAnimation();
signaturePad.off(); signaturePad.off();
var data = signaturePad.toDataURL('image/png'); var data = signaturePad.toDataURL('image/png');
document.getElementById("attendanceData^" + selPeriod).getElementsByClassName("signatureData")[0].value = data; document.getElementById("attendanceData^" + selPeriod).getElementsByClassName("signatureData")[0].value = data;
@ -146,6 +158,12 @@
window.addEventListener("resize", resizeCanvas); window.addEventListener("resize", resizeCanvas);
resizeCanvas(); resizeCanvas();
} }
function unCheckAbs(string) {
document.getElementById('absent^' + string).checked = false;
}
function unCheckLate(string) {
document.getElementById('late^' + string).checked = false;
}
</script> </script>
<div id="loading" style="text-align:center; width:100%; display:none;"><img src="/static/loading.gif" alt="" <div id="loading" style="text-align:center; width:100%; display:none;"><img src="/static/loading.gif" alt=""
style="height:100%;" /> style="height:100%;" />
@ -153,11 +171,10 @@
<footer> <footer>
<hr> <hr>
<p style="text-align: center;">&copy; 2021 Attendance (β) | Made by <a target="_blank" <p style="text-align: center;">&copy; 2021 Attendance (β) | Made by <a target="_blank"
href="https://github.com/aaronleetw">Aaron Lee</a> for <a target="_blank" href="https://github.com/aaronleetw">Aaron Lee 李翊愷</a> for <a target="_blank"
href="https://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a> href="https://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a>
<br> <br>
Consultants: Mr. Raymond Tsai, Alvin Tsao Consultants: Mr. Raymond Tsai 蔡瑋倫老師, Alvin Tsao 曹庭睿
</p> </p>
</footer> </footer>
<script> <script>

View file

@ -35,6 +35,7 @@
<input type="hidden" id="hrCfrm-sign" name="signatureData" value=""> <input type="hidden" id="hrCfrm-sign" name="signatureData" value="">
</form> </form>
<div class="col"> <div class="col">
<div class="sticky-top" style="background-color:white;">
<div class="row title"> <div class="row title">
<div class="col">HR</div> <div class="col">HR</div>
<div class="col">Number</div> <div class="col">Number</div>
@ -64,7 +65,7 @@
{{absData[currDate][i]['teacher']}}</div> {{absData[currDate][i]['teacher']}}</div>
{% endfor %} {% endfor %}
</div> </div>
{% if data != None %} </div>
{% for i in homeroomData %} {% for i in homeroomData %}
<div class="row"> <div class="row">
<div class="col">{{homeroomCode[0]}}{{homeroomCode[1]}}</div> <div class="col">{{homeroomCode[0]}}{{homeroomCode[1]}}</div>
@ -75,8 +76,12 @@
<div class="col" {% if currPeriod==j %} style="background-color: #ffdf81;" {% endif %}> <div class="col" {% if currPeriod==j %} style="background-color: #ffdf81;" {% endif %}>
{% if 'signature' in absData[currDate][j] %} {% if 'signature' in absData[currDate][j] %}
{% if i in absData[currDate][j] %} {% if i in absData[currDate][j] %}
{% if absData[currDate][j][i] == 1 %}
<p class="highlightAbs n-2">X</p> <p class="highlightAbs n-2">X</p>
{% else %} {% else %}
<p class="highlightAbs n-3">φ</p>
{% endif %}
{% else %}
{% if absData[currDate][j]['name'] != 'GP' %} {% if absData[currDate][j]['name'] != 'GP' %}
<p class="highlightAbs n-1">V</p> <p class="highlightAbs n-1">V</p>
{% else %} {% else %}
@ -94,8 +99,12 @@
{% if 'confirm' in absData[currDate] %} {% if 'confirm' in absData[currDate] %}
<p class="highlightAbs"></p> <p class="highlightAbs"></p>
{% else %} {% else %}
<input type="checkbox" class="tobeform {{j}}^{{i}}"> <input type="checkbox" class="tobeform 2^{{j}}^{{i}} late" id="late^{{j}}^{{i}}"
onchange="unCheckAbs('{{j}}^{{i}}')">
<input type="checkbox" class="tobeform 1^{{j}}^{{i}} absent" id="absent^{{j}}^{{i}}"
onchange="unCheckLate('{{j}}^{{i}}')">
{% endif %} {% endif %}
<!-- <input type="checkbox" class="tobeform {{j}}^{{i}}"> -->
{% endif %} {% endif %}
</div> </div>
{% endfor %} {% endfor %}
@ -119,7 +128,6 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
{% endif %}
<form action="/manage/homeroom_abs" id="postHomeroomAbs" hidden="hidden" method="post"> <form action="/manage/homeroom_abs" id="postHomeroomAbs" hidden="hidden" method="post">
<input type="text" id="HR-date" name="date" value="{{currDate}}"> <input type="text" id="HR-date" name="date" value="{{currDate}}">
<input type="text" id="HR-period" name="period" value=""> <input type="text" id="HR-period" name="period" value="">
@ -188,10 +196,10 @@
<footer> <footer>
<hr> <hr>
<p style="text-align: center;">&copy; 2021 Attendance (β) | Made by <a target="_blank" <p style="text-align: center;">&copy; 2021 Attendance (β) | Made by <a target="_blank"
href="https://github.com/aaronleetw">Aaron Lee</a> for <a target="_blank" href="https://github.com/aaronleetw">Aaron Lee 李翊愷</a> for <a target="_blank"
href="https://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a> href="https://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a>
<br> <br>
Consultants: Mr. Raymond Tsai, Alvin Tsao Consultants: Mr. Raymond Tsai 蔡瑋倫老師, Alvin Tsao 曹庭睿
</p> </p>
</footer> </footer>
<script> <script>
@ -242,17 +250,18 @@
} }
function afterSelAbs(period) { function afterSelAbs(period) {
var tobeformArr = []; var tobeformArr = [];
$('#postHomeroomAbs #HR-period').val(period); $('#postHomeroomAbs #HR-period').attr('value', period);
$('.tobeform').attr('disabled', 'disabled'); $('.tobeform').attr('disabled', 'disabled');
$('.afterSelButton').attr('disabled', 'disabled'); $('.afterSelButton').attr('disabled', 'disabled');
$('#showSignPeriod').text(period); $('#showSignPeriod').text(period);
$('#showSignSubjectName').text(periodData[period]); $('#showSignSubjectName').text(periodData[period]);
var cnt = 0; var cnt = 0;
$('.tobeform').each(function (i, obj) { $('.tobeform').each(function (i, obj) {
if ($(this).attr('class').split(' ')[1].split('^')[0] == period && if ($(this).attr('class').split(' ')[1].split('^')[1] == period &&
$(this).is(":checked")) { $(this).is(":checked")) {
cnt++; cnt++;
$('#postHomeroomAbs').append('<input type="checkbox" name="' + $(this).attr('class').split(' ')[1].split('^')[1] $('#postHomeroomAbs').append('<input type="checkbox" name="' + $(this).attr('class').split(' ')[1].split('^')[0] + '^'
+ $(this).attr('class').split(' ')[1].split('^')[2]
+ '" checked="checked">'); + '" checked="checked">');
} }
}); });
@ -268,6 +277,12 @@
$('.afterSelButton').attr('disabled', 'disabled'); $('.afterSelButton').attr('disabled', 'disabled');
showSignaturePad(); showSignaturePad();
} }
function unCheckLate(string) {
document.getElementById('late^' + string).checked = false;
}
function unCheckAbs(string) {
document.getElementById('absent^' + string).checked = false;
}
</script> </script>
</body> </body>

View file

@ -43,10 +43,10 @@
<footer> <footer>
<hr> <hr>
<p style="text-align: center;">&copy; 2021 Attendance (β) | Made by <a target="_blank" <p style="text-align: center;">&copy; 2021 Attendance (β) | Made by <a target="_blank"
href="https://github.com/aaronleetw">Aaron Lee</a> for <a target="_blank" href="https://github.com/aaronleetw">Aaron Lee 李翊愷</a> for <a target="_blank"
href="https://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a> href="https://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a>
<br> <br>
Consultants: Mr. Raymond Tsai, Alvin Tsao Consultants: Mr. Raymond Tsai 蔡瑋倫老師, Alvin Tsao 曹庭睿
</p> </p>
</footer> </footer>
<script type=" text/javascript" src="/static/jquery.min.js"></script> <script type=" text/javascript" src="/static/jquery.min.js"></script>

View file

@ -52,10 +52,10 @@
<footer> <footer>
<hr> <hr>
<p style="text-align: center;">&copy; 2021 Attendance (β) | Made by <a target="_blank" <p style="text-align: center;">&copy; 2021 Attendance (β) | Made by <a target="_blank"
href="https://github.com/aaronleetw">Aaron Lee</a> for <a target="_blank" href="https://github.com/aaronleetw">Aaron Lee 李翊愷</a> for <a target="_blank"
href="https://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a> href="https://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a>
<br> <br>
Consultants: Mr. Raymond Tsai, Alvin Tsao Consultants: Mr. Raymond Tsai 蔡瑋倫老師, Alvin Tsao 曹庭睿
</p> </p>
</footer> </footer>
<script type="text/javascript" src="/static/jquery.min.js"></script> <script type="text/javascript" src="/static/jquery.min.js"></script>