Skip to content

Commit 77d1eb3

Browse files
Merge remote-tracking branch 'origin/feature/teacher' into feature/teacher
2 parents 81090c6 + 9f7a3ab commit 77d1eb3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

My_path_team9/teacher/routes.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ def dashboard():
1212
if current_user.role != 'teacher':
1313
return "Access denied", 403
1414

15+
"""
16+
Teacher dashboard view.
17+
18+
Displays all video submissions to the teacher.
19+
Only accessible to users with the 'teacher' role.
20+
"""
21+
1522
submissions = VideoSubmission.query.all()
1623
return render_template('teacher_dashboard.html', submissions=submissions)
1724

@@ -21,6 +28,14 @@ def dashboard():
2128
def approve_video(submission_id):
2229
if current_user.role != 'teacher':
2330
return "Access denied", 403
31+
"""
32+
Approves a specific video submission.
33+
34+
Sets the 'confirmed' flag to True and commits the change to the database.
35+
Only accessible to users with the 'teacher' role.
36+
37+
:param submission_id: ID of the video submission to approve
38+
"""
2439

2540
submission = VideoSubmission.query.get_or_404(submission_id)
2641
submission.confirmed = True
@@ -35,6 +50,15 @@ def reject_video(submission_id):
3550
if current_user.role != 'teacher':
3651
return "Access denied", 403
3752

53+
"""
54+
Rejects and deletes a specific video submission.
55+
56+
Deletes the submission from the database.
57+
Only accessible to users with the 'teacher' role.
58+
59+
:param submission_id: ID of the video submission to reject
60+
"""
61+
3862
submission = VideoSubmission.query.get_or_404(submission_id)
3963
db.session.delete(submission)
4064
db.session.commit()
@@ -47,6 +71,14 @@ def settings_teacher():
4771
if current_user.role != 'teacher':
4872
return "Access denied", 403
4973

74+
"""
75+
Allows a teacher to update their profile and optionally change their password.
76+
77+
Performs validation for username and email uniqueness,
78+
and validates the current password before allowing a password change.
79+
Only accessible to users with the 'teacher' role.
80+
"""
81+
5082
form = SettingsForm(obj=current_user)
5183

5284
if form.validate_on_submit():
@@ -85,6 +117,12 @@ def settings_teacher():
85117
@teacher_bp.route('/students', methods=['GET', 'POST'])
86118
@login_required
87119
def students_list():
120+
"""
121+
Displays a list of all student users and allows the teacher to create new student accounts.
122+
123+
On POST, processes the creation of a new student account after validating required fields.
124+
Only accessible to users with the 'teacher' role.
125+
"""
88126
if current_user.role != 'teacher':
89127
flash('You do not have access to this page.', 'danger')
90128
return redirect(url_for('main.home'))
@@ -118,6 +156,13 @@ def students_list():
118156
@teacher_bp.route('/students/delete/<int:user_id>', methods=['POST'])
119157
@login_required
120158
def delete_student(user_id):
159+
"""
160+
Deletes a student account based on the provided user ID.
161+
162+
Ensures only students can be deleted and that the current user has the 'teacher' role.
163+
164+
:param user_id: ID of the student user to delete
165+
"""
121166
if current_user.role != 'teacher':
122167
flash('You do not have permission to perform this action.', 'danger')
123168
return redirect(url_for('main.home'))

0 commit comments

Comments
 (0)