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

fix: fix issue with deleted students appearing #1256

Merged
merged 1 commit into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions game/views/level_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ def get(self, request, **kwargs):

# First get all the student's classmates
class_ = student.class_field
classmates = Student.objects.filter(class_field=class_).exclude(
id=student.id
)
classmates = Student.objects.filter(
class_field=class_, new_user__is_active=True
).exclude(id=student.id)
valid_recipients["classmates"] = [
{
"id": classmate.user.user.id,
Expand All @@ -344,7 +344,9 @@ def get(self, request, **kwargs):
valid_recipients["classes"] = []
classes_taught = Class.objects.filter(teacher=teacher)
for class_ in classes_taught:
students = Student.objects.filter(class_field=class_)
students = Student.objects.filter(
class_field=class_, new_user__is_active=True
)
valid_recipients["classes"].append(
{
"name": class_.name,
Expand Down
4 changes: 2 additions & 2 deletions game/views/level_moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def level_moderation(request):
messages.noPermissionLevelModerationClass(),
)

students = Student.objects.filter(class_field=cl)
students = Student.objects.filter(class_field=cl, new_user__is_active=True)
student_dict = {
student.id: student.user.user.first_name for student in students
}
Expand Down Expand Up @@ -152,7 +152,7 @@ def get_students_for_level_moderation(request, class_id):
if userprofile.teacher != class_.teacher:
raise Http404

students = Student.objects.filter(class_field=class_)
students = Student.objects.filter(class_field=class_, new_user__is_active=True)
student_dict = {student.id: student.user.user.first_name for student in students}

return HttpResponse(json.dumps(student_dict), content_type="application/javascript")
10 changes: 6 additions & 4 deletions game/views/scoreboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ def authorised_student_access(class_, class_ids):
def students_visible_to_student(student):
class_ = student.class_field
if is_viewable(class_):
return class_.students.all().select_related("class_field", "user__user")
return class_.students.filter(new_user__is_active=True).select_related(
"class_field", "user__user"
)
else:
return [student]

Expand All @@ -205,9 +207,9 @@ def students_visible_to_user(user, classes):


def students_of_classes(classes):
return Student.objects.filter(class_field__in=classes).select_related(
"class_field", "user__user"
)
return Student.objects.filter(
class_field__in=classes, new_user__is_active=True
).select_related("class_field", "user__user")


def is_valid_request(user, class_ids):
Expand Down