From 9dab608d8ec37daf44d6fd977f6a540444daef38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A7=D0=B5?= <39742182+Dmi4er4@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:34:34 +0300 Subject: [PATCH] Update invitation to use course enrollment time (#843) --- apps/learning/models.py | 8 +------- apps/users/tests/test_models.py | 6 ++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/learning/models.py b/apps/learning/models.py index dece12a89..b931f7d6c 100644 --- a/apps/learning/models.py +++ b/apps/learning/models.py @@ -560,13 +560,7 @@ def get_absolute_url(self): @property def is_active(self): - today = now_local(self.branch.get_timezone()).date() - return (EnrollmentPeriod.objects - .filter(semester=self.semester, - site_id=settings.SITE_ID, - starts_on__lte=today, - ends_on__gte=today) - .exists()) + return all(course.enrollment_is_open for course in self.courses.all()) class PersonalAssignmentActivity(models.TextChoices): diff --git a/apps/users/tests/test_models.py b/apps/users/tests/test_models.py index a445bed07..b6da805e0 100644 --- a/apps/users/tests/test_models.py +++ b/apps/users/tests/test_models.py @@ -197,7 +197,9 @@ def test_student_profile_is_invited_student_active(): student_profile.type = StudentTypes.INVITED assert not student_profile.is_invited_student_active + course = CourseFactory(semester=Semester.get_current()) invitation = InvitationFactory() + invitation.courses.add(course) student_profile.invitation = invitation assert not student_profile.is_invited_student_active @@ -224,6 +226,10 @@ def test_student_profile_is_invited_student_active(): enrollmentperiod.save() assert student_profile.is_invited_student_active + course.ends_on = today - datetime.timedelta(days=1) + course.save() + assert not student_profile.is_invited_student_active + def test_get_abbreviated_short_name(): non_breaking_space = chr(160)