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

View file

@ -50,11 +50,15 @@ p.highlightAbs.n-2 {
color: red;
}
p.highlightAbs.n-3 {
color: rgb(15, 184, 0);
}
.margin-top {
margin-top: 20px;
}
input[type="checkbox"]{
input[type="checkbox"].absent, input[type="checkbox"].late {
-webkit-appearance: initial;
appearance: initial;
background: rgb(207, 207, 207);
@ -64,16 +68,26 @@ input[type="checkbox"]{
margin-top: 3px;
position: relative;
}
input[type="checkbox"]:checked {
input[type="checkbox"].absent:checked {
background: red;
}
input[type="checkbox"]:checked:after {
/* Heres your symbol replacement */
input[type="checkbox"].absent:checked:after {
content: "X";
color: #fff;
/* The following positions my tick in the center,
* but you could just overlay the entire box
* with a full after element with a background if you want to */
color: white;
position: absolute;
left: 50%;
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;
left: 50%;
top: 50%;
@ -81,13 +95,4 @@ input[type="checkbox"]:checked:after {
-moz-transform: translate(-50%,-50%);
-ms-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>
<hr>
<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>
<br>
Consultants: Mr. Raymond Tsai, Alvin Tsao
Consultants: Mr. Raymond Tsai 蔡瑋倫老師, Alvin Tsao 曹庭睿
</p>
</footer>
<script>

View file

@ -36,7 +36,7 @@
<input type="hidden" name="period" value="{{i}}">
<input type="hidden" class="signatureData" name="signatureData" value="">
<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">Class Code</div>
<div class="col">Number</div>
@ -56,10 +56,14 @@
<div class="col">{{ absData[i][grade][homeroom][student]['eng_name'] }}</div>
{% if absData[i][grade][homeroom][student]['alr_fill'] %}
{% set alr_fill.found = true %}
{% if absData[i][grade][homeroom][student]['absent'] %}
{% if absData[i][grade][homeroom][student]['absent'] == 1 %}
<div class="col">
<p class="highlightAbs n-2">X</p>
</div>
{% elif absData[i][grade][homeroom][student]['absent'] == 2 %}
<div class="col">
<p class="highlightAbs n-3">φ</p>
</div>
{% else %}
<div class="col">
<p class="highlightAbs n-1">V</p>
@ -70,7 +74,14 @@
{% if [grade,homeroom] in confirmed %}
<p class="highlightAbs">--</p>
{% 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 %}
</div>
{% endif %}
@ -108,6 +119,7 @@
var signaturePad, selPeriod;
function submitForm() {
if (!signaturePad.isEmpty()) {
loadingAnimation();
signaturePad.off();
var data = signaturePad.toDataURL('image/png');
document.getElementById("attendanceData^" + selPeriod).getElementsByClassName("signatureData")[0].value = data;
@ -146,6 +158,12 @@
window.addEventListener("resize", resizeCanvas);
resizeCanvas();
}
function unCheckAbs(string) {
document.getElementById('absent^' + string).checked = false;
}
function unCheckLate(string) {
document.getElementById('late^' + string).checked = false;
}
</script>
<div id="loading" style="text-align:center; width:100%; display:none;"><img src="/static/loading.gif" alt=""
style="height:100%;" />
@ -153,11 +171,10 @@
<footer>
<hr>
<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>
<br>
Consultants: Mr. Raymond Tsai, Alvin Tsao
Consultants: Mr. Raymond Tsai 蔡瑋倫老師, Alvin Tsao 曹庭睿
</p>
</footer>
<script>

View file

@ -35,6 +35,7 @@
<input type="hidden" id="hrCfrm-sign" name="signatureData" value="">
</form>
<div class="col">
<div class="sticky-top" style="background-color:white;">
<div class="row title">
<div class="col">HR</div>
<div class="col">Number</div>
@ -64,7 +65,7 @@
{{absData[currDate][i]['teacher']}}</div>
{% endfor %}
</div>
{% if data != None %}
</div>
{% for i in homeroomData %}
<div class="row">
<div class="col">{{homeroomCode[0]}}{{homeroomCode[1]}}</div>
@ -75,8 +76,12 @@
<div class="col" {% if currPeriod==j %} style="background-color: #ffdf81;" {% endif %}>
{% if 'signature' in absData[currDate][j] %}
{% if i in absData[currDate][j] %}
{% if absData[currDate][j][i] == 1 %}
<p class="highlightAbs n-2">X</p>
{% else %}
<p class="highlightAbs n-3">φ</p>
{% endif %}
{% else %}
{% if absData[currDate][j]['name'] != 'GP' %}
<p class="highlightAbs n-1">V</p>
{% else %}
@ -94,8 +99,12 @@
{% if 'confirm' in absData[currDate] %}
<p class="highlightAbs"></p>
{% 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 %}
<!-- <input type="checkbox" class="tobeform {{j}}^{{i}}"> -->
{% endif %}
</div>
{% endfor %}
@ -119,7 +128,6 @@
</div>
{% endfor %}
</div>
{% endif %}
<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-period" name="period" value="">
@ -188,10 +196,10 @@
<footer>
<hr>
<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>
<br>
Consultants: Mr. Raymond Tsai, Alvin Tsao
Consultants: Mr. Raymond Tsai 蔡瑋倫老師, Alvin Tsao 曹庭睿
</p>
</footer>
<script>
@ -242,17 +250,18 @@
}
function afterSelAbs(period) {
var tobeformArr = [];
$('#postHomeroomAbs #HR-period').val(period);
$('#postHomeroomAbs #HR-period').attr('value', period);
$('.tobeform').attr('disabled', 'disabled');
$('.afterSelButton').attr('disabled', 'disabled');
$('#showSignPeriod').text(period);
$('#showSignSubjectName').text(periodData[period]);
var cnt = 0;
$('.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")) {
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">');
}
});
@ -268,6 +277,12 @@
$('.afterSelButton').attr('disabled', 'disabled');
showSignaturePad();
}
function unCheckLate(string) {
document.getElementById('late^' + string).checked = false;
}
function unCheckAbs(string) {
document.getElementById('absent^' + string).checked = false;
}
</script>
</body>

View file

@ -43,10 +43,10 @@
<footer>
<hr>
<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>
<br>
Consultants: Mr. Raymond Tsai, Alvin Tsao
Consultants: Mr. Raymond Tsai 蔡瑋倫老師, Alvin Tsao 曹庭睿
</p>
</footer>
<script type=" text/javascript" src="/static/jquery.min.js"></script>

View file

@ -52,10 +52,10 @@
<footer>
<hr>
<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>
<br>
Consultants: Mr. Raymond Tsai, Alvin Tsao
Consultants: Mr. Raymond Tsai 蔡瑋倫老師, Alvin Tsao 曹庭睿
</p>
</footer>
<script type="text/javascript" src="/static/jquery.min.js"></script>