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: students levels are not shared with anybody when the student is … #2376

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
18 changes: 18 additions & 0 deletions portal/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,24 @@ def test_release_verified_student(self):
assert response.status_code == 302

student = Student.objects.get(pk=self.student.pk)

assert student.user.is_verified

c.logout()
c.login(username=self.email, password=self.password)

teacher = Teacher.objects.factory("the", "teacher", "[email protected]", "password")
level = Level.objects.create()

level.owner = student.new_user.userprofile
level.shared_with.add(teacher.new_user)
level.save()

students_levels = Level.objects.filter(owner=student.new_user.userprofile).all()

for level in students_levels.all():
assert level.shared_with.exists()

release_url = reverse(
"teacher_dismiss_students", args=[self.class_access_code]
)
Expand All @@ -279,6 +292,11 @@ def test_release_verified_student(self):
student = Student.objects.get(pk=self.student.pk)
assert not student.user.is_verified

students_levels = Level.objects.filter(owner=student.new_user.userprofile).all()

for level in students_levels.all():
assert not level.shared_with.exists()


class TestLoginViews(TestCase):
@classmethod
Expand Down
8 changes: 8 additions & 0 deletions portal/views/teacher/teach.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
from reportlab.lib.utils import ImageReader
from reportlab.pdfgen import canvas

from game.models import Level

from portal.forms.teach import (
BaseTeacherDismissStudentsFormSet,
BaseTeacherMoveStudentsDisambiguationFormSet,
Expand All @@ -56,6 +58,7 @@
from portal.helpers.ratelimit import clear_ratelimit_cache_for_user
from portal.views.registration import handle_reset_password_tracking


STUDENT_PASSWORD_LENGTH = 6
REMINDER_CARDS_PDF_ROWS = 8
REMINDER_CARDS_PDF_COLUMNS = 1
Expand Down Expand Up @@ -616,6 +619,11 @@ def process_dismiss_student_form(request, formset, klass, access_code):
new_user__first_name__iexact=data["orig_name"],
)

students_levels = Level.objects.filter(owner=student.new_user.userprofile).all()
for level in students_levels:
level.shared_with.set([])
level.save()

student.class_field = None
student.new_user.first_name = data["name"]
student.new_user.username = data["email"]
Expand Down
Loading