Merge branch 'master' into edit

This commit is contained in:
Aaron Lee 2021-10-15 20:39:03 +08:00
commit 07d72978df
5 changed files with 97 additions and 76 deletions

6
app.py
View file

@ -9,6 +9,12 @@ app.register_blueprint(upload)
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY') app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY')
@app.after_request
def add_header(response):
response.headers['SameSite'] = "Strict"
return response
@ app.route('/', methods=['GET', 'POST']) @ app.route('/', methods=['GET', 'POST'])
def index(): def index():
if request.method == 'GET': if request.method == 'GET':

View file

@ -187,16 +187,16 @@ def manageRoot():
return manageProcess("", "") return manageProcess("", "")
@manage.route('/manage/date', methods=['POST']) @manage.route('/manage/date/<date>', methods=['GET'])
def manage_date(): def manage_date(date):
return manageProcess("date", request.form['date']) return manageProcess("date", date)
@manage.route('/manage/admin', methods=['POST']) @manage.route('/manage/admin/<g>/<r>/<date>', methods=['GET'])
def manage_admin(): def manage_admin(g, r, date):
data = [ data = [
request.form['grade'] + '^' + request.form['room'], g + '^' + r,
request.form['date'] date
] ]
return manageProcess("admin", data) return manageProcess("admin", data)

View file

@ -34,8 +34,14 @@
<h2 style="color: red; text-align: center;">Homeroom NOT Confirmed 班導尚未確認</h2> <h2 style="color: red; text-align: center;">Homeroom NOT Confirmed 班導尚未確認</h2>
{% endif %} {% endif %}
<a href="/logout"><button class="btn btn-primary logout margin-top">Logout 登出</button></a> <a href="/logout"><button class="btn btn-primary logout margin-top">Logout 登出</button></a>
<form action="/swapClass" method="post" id="swapClassForm" hidden>
<input type="text" name="homeroom" value="{{homeroomCode[0]}}^{{homeroomCode[1]}}">
<input type="text" name="date" value="{{currDate}}">
<input type="text" name="type" value="seewindow">
</form>
<a href="/swapClass/{{homeroomCode[0]}}/{{homeroomCode[1]}}/{{currDate}}"><button
class="btn btn-warning logout margin-top">Swap Classes 改、換課</button></a>
<div class="container margin-bottom"> <div class="container margin-bottom">
<form action="/manage/admin" id="adminSelForm" method="post">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<select name="grade" id="sel-grade" class="form-select" onchange="getHR()" required> <select name="grade" id="sel-grade" class="form-select" onchange="getHR()" required>
@ -62,10 +68,9 @@
</select> </select>
</div> </div>
<div class="col-1"> <div class="col-1">
<button type="button" class="btn btn-primary" onclick="loadingAnimation()">查詢</button> <button type="button" class="btn btn-primary" onclick="redirAdmin()">查詢</button>
</div> </div>
</div> </div>
</form>
</div> </div>
<div class="col"> <div class="col">
<div class="sticky-top" style="background-color: white;"> <div class="sticky-top" style="background-color: white;">
@ -84,7 +89,11 @@
<div class="col"></div> <div class="col"></div>
<div class="col"></div> <div class="col"></div>
{% for i in periods %} {% for i in periods %}
<div class="col">{{absData[currDate][i]['name']}}</div> <div class="col">{{absData[currDate][i]['name']}}
{% if 'changed' in absData[currDate][i] %}
<span style="color: red;">(換)</span>
{% endif %}
</div>
{% endfor %} {% endfor %}
</div> </div>
<div class="row title"> <div class="row title">
@ -102,7 +111,7 @@
<div class="row"> <div class="row">
<div class="col">{{homeroomCode[0]}}{{homeroomCode[1]}}</div> <div class="col">{{homeroomCode[0]}}{{homeroomCode[1]}}</div>
<div class="col">{{i}}</div> <div class="col">{{i}}</div>
<div class="col">{{ homeroomData[i]['name'] }}</div> <div class="col">{{ homeroomData[i]['name'] }} </div>
<div class="col">{{ homeroomData[i]['eng_name'] }}</div> <div class="col">{{ homeroomData[i]['eng_name'] }}</div>
{% for j in periods %} {% for j in periods %}
<div class="col" {% if currPeriod==j %} style="background-color: #ffdf81;" {% endif %}> <div class="col" {% if currPeriod==j %} style="background-color: #ffdf81;" {% endif %}>
@ -222,16 +231,6 @@
homerooms['{{i}}'].push({{ j }}); homerooms['{{i}}'].push({{ j }});
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
console.log(homerooms)
function loadingAnimation() {
if ($("#sel-room").val() == "") {
alert("請選擇年級 / 班級!");
return;
}
document.getElementById('adminSelForm').submit();
$('.container').hide();
$('#loading').show();
}
function getHR() { function getHR() {
var grade = $('#sel-grade').val(); var grade = $('#sel-grade').val();
$('#sel-room').html('<option value="">請先選擇年級</option>'); $('#sel-room').html('<option value="">請先選擇年級</option>');
@ -244,9 +243,19 @@
}); });
$('#sel-room').removeAttr('disabled') $('#sel-room').removeAttr('disabled')
} }
function submitQuery() { function redirAdmin() {
loadingAnimation(); if ($("#sel-room").val() == "") {
document.getElementById('hrSelForm').submit(); alert("請選擇年級 / 班級!");
return;
}
var url = "/manage/admin/" + $('#sel-grade').val() + "/" + $('#sel-room').val() + "/" + $('#date').val();
var new_form = document.createElement('form');
new_form.method = 'GET';
new_form.action = url;
document.body.appendChild(new_form);
new_form.submit();
$('.container').hide();
$('#loading').show();
} }
</script> </script>
<script src="/static/time.js"></script> <script src="/static/time.js"></script>

