Done with upload format

This commit is contained in:
Aaron Lee 2021-09-14 22:55:11 +08:00
parent 419a71be2b
commit 745b43dff3
5 changed files with 278 additions and 212 deletions

390
app.py
View file

@ -41,6 +41,10 @@ def check_login_status():
(datetime.now(tz) - session['loginTime']).total_seconds() > 3600) (datetime.now(tz) - session['loginTime']).total_seconds() > 3600)
def check_permission():
return db.child('Users').child(session['uid']).child('permission').get().val() == 'admin'
def manageProcess(fCommand, fData): def manageProcess(fCommand, fData):
if (check_login_status()): if (check_login_status()):
return redirect('/logout') return redirect('/logout')
@ -65,7 +69,8 @@ def manageProcess(fCommand, fData):
homeroomData = homerooms[currRoom[0]][currRoom[1]] homeroomData = homerooms[currRoom[0]][currRoom[1]]
absData = homeroomData["Absent"] absData = homeroomData["Absent"]
homeroomData.pop('Absent') homeroomData.pop('Absent')
homeroomData.pop('placeholder') if 'placeholder' in homeroomData:
homeroomData.pop('placeholder')
currDate = "" currDate = ""
if fCommand != "": if fCommand != "":
currDate = fData[1] currDate = fData[1]
@ -85,8 +90,6 @@ def manageProcess(fCommand, fData):
"GP_Class").child(i).get().val() "GP_Class").child(i).get().val()
cclass = { cclass = {
"name": cateData['Class'][classes[i]]['name'], "name": cateData['Class'][classes[i]]['name'],
"teacher": cateData['Class'][classes[i]]['teacher'],
"classroom": cateData['Class'][classes[i]]['classroom'],
"category": i, "category": i,
"class_id": classes[i] "class_id": classes[i]
} }
@ -100,7 +103,8 @@ def manageProcess(fCommand, fData):
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')
hrData.pop('placeholder') if 'placeholder' in hrData:
hrData.pop('placeholder')
periods = [] periods = []
dow = "" dow = ""
if currDate == "": if currDate == "":
@ -196,7 +200,8 @@ def manageProcess(fCommand, fData):
break break
absData = homeroomData["Absent"] absData = homeroomData["Absent"]
homeroomData.pop('Absent') homeroomData.pop('Absent')
homeroomData.pop('placeholder') if 'placeholder' in homeroomData:
homeroomData.pop('placeholder')
currDate = "" currDate = ""
if fCommand == 'date': if fCommand == 'date':
currDate = fData currDate = fData
@ -221,7 +226,7 @@ def index():
if check_login_status(): if check_login_status():
try: try:
user = auth.sign_in_with_email_and_password( user = auth.sign_in_with_email_and_password(
request.form['username'] + "@group-attendence.fhjh.tp.edu.tw", request.form['password']) request.form['username'] + "@group-attendance.fhjh.tp.edu.tw", request.form['password'])
session['is_logged_in'] = True session['is_logged_in'] = True
session['email'] = user['email'] session['email'] = user['email']
session['uid'] = user['localId'] session['uid'] = user['localId']
@ -297,15 +302,16 @@ def group_teach_publish():
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(
"Absent").child(date).child(period).child("signature").update({cclass['class_id']: str(storage.child(os.path.join('signatures', rand)).get_url(None))}) "Absent").child(date).child(period).child("signature").update({cclass['class_id']: str(storage.child(os.path.join('signatures', rand)).get_url(None))})
currPeriodData = db.child("Homerooms").child(h[0]).child(h[1]).child(
"Absent").child(date).child(period).get().val()
if 'notes' in currPeriodData:
db.child("Homerooms").child(h[0]).child(h[1]).child(
"Absent").child(date).child(period).update({'notes': currPeriodData['notes']+'; '+notes})
else:
db.child("Homerooms").child(h[0]).child(h[1]).child(
"Absent").child(date).child(period).update({'notes': notes})
# upload notes # upload notes
currPeriodData = db.child("Homerooms").child(h[0]).child(h[1]).child(
"Absent").child(date).child(period).get().val()
if 'notes' in currPeriodData:
db.child("Homerooms").child(h[0]).child(h[1]).child(
"Absent").child(date).child(period).update({'notes': currPeriodData['notes']+'; '+notes})
else:
db.child("Homerooms").child(h[0]).child(h[1]).child(
"Absent").child(date).child(period).update({'notes': notes})
os.remove(os.path.join('temp', rand)) os.remove(os.path.join('temp', rand))
return redirect('/manage') return redirect('/manage')
@ -368,168 +374,218 @@ def homeroom_confirm():
return redirect('/manage') return redirect('/manage')
@ app.route('/upload/homeroom', methods=['GET', 'POST']) @ app.route('/upload/1', methods=['GET', 'POST'])
def upload_homeroom(): def upload_homeroom():
if request.method == 'GET': if ((not check_login_status()) and check_permission()):
return render_template('uploadcsv.html', title="Homeroom List", url="/upload/homeroom") if request.method == 'GET':
elif request.method == 'POST': return render_template('uploadcsv.html', title="Homeroom List", url="/upload/1")
try: elif request.method == 'POST':
# get csv try:
gradec = request.form['gradeCode'] # get csv
classc = request.form['classcode'] gradec = request.form['gradeCode']
csv_file = request.files['csv'] classc = request.form['classcode']
filepath = os.path.join('./temp', csv_file.filename) csv_file = request.files['csv']
csv_file.save(filepath) filepath = os.path.join('./temp', csv_file.filename)
with open(filepath) as file: csv_file.save(filepath)
csv_dict = csv.DictReader(file) with open(filepath) as file:
for row in csv_dict: csv_dict = csv.DictReader(file)
db.child("Homerooms").child(gradec).child( for row in csv_dict:
classc).child(row['number']).set(row) if row['number'] == 'password':
# row['class'] row['number'] row['name'] row['eng_name'] auth.create_user_with_email_and_password(
os.remove(filepath) gradec + '^' + classc + "@group-attendance.fhjh.tp.edu.tw", row['name'])
except Exception as e: user = auth.sign_in_with_email_and_password(
os.remove(filepath) gradec + '^' + classc + "@group-attendance.fhjh.tp.edu.tw", row['name'])
return "Error. Please try again\n("+str(e)+")" db.child("Users").child(user['localId']).update({
return "Successfully uploaded " + gradec + "-" + classc "permission": 'homeroom',
"username": gradec + '^' + classc,
"homeroom": gradec + '^' + classc
@ app.route('/upload/gp_classes', methods=['GET', 'POST']) })
def upload_gp_classes():
if request.method == 'GET':
return render_template('uploadcsv.html', title="Group Classes", url="/upload/gp_classes")
elif request.method == 'POST':
try:
csv_file = request.files['csv']
filepath = os.path.join('./temp', csv_file.filename)
csv_file.save(filepath)
csv_dict = pd.read_csv(filepath)
category_cnt = csv_dict.shape[1] - 1
for i in range(category_cnt):
tmp_csv = csv_dict[csv_dict.columns[i+1]].tolist()
for j in range(len(tmp_csv)):
if type(tmp_csv[j]) == float:
break
if j % 4 == 0:
db.child("Classes").child("GP_Class").child(csv_dict.columns[i+1]).child("Class").child(
tmp_csv[j]).child("name").set(tmp_csv[j+1])
db.child("Classes").child("GP_Class").child(csv_dict.columns[i+1]).child("Class").child(
tmp_csv[j]).child("teacher").set(tmp_csv[j+2])
db.child("Classes").child("GP_Class").child(csv_dict.columns[i+1]).child("Class").child(
tmp_csv[j]).child("classroom").set(tmp_csv[j+3])
os.remove(filepath)
except Exception as e:
os.remove(filepath)
return "Error. Please try again\n("+str(e)+")"
return "Successfully uploaded"
@ app.route('/upload/stud_in_group', methods=['GET', 'POST'])
def upload_stud_in_group():
if request.method == 'GET':
return render_template('uploadcsv.html', title="Student in Group List", url="/upload/stud_in_group")
elif request.method == 'POST':
try:
gradec = request.form['gradeCode']
classc = request.form['classcode']
csv_file = request.files['csv']
filepath = os.path.join('./temp', csv_file.filename)
csv_file.save(filepath)
with open(filepath) as file:
csv_dict = csv.DictReader(file)
headers = csv_dict.fieldnames
headers = headers[1:]
for h in headers:
db.child("Classes").child("GP_Class").child(
h).child("Homerooms").update({gradec+'^'+classc: 0})
for row in csv_dict:
for h in headers:
db.child("Homerooms").child(gradec).child(classc).child(
row['number']).child("GP_Class").update({h: row[h]})
os.remove(filepath)
except Exception as e:
os.remove(filepath)
return "Error. Please try again\n("+str(e)+")"
return "Successfully uploaded " + gradec + "-" + classc
@ app.route('/upload/period_list', methods=['GET', 'POST'])
def upload_period_list():
if request.method == 'GET':
return render_template('uploadcsv.html', title="Period List", url="/upload/period_list")
elif request.method == 'POST':
try:
# get csv
gradec = request.form['gradeCode']
classc = request.form['classcode']
csv_file = request.files['csv']
filepath = os.path.join('./temp', csv_file.filename)
csv_file.save(filepath)
csv_dict = pd.read_csv(filepath)
periodCodes = csv_dict['Period Day'].tolist()
for i in range(5):
tmp_csv = csv_dict[str(i+1)].tolist()
for j in range(len(tmp_csv)):
if not (periodCodes[j].endswith('-t')):
if type(tmp_csv[j]) == float:
db.child("Classes").child("Homeroom").child(gradec).child(classc).child(
str(i+1)).child(periodCodes[j]).update({'name': '--'})
else: else:
db.child("Classes").child("Homeroom").child(gradec).child(classc).child( db.child("Homerooms").child(gradec).child(
str(i+1)).child(periodCodes[j]).update({'name': tmp_csv[j]}) classc).child(row['number']).set(row)
if not(periodCodes[j] == 'm' or periodCodes[j] == 'n'): # row['class'] row['number'] row['name'] row['eng_name']
j += 1 os.remove(filepath)
except Exception as e:
os.remove(filepath)
return "Error. Please try again\n("+str(e)+")"
return "Successfully uploaded " + gradec + "-" + classc
else:
return redirect('/logout')
@ app.route('/upload/2', methods=['GET', 'POST'])
def upload_gp_classes():
if ((not check_login_status()) and check_permission()):
if request.method == 'GET':
return render_template('uploadcsv.html', title="Group Classes", url="/upload/2")
elif request.method == 'POST':
try:
csv_file = request.files['csv']
filepath = os.path.join('./temp', csv_file.filename)
csv_file.save(filepath)
csv_dict = pd.read_csv(filepath)
category_cnt = csv_dict.shape[1] - 1
for i in range(category_cnt):
tmp_csv = csv_dict[csv_dict.columns[i+1]].tolist()
for j in range(len(tmp_csv)):
if type(tmp_csv[j]) == float:
break
if j % 5 == 0:
db.child("Classes").child("GP_Class").child(csv_dict.columns[i+1]).child("Class").child(
tmp_csv[j]).child("name").set(tmp_csv[j+1] + " : " + tmp_csv[j+2] + " (" + tmp_csv[j+3] + ")")
auth.create_user_with_email_and_password(
csv_dict.columns[i+1] + "^" + tmp_csv[j] + "@group-attendance.fhjh.tp.edu.tw", tmp_csv[j+4])
user = auth.sign_in_with_email_and_password(
csv_dict.columns[i+1] + "^" + tmp_csv[j] + "@group-attendance.fhjh.tp.edu.tw", tmp_csv[j+4])
db.child("Users").child(user['localId']).update({
"permission": 'group',
"username": csv_dict.columns[i+1] + "^" + tmp_csv[j],
"class": {
csv_dict.columns[i+1]: tmp_csv[j],
}
})
os.remove(filepath)
except Exception as e:
os.remove(filepath)
return "Error. Please try again\n("+str(e)+")"
return "Successfully uploaded"
else:
return redirect('/logout')
@ app.route('/upload/3', methods=['GET', 'POST'])
def upload_stud_in_group():
if ((not check_login_status()) and check_permission()):
if request.method == 'GET':
return render_template('uploadcsv.html', title="Student in Group List", url="/upload/3")
elif request.method == 'POST':
try:
gradec = request.form['gradeCode']
classc = request.form['classcode']
csv_file = request.files['csv']
filepath = os.path.join('./temp', csv_file.filename)
csv_file.save(filepath)
with open(filepath) as file:
csv_dict = csv.DictReader(file)
headers = csv_dict.fieldnames
headers = headers[1:]
for h in headers:
db.child("Classes").child("GP_Class").child(
h).child("Homerooms").update({gradec+'^'+classc: 0})
for row in csv_dict:
for h in headers:
db.child("Homerooms").child(gradec).child(classc).child(
row['number']).child("GP_Class").update({h: row[h]})
os.remove(filepath)
except Exception as e:
os.remove(filepath)
return "Error. Please try again\n("+str(e)+")"
return "Successfully uploaded " + gradec + "-" + classc
else:
return redirect('/logout')
@ app.route('/upload/4', methods=['GET', 'POST'])
def upload_period_list():
if ((not check_login_status()) and check_permission()):
if request.method == 'GET':
return render_template('uploadcsv.html', title="Period List", url="/upload/4")
elif request.method == 'POST':
try:
# get csv
gradec = request.form['gradeCode']
classc = request.form['classcode']
csv_file = request.files['csv']
filepath = os.path.join('./temp', csv_file.filename)
csv_file.save(filepath)
csv_dict = pd.read_csv(filepath)
periodCodes = csv_dict['Period Day'].tolist()
for i in range(5):
tmp_csv = csv_dict[str(i+1)].tolist()
for j in range(len(tmp_csv)):
if not (periodCodes[j].endswith('-t')):
if type(tmp_csv[j]) == float:
db.child("Classes").child("Homeroom").child(gradec).child(classc).child( db.child("Classes").child("Homeroom").child(gradec).child(classc).child(
str(i+1)).child(periodCodes[j-1]).update({'teacher': tmp_csv[j]}) str(i+1)).child(periodCodes[j]).update({'name': '--'})
os.remove(filepath) else:
except Exception as e: db.child("Classes").child("Homeroom").child(gradec).child(classc).child(
os.remove(filepath) str(i+1)).child(periodCodes[j]).update({'name': tmp_csv[j]})
return "Error. Please try again\n("+str(e)+")" if not(periodCodes[j] == 'm' or periodCodes[j] == 'n'):
return "Successfully uploaded " + gradec + "-" + classc j += 1
db.child("Classes").child("Homeroom").child(gradec).child(classc).child(
str(i+1)).child(periodCodes[j-1]).update({'teacher': tmp_csv[j]})
os.remove(filepath)
except Exception as e:
os.remove(filepath)
return "Error. Please try again\n("+str(e)+")"
return "Successfully uploaded " + gradec + "-" + classc
else:
return redirect('/logout')
@ app.route('/upload/dates', methods=['GET', 'POST']) @ app.route('/upload/dates', methods=['GET', 'POST'])
def upload_dates(): def upload_dates():
if request.method == 'GET': if ((not check_login_status()) and check_permission()):
return render_template('uploadcsv.html', title="School Days", url="/upload/dates") if request.method == 'GET':
elif request.method == 'POST': return render_template('uploadcsv.html', title="School Days", url="/upload/dates")
try: elif request.method == 'POST':
csv_file = request.files['csv'] try:
filepath = os.path.join('./temp', csv_file.filename) csv_file = request.files['csv']
csv_file.save(filepath) filepath = os.path.join('./temp', csv_file.filename)
with open(filepath) as file: csv_file.save(filepath)
csv_dict = csv.DictReader(file) with open(filepath) as file:
headers = csv_dict.fieldnames csv_dict = csv.DictReader(file)
temp = db.child("Homerooms").get().val() headers = csv_dict.fieldnames
for row in csv_dict: temp = db.child("Homerooms").get().val()
for h in headers: for row in csv_dict:
for t in temp: for h in headers:
for i in temp[t]: for t in temp:
periodData = db.child("Classes").child( for i in temp[t]:
"Homeroom").child(t).child(i).get().val() periodData = db.child("Classes").child(
db.child("Homerooms").child(t).child(i).child( "Homeroom").child(t).child(i).get().val()
"Absent").child(h).update({"dow": row[h]}) 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( db.child("Homerooms").child(t).child(i).child(
periodData[int(row[h])] "Absent").child(h).update(
) periodData[int(row[h])]
os.remove(filepath) )
except Exception as e: os.remove(filepath)
os.remove(filepath) except Exception as e:
return "Error. Please try again\n("+str(e)+")" os.remove(filepath)
return "Successfully uploaded dates" return "Error. Please try again\n("+str(e)+")"
return "Successfully uploaded dates"
else:
return redirect('/logout')
# @ app.route('/upload/rm_all_data_of_class', methods=['GET', "POST"]) @app.route('/upload/admin_acc', methods=['GET', 'POST'])
# def rm_all_data_of_class(): def upload_admin_acc():
# if request.method == 'GET': if ((not check_login_status()) and check_permission()):
# return render_template('uploadcsv.html', title="Remove all data of class", url="/upload/rm_all_data_of_class") if request.method == 'GET':
# elif request.method == 'POST': return render_template('uploadcsv.html', title="Admin Accounts", url="/upload/admin_acc")
# try: elif request.method == 'POST':
# classc = request.form['classcode'] try:
# db.child("Homerooms").child(classc).remove() csv_file = request.files['csv']
# except Exception as e: filepath = os.path.join('./temp', csv_file.filename)
# return "Error. Please try again\n("+str(e)+")" csv_file.save(filepath)
# return "Successfully removed " + classc with open(filepath) as file:
csv_dict = csv.DictReader(file)
for row in csv_dict:
auth.create_user_with_email_and_password(
row['username'] + '@group-attendance.fhjh.tp.edu.tw', row['password'])
user = auth.sign_in_with_email_and_password(
row['username'] + '@group-attendance.fhjh.tp.edu.tw', row['password'])
db.child("Users").child(user['localId']).update({
'permission': 'admin',
'username': row['username']
})
os.remove(filepath)
except Exception as e:
os.remove(filepath)
return "Error. Please try again\n("+str(e)+")"
return "Successfully uploaded admin accounts"
else:
return redirect('/logout')
@ app.route('/logout', methods=['GET']) @ app.route('/logout', methods=['GET'])

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View file

