Skip to content

Commit

Permalink
Update invitation to use course enrollment time (#843)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmi4er4 authored Jun 5, 2024
1 parent 35656fb commit 9dab608
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 1 addition & 7 deletions apps/learning/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 6 additions & 0 deletions apps/users/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit 9dab608

Please sign in to comment.