Skip to content

Commit

Permalink
Fix exception in Course Assignments list
Browse files Browse the repository at this point in the history
When the course has no faculty group, an exception is possible in this
method:
```
'NoneType' object has no attribute 'user_set'
```
  • Loading branch information
nikolas committed Oct 11, 2024
1 parent 7537ce7 commit 08f91e0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mediathread/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,16 @@ def visible_assignments_by_course(self, course, viewer):
their own draft assignments.
"""

users = []
if course.faculty_group:
users = course.faculty_group.user_set.all()

# Retrieve all assignments authored by course faculty
qs = Collaboration.objects.filter(
content_type__model='project',
project__project_type__in=PROJECT_TYPE_ASSIGNMENTS,
project__course=course,
user__in=course.faculty_group.user_set.all())
user__in=users)

# Get all published assignments or those authored by the viewer
qs = qs.filter(
Expand Down

0 comments on commit 08f91e0

Please sign in to comment.