View file

@ -30,8 +30,7 @@
<h2>[{{currDate}}]</h2> <h2>[{{currDate}}]</h2>
<a href="/logout"><button class="btn btn-primary margin-top logout">Logout 登出</button></a> <a href="/logout"><button class="btn btn-primary margin-top logout">Logout 登出</button></a>
<a href="/select"><button class="btn btn-primary margin-top logout">Choose Subuser 選擇其他帳號</button></a> <a href="/select"><button class="btn btn-primary margin-top logout">Choose Subuser 選擇其他帳號</button></a>
<form action="/manage/date" id="dateSelForm" method="post"> <select name="date" id="date" class="form-select logout" onchange="chgDate();">
<select name="date" id="date" class="form-select logout" onchange="chgDate(this);">
{% for date in tmpAbsData %} {% for date in tmpAbsData %}
{% if date == currDate %} {% if date == currDate %}
<option value="{{date}}" selected="selected">{{date}}</option> <option value="{{date}}" selected="selected">{{date}}</option>
@ -40,7 +39,6 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</select> </select>
</form>
{% for i in absData %} {% for i in absData %}
{% set alr_fill = namespace(found=false) %} {% set alr_fill = namespace(found=false) %}
<form action="/manage/group_teach_publish" id="attendanceData^{{i}}" method="post"> <form action="/manage/group_teach_publish" id="attendanceData^{{i}}" method="post">
@ -202,7 +200,12 @@
} }
function chgDate(sel) { function chgDate(sel) {
loadingAnimation(); loadingAnimation();
document.getElementById('dateSelForm').submit(); var url = '/manage/date/' + $('#date').val()
var new_form = document.createElement('form');
new_form.method = 'GET';
new_form.action = url;
document.body.appendChild(new_form);
new_form.submit();
} }
</script> </script>
<script src="/static/time.js"></script> <script src="/static/time.js"></script>

View file

@ -31,7 +31,6 @@
<h2>[{{currDate}}]</h2> <h2>[{{currDate}}]</h2>
<a href="/logout"><button class="btn btn-primary logout margin-top">Logout 登出</button></a> <a href="/logout"><button class="btn btn-primary logout margin-top">Logout 登出</button></a>
<a href="/select"><button class="btn btn-primary margin-top logout">Choose Subuser 選擇其他帳號</button></a> <a href="/select"><button class="btn btn-primary margin-top logout">Choose Subuser 選擇其他帳號</button></a>
<form action="/manage/date" id="dateSelForm" method="post">
<select name="date" id="date" class="form-select logout" onchange="chgDate();"> <select name="date" id="date" class="form-select logout" onchange="chgDate();">
{% for date in absData %} {% for date in absData %}
{% if date == currDate %} {% if date == currDate %}
@ -41,7 +40,6 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</select> </select>
</form>
<form action="/manage/homeroom_confirm" id="homeroom_confirm" method="post"> <form action="/manage/homeroom_confirm" id="homeroom_confirm" method="post">
<input type="hidden" name="date" value="{{currDate}}"> <input type="hidden" name="date" value="{{currDate}}">
<input type="hidden" name="homeroom" value="{{homeroomCode[0]}}^{{homeroomCode[1]}}"> <input type="hidden" name="homeroom" value="{{homeroomCode[0]}}^{{homeroomCode[1]}}">
@ -241,7 +239,12 @@
} }
function chgDate() { function chgDate() {
loadingAnimation(); loadingAnimation();
document.getElementById('dateSelForm').submit(); var url = '/manage/date/' + $('#date').val()
var new_form = document.createElement('form');
new_form.method = 'GET';
new_form.action = url;
document.body.appendChild(new_form);
new_form.submit();
} }
function submitForm() { function submitForm() {
if (!signaturePad.isEmpty()) { if (!signaturePad.isEmpty()) {