diff --git a/game/views/level_editor.py b/game/views/level_editor.py index b7a92e54b..b45b21a5a 100644 --- a/game/views/level_editor.py +++ b/game/views/level_editor.py @@ -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, @@ -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, diff --git a/game/views/level_moderation.py b/game/views/level_moderation.py index 1fa6ef22e..9f7edade6 100644 --- a/game/views/level_moderation.py +++ b/game/views/level_moderation.py @@ -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 } @@ -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") diff --git a/game/views/scoreboard.py b/game/views/scoreboard.py index 045d95737..38f581446 100644 --- a/game/views/scoreboard.py +++ b/game/views/scoreboard.py @@ -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] @@ -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):