-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathminor.py
More file actions
60 lines (46 loc) · 2.56 KB
/
minor.py
File metadata and controls
60 lines (46 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from flask import render_template, g, abort, request, redirect, url_for, send_file, jsonify
from app.logic.minor import getMinorProgress
from app.models.user import User
from app.controllers.admin import admin_bp
from app.logic.minor import getMinorInterest, getMinorProgress, toggleMinorInterest, getMinorSpreadsheet, getDeclaredMinorStudents
@admin_bp.route('/profile/<username>/cceMinorChart', methods=['GET'])
def cceMinorChart(username):
if not g.current_user.isAdmin:
abort(403)
else:
progressList = getMinorProgress()
turnToChart = []
for progress in progressList:
turnToChart.append({'name':progress["firstName"] + " " + progress["lastName"], "engagementCount" : progress['engagementCount'], "completeSummer": "Yes" if progress['hasSummer'] == "Completed" else "No", "termDescription": progress['engagementTerm']})
return jsonify(turnToChart)
@admin_bp.route('/admin/cceMinor', methods=['GET','POST'])
def manageMinor():
if not g.current_user.isAdmin:
abort(403)
if request.method == 'POST':
interestedStudents = request.form.getlist('interestedStudents[]')
for student in interestedStudents:
user = User.get(username=student)
if not user.minorInterest:
toggleMinorInterest(student, True)
return redirect(url_for("admin.manageMinor"))
interestedStudentsList = getMinorInterest()
interestedStudentEmailString = ';'.join([student['email'] for student in interestedStudentsList])
sustainedEngagement = getMinorProgress()
declaredStudentsList = getDeclaredMinorStudents()
declaredStudentEmailString = ';'.join([student['email'] for student in declaredStudentsList])
adminUsername = g.current_user.username
return render_template('/admin/cceMinor.html',
interestedStudentsList = interestedStudentsList,
declaredStudentsList = declaredStudentsList,
interestedStudentEmailString = interestedStudentEmailString,
declaredStudentEmailString = declaredStudentEmailString,
sustainedEngagement = sustainedEngagement,
adminUsername = adminUsername,
)
@admin_bp.route("/admin/cceMinor/download")
def downloadSpreadsheet():
if not g.current_user.isCeltsAdmin:
abort(403)
newfile = getMinorSpreadsheet()
return send_file(open(newfile, 'rb'), download_name='minor_progress.xlsx', as_attachment=True)