@ -52,40 +52,42 @@
</form> </form>
</div> </div>
<div class="col"> <div class="col">
<div class="row title"> <div class="sticky-top" style="background-color: white;">
<div class="col">HR</div> <div class="row title">
<div class="col">Number</div> <div class="col">HR</div>
<div class="col">Name</div> <div class="col">Number</div>
<div class="col">Eng Name</div> <div class="col">Name</div>
<div class="col">Morning</div> <div class="col">Eng Name</div>
<div class="col">1</div> <div class="col">Morning</div>
<div class="col">2</div> <div class="col">1</div>
<div class="col">3</div> <div class="col">2</div>
<div class="col">4</div> <div class="col">3</div>
<div class="col">Nap</div> <div class="col">4</div>
<div class="col">5</div> <div class="col">Nap</div>
<div class="col">6</div> <div class="col">5</div>
<div class="col">7</div> <div class="col">6</div>
<div class="col">8</div> <div class="col">7</div>
<div class="col">9</div> <div class="col">8</div>
</div> <div class="col">9</div>
<div class="row title"> </div>
<div class="col"></div> <div class="row title">
<div class="col"></div> <div class="col"></div>
<div class="col"></div> <div class="col"></div>
<div class="col"></div> <div class="col"></div>
{% for i in periods %} <div class="col"></div>
<div class="col">{{absData[currDate][i]['name']}}</div> {% for i in periods %}
{% endfor %} <div class="col">{{absData[currDate][i]['name']}}</div>
</div> {% endfor %}
<div class="row title"> </div>
<div class="col"></div> <div class="row title">
<div class="col"></div> <div class="col"></div>
<div class="col"></div> <div class="col"></div>
<div class="col"></div> <div class="col"></div>
{% for i in periods %} <div class="col"></div>
<div class="col">{{absData[currDate][i]['teacher']}}</div> {% for i in periods %}
{% endfor %} <div class="col">{{absData[currDate][i]['teacher']}}</div>
{% endfor %}
</div>
</div> </div>
{% if data != None %} {% if data != None %}
{% for i in homeroomData %} {% for i in homeroomData %}
@ -128,7 +130,7 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% for c in range(periods|length + 1) %} {% for c in range(periods|length + 1) %}
{% if c % 2 == 0 %} {% if c % 4 == 0 %}
<div class="row signatures"> <div class="row signatures">
{% endif %} {% endif %}
<div class="col half"> <div class="col half">
@ -140,7 +142,8 @@
{% if 'signature' in absData[currDate][periods[c-1]] %} {% if 'signature' in absData[currDate][periods[c-1]] %}
{% for i in absData[currDate][periods[c-1]]['signature'] %} {% for i in absData[currDate][periods[c-1]]['signature'] %}
<div class="row">{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['teacher']}}: {{i}}</div> <div class="row">{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['teacher']}}: {{i}}</div>
<div class="row"><img src="{{absData[currDate][periods[c-1]]['signature'][i]}}" alt=""></div> <div class="row"><img src="{{absData[currDate][periods[c-1]]['signature'][i]}}" alt=""><br>備註:
{{absData[currDate][periods[c-1]]['notes']}}</div>
{% endfor %} {% endfor %}
{% else %} {% else %}
<div class="row">{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['teacher']}}: No Signature <div class="row">{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['teacher']}}: No Signature
@ -151,11 +154,12 @@
<div class="row">{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['name']}}: <div class="row">{{periods[c-1]}}: {{absData[currDate][periods[c-1]]['name']}}:
{{absData[currDate][periods[c-1]]['teacher']}} {{absData[currDate][periods[c-1]]['teacher']}}
</div> </div>
<div class="row"><img src="{{absData[currDate][periods[c-1]]['signature']}}" alt=""></div> <div class="row"><img src="{{absData[currDate][periods[c-1]]['signature']}}"
alt=""><br>備註:{{absData[currDate][periods[c-1]]['notes']}}</div>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
{% if c % 2 == 1 %} {% if c % 4 == 3 %}
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View file

