From 56957fdbdb5da1da817e93b61f6c0da98678402a Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Fri, 15 Oct 2021 20:32:24 +0800 Subject: [PATCH] Change POST format --- app.py | 6 +++ manage.py | 14 +++--- templates/admin.html | 99 +++++++++++++++++++++----------------- templates/group_teach.html | 27 ++++++----- templates/homeroom.html | 27 ++++++----- 5 files changed, 97 insertions(+), 76 deletions(-) diff --git a/app.py b/app.py index 78b72dd..6734e98 100644 --- a/app.py +++ b/app.py @@ -9,6 +9,12 @@ app.register_blueprint(upload) 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']) def index(): if request.method == 'GET': diff --git a/manage.py b/manage.py index b1bece1..af25a95 100644 --- a/manage.py +++ b/manage.py @@ -187,16 +187,16 @@ def manageRoot(): return manageProcess("", "") -@manage.route('/manage/date', methods=['POST']) -def manage_date(): - return manageProcess("date", request.form['date']) +@manage.route('/manage/date/', methods=['GET']) +def manage_date(date): + return manageProcess("date", date) -@manage.route('/manage/admin', methods=['POST']) -def manage_admin(): +@manage.route('/manage/admin///', methods=['GET']) +def manage_admin(g, r, date): data = [ - request.form['grade'] + '^' + request.form['room'], - request.form['date'] + g + '^' + r, + date ] return manageProcess("admin", data) diff --git a/templates/admin.html b/templates/admin.html index 4fff365..f3ddb41 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -34,38 +34,43 @@

Homeroom NOT Confirmed 班導尚未確認

{% endif %} + +
-
-
-
- -
-
- -
-
- -
-
- -
+
+
+
- +
+ +
+
+ +
+
+ +
+
@@ -84,7 +89,11 @@
{% for i in periods %} -
{{absData[currDate][i]['name']}}
+
{{absData[currDate][i]['name']}} + {% if 'changed' in absData[currDate][i] %} + (換) + {% endif %} +
{% endfor %}
@@ -102,7 +111,7 @@
{{homeroomCode[0]}}{{homeroomCode[1]}}
{{i}}
-
{{ homeroomData[i]['name'] }}
+
{{ homeroomData[i]['name'] }}
{{ homeroomData[i]['eng_name'] }}
{% for j in periods %}
@@ -222,16 +231,6 @@ homerooms['{{i}}'].push({{ j }}); {% endfor %} {% endfor %} - console.log(homerooms) - function loadingAnimation() { - if ($("#sel-room").val() == "") { - alert("請選擇年級 / 班級!"); - return; - } - document.getElementById('adminSelForm').submit(); - $('.container').hide(); - $('#loading').show(); - } function getHR() { var grade = $('#sel-grade').val(); $('#sel-room').html(''); @@ -244,9 +243,19 @@ }); $('#sel-room').removeAttr('disabled') } - function submitQuery() { - loadingAnimation(); - document.getElementById('hrSelForm').submit(); + function redirAdmin() { + if ($("#sel-room").val() == "") { + 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(); } diff --git a/templates/group_teach.html b/templates/group_teach.html index 1c8919e..d83f979 100644 --- a/templates/group_teach.html +++ b/templates/group_teach.html @@ -30,17 +30,15 @@

[{{currDate}}]

-
- -
+ {% for i in absData %} {% set alr_fill = namespace(found=false) %}
@@ -202,7 +200,12 @@ } function chgDate(sel) { 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(); } diff --git a/templates/homeroom.html b/templates/homeroom.html index 2a43805..c5d6034 100644 --- a/templates/homeroom.html +++ b/templates/homeroom.html @@ -31,17 +31,15 @@

[{{currDate}}]

- - -
+
@@ -239,7 +237,12 @@ } function chgDate() { 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() { if (!signaturePad.isEmpty()) {