Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restricted permissions to the course management page #934

Merged
merged 6 commits into from
Jun 15, 2023
15 changes: 9 additions & 6 deletions app/controllers/serviceLearning/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@
@serviceLearning_bp.route('/serviceLearning/courseManagement', methods = ['GET'])
@serviceLearning_bp.route('/serviceLearning/courseManagement/<username>', methods = ['GET'])
def serviceCourseManagement(username=None):
if g.current_user.isStudent:
abort(403)
if g.current_user.isCeltsAdmin or g.current_user.isFaculty:
setRedirectTarget("/serviceLearning/courseManagement")
try:
user = User.get(User.username==username) if username else g.current_user
except DoesNotExist:
abort(404)

isRequestingForSelf = g.current_user == user
if g.current_user.isCeltsAdmin or (g.current_user.isFaculty and isRequestingForSelf):
setRedirectTarget("/serviceLearning/courseManagement")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of always coming back to /serviceLearning/courseManagement in setRedirectTarget, we should come back to the original route they came in on (including the username if necessary). Check out the flask request object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On it!

courseDict = getServiceLearningCoursesData(user)
termList = selectSurroundingTerms(g.current_term, prevTerms=0)
return render_template('serviceLearning/slcManagement.html',
user=user,
courseDict=courseDict,
termList=termList)
else:
flash("Unauthorized to view page", 'warning')
return redirect(url_for('main.events', selectedTerm=g.current_term))
abort(403)


@serviceLearning_bp.route('/serviceLearning/viewProposal/<courseID>', methods=['GET'])
@serviceLearning_bp.route('/serviceLearning/editProposal/upload/<courseID>', methods=['GET'])
Expand Down