@ -5,7 +5,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Homeroom_View</title> <title>Attendance | Homeroom</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous"> integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
<link rel="stylesheet" href="/static/allpages.css"> <link rel="stylesheet" href="/static/allpages.css">
@ -14,9 +14,9 @@
<body> <body>
<div class="container"> <div class="container">
<h1>Homeroom_View</h1> <h1>Attendance | Homeroom</h1>
<h2>{{homeroomCode[0]}}: {{homeroomCode[1]}}</h2> <h2>{{homeroomCode[0]}}: {{homeroomCode[1]}}</h2>
<h2>Status: ({{currDate}}, 星期{{absData[currDate]['dow']}})</h2> <h2>{{currDate}}, 依照 星期{{absData[currDate]['dow']}} 課表</h2>
<a href="/logout"><button class="btn btn-primary">Logout 登出</button></a> <a href="/logout"><button class="btn btn-primary">Logout 登出</button></a>
<form action="/manage/date" id="dateSelForm" method="post"> <form action="/manage/date" id="dateSelForm" method="post">
<select name="date" id="date" class="form-select" onchange="chgDate();"> <select name="date" id="date" class="form-select" onchange="chgDate();">
@ -137,10 +137,10 @@
</form> </form>
{% if 'confirm' in absData[currDate] %} {% if 'confirm' in absData[currDate] %}
<button class="btn btn-primary margin-top afterSelButton" onclick="homeroomCfrm()" disabled="disabled"> <button class="btn btn-primary margin-top afterSelButton" onclick="homeroomCfrm()" disabled="disabled">
Already Confirmed</button> Homeroom Teacher Already Confirmed | 班導已確認</button>
{% else %} {% else %}
<button class="btn btn-primary margin-top afterSelButton" onclick="homeroomCfrm()">Homeroom <button class="btn btn-primary margin-top afterSelButton" onclick="homeroomCfrm()">Homeroom
Teacher Confirm</button> Teacher Confirm | 班導已確認</button>
{% endif %} {% endif %}
<div id="finalCheck" hidden="hidden"> <div id="finalCheck" hidden="hidden">
<!-- show warning --> <!-- show warning -->

View file

@ -18,7 +18,7 @@
<div class="col-md-4 offset-md-4"> <div class="col-md-4 offset-md-4">
<h1 class="text-center">Upload {{title}}</h1> <h1 class="text-center">Upload {{title}}</h1>
<!-- upload csv --> <!-- upload csv -->
<form action="{{url}}" method="post" enctype="multipart/form-data"> <form action="{{url}}" id="uploadCsvForm" method="post" enctype="multipart/form-data">
<!-- input class code --> <!-- input class code -->
<div class="form-group"> <div class="form-group">
<label for="gradeCode">Grade Code</label> <label for="gradeCode">Grade Code</label>
@ -34,7 +34,7 @@
<label for="csv">{{title}}</label> <label for="csv">{{title}}</label>
<input type="file" class="form-control-file" id="csv" name="csv"> <input type="file" class="form-control-file" id="csv" name="csv">
</div> </div>
<button onclick="loadingAnimation()" type="submit" class="btn btn-primary">Upload</button> <button onclick="loadingAnimation()" type="button" class="btn btn-primary">Upload</button>
</form> </form>
<!-- show danger zone --> <!-- show danger zone -->
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
@ -61,6 +61,12 @@
<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() {
// if csv is empty
if ($("#csv").val() == "") {
alert("Please select a file!");
return;
}
$('#uploadCsvForm').submit();
$('.container').hide(); $('.container').hide();
$('#loading').show(); $('#loading').show();
} }