Handle confirmed homerooms; Added (C) footer

This commit is contained in:
Aaron Lee 2021-09-12 20:15:19 +08:00
parent 8ce46a8e1f
commit c727547530
6 changed files with 54 additions and 5 deletions

16
app.py
View file

@ -37,6 +37,8 @@ def check_login_status():
def manageProcess(fCommand, fData): def manageProcess(fCommand, fData):
if (check_login_status()):
return redirect('/logout')
# this is to fix a bug where pyrebase doesnt load the first request # this is to fix a bug where pyrebase doesnt load the first request
db.child("Users").child( db.child("Users").child(
session['uid']).child("permission").get().val() session['uid']).child("permission").get().val()
@ -86,6 +88,7 @@ def manageProcess(fCommand, fData):
print("got class") print("got class")
homerooms = cateData['Homerooms'] homerooms = cateData['Homerooms']
currDate = "" currDate = ""
confirmed = []
absData = {} absData = {}
for h in homerooms: for h in homerooms:
h = h.split('^') h = h.split('^')
@ -104,6 +107,7 @@ def manageProcess(fCommand, fData):
dow = tmpAbsData[currDate][j] dow = tmpAbsData[currDate][j]
continue continue
elif j == "confirm": elif j == "confirm":
confirmed.append([h[0], h[1]])
continue continue
if (tmpAbsData[currDate][j]['name'] == 'GP' and if (tmpAbsData[currDate][j]['name'] == 'GP' and
tmpAbsData[currDate][j]['teacher'] == cclass['category']): tmpAbsData[currDate][j]['teacher'] == cclass['category']):
@ -119,6 +123,7 @@ def manageProcess(fCommand, fData):
dow = tmpAbsData[i][j] dow = tmpAbsData[i][j]
continue continue
elif j == "confirm": elif j == "confirm":
confirmed.append([h[0], h[1]])
continue continue
if (tmpAbsData[i][j]['name'] == 'GP' and if (tmpAbsData[i][j]['name'] == 'GP' and
tmpAbsData[i][j]['teacher'] == cclass['category']): tmpAbsData[i][j]['teacher'] == cclass['category']):
@ -132,6 +137,7 @@ def manageProcess(fCommand, fData):
dow = tmpAbsData[currDate][j] dow = tmpAbsData[currDate][j]
continue continue
elif j == "confirm": elif j == "confirm":
confirmed.append([h[0], h[1]])
continue continue
if (tmpAbsData[currDate][j]['name'] == 'GP' and if (tmpAbsData[currDate][j]['name'] == 'GP' and
tmpAbsData[currDate][j]['teacher'] == cclass['category']): tmpAbsData[currDate][j]['teacher'] == cclass['category']):
@ -155,7 +161,7 @@ def manageProcess(fCommand, fData):
"absent": num in tmpAbsData[currDate][p] "absent": num in tmpAbsData[currDate][p]
} }
print(absData) print(absData)
return render_template('group_teach.html', cclass=cclass, absData=absData, dow=dow, currDate=currDate, tmpAbsData=tmpAbsData) 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(
session['uid']).child("homeroom").get().val().split('^') session['uid']).child("homeroom").get().val().split('^')
@ -222,6 +228,8 @@ def manage_admin():
@ app.route('/manage/group_teach_publish', methods=['POST']) @ app.route('/manage/group_teach_publish', methods=['POST'])
def group_teach_publish(): def group_teach_publish():
if (check_login_status()):
return redirect('/logout')
classes = db.child("Users").child( classes = db.child("Users").child(
session['uid']).child("class").get().val() session['uid']).child("class").get().val()
cclass = {} cclass = {}
@ -265,6 +273,9 @@ def group_teach_publish():
@ app.route('/manage/homeroom_abs', methods=['POST']) @ app.route('/manage/homeroom_abs', methods=['POST'])
def homeroom_abs_publish(): def homeroom_abs_publish():
if (check_login_status()):
return redirect('/logout')
date = request.form['date'] date = request.form['date']
homeroom = request.form['homeroom'].split('^') homeroom = request.form['homeroom'].split('^')
period = request.form['period'] period = request.form['period']
@ -293,6 +304,8 @@ def homeroom_abs_publish():
@app.route('/manage/homeroom_confirm', methods=['POST']) @app.route('/manage/homeroom_confirm', methods=['POST'])
def homeroom_confirm(): def homeroom_confirm():
if (check_login_status()):
return redirect('/logout')
date = request.form['date'] date = request.form['date']
homeroom = request.form['homeroom'].split('^') homeroom = request.form['homeroom'].split('^')
signature = request.form['signatureData'] signature = request.form['signatureData']
@ -306,6 +319,7 @@ def homeroom_confirm():
).put(os.path.join('temp', rand)) ).put(os.path.join('temp', rand))
db.child("Homerooms").child(homeroom[0]).child(homeroom[1]).child("Absent").child(date).update( db.child("Homerooms").child(homeroom[0]).child(homeroom[1]).child("Absent").child(date).update(
{"confirm": str(storage.child(os.path.join('signatures', rand)).get_url(None))}) {"confirm": str(storage.child(os.path.join('signatures', rand)).get_url(None))})
os.remove(os.path.join('temp', rand))
return redirect('/manage') return redirect('/manage')

View file

@ -186,6 +186,13 @@
<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%;" />
</div> </div>
<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://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a>
</p>
</footer>
<script> <script>
var homerooms = {}; var homerooms = {};
{% for i in homerooms %} {% for i in homerooms %}

View file

@ -67,7 +67,7 @@
{% endif %} {% endif %}
{% else %} {% else %}
<div class="col"> <div class="col">
{% if 'confirm' in absData[i][grade][homeroom] %} {% if [grade,homeroom] in confirmed %}
<p class="highlightAbs">--</p> <p class="highlightAbs">--</p>
{% else %} {% else %}
<input type="checkbox" class="{{grade}}^{{homeroom}}^{{student}}"> <input type="checkbox" class="{{grade}}^{{homeroom}}^{{student}}">
@ -135,6 +135,13 @@
<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%;" />
</div> </div>
<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://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a>
</p>
</footer>
<script> <script>
function loadingAnimation() { function loadingAnimation() {
$("div.container").hide(); $("div.container").hide();

View file

@ -194,7 +194,13 @@
<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%;" />
</div> </div>
<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://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a>
</p>
</footer>
<script> <script>
var signaturePad, hrCfrm = false; var signaturePad, hrCfrm = false;
function loadingAnimation() { function loadingAnimation() {
@ -253,6 +259,8 @@
} }
function homeroomCfrm() { function homeroomCfrm() {
hrCfrm = true; hrCfrm = true;
$('.tobeform').attr('disabled', 'disabled');
$('.afterSelButton').attr('disabled', 'disabled');
showSignaturePad(); showSignaturePad();
} }
</script> </script>

View file

@ -40,8 +40,14 @@
<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%;" />
</div> </div>
<!-- end login form center --> <footer>
<script type="text/javascript" src="/static/jquery.min.js"></script> <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://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a>
</p>
</footer>
<script type=" text/javascript" src="/static/jquery.min.js"></script>
<script> <script>
function loadingAnimation() { function loadingAnimation() {
$('.container').hide(); $('.container').hide();

View file

@ -49,6 +49,13 @@
<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%;" />
</div> </div>
<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://www.fhjh.tp.edu.tw">Taipei Fuhsing Private School</a>
</p>
</footer>
<script type="text/javascript" src="/static/jquery.min.js"></script> <script type="text/javascript" src="/static/jquery.min.js"></script>
<script> <script>
function loadingAnimation() { function loadingAnimation() {