Coverage for app/controllers/admin/minor.py: 33%

18 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-08-29 21:39 +0000

1from flask import render_template, g, abort, request, redirect, url_for 

2 

3from app.models.user import User 

4 

5from app.controllers.admin import admin_bp 

6 

7from app.logic.minor import getMinorInterest, getMinorProgress, toggleMinorInterest 

8 

9@admin_bp.route('/admin/cceMinor', methods=['POST','GET']) 

10def manageMinor(): 

11 

12 if not g.current_user.isAdmin: 

13 abort(403) 

14 

15 if request.method == 'POST': 

16 interested_students = request.form.getlist('interestedStudents[]') 

17 

18 for i in interested_students: 

19 user = User.get(username=i) 

20 if not user.minorInterest: 

21 toggleMinorInterest(i) 

22 

23 

24 interestedStudentsList = getMinorInterest() 

25 interestedStudentEmailString = ';'.join([student['email'] for student in interestedStudentsList]) 

26 sustainedEngagement = getMinorProgress() 

27 

28 

29 return render_template('/admin/cceMinor.html', 

30 interestedStudentsList = interestedStudentsList, 

31 interestedStudentEmailString = interestedStudentEmailString, 

32 sustainedEngagement = sustainedEngagement, 

33 ) 

34 

35 

36