Skip to content

Commit

Permalink
feat: add filter in CourseEnrollmentAllowed.
Browse files Browse the repository at this point in the history
  • Loading branch information
anfbermudezme committed May 31, 2024
1 parent 60444ea commit 02fcb57
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lms/djangoapps/instructor/enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
get_event_transaction_id,
set_event_transaction_type
)
from common.djangoapps.student.models import EnrollmentNotAllowed
from lms.djangoapps.courseware.models import StudentModule
from lms.djangoapps.grades.api import constants as grades_constants
from lms.djangoapps.grades.api import disconnect_submissions_signal_receiver
Expand All @@ -51,6 +52,7 @@
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.user_api.models import UserPreference
from openedx.core.djangolib.markup import Text
from openedx_filters.learning.filters import CourseEnrollmentStarted
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.exceptions import ItemNotFoundError # lint-amnesty, pylint: disable=wrong-import-order

Expand Down Expand Up @@ -166,6 +168,13 @@ def enroll_email(course_id, student_email, auto_enroll=False, email_students=Fal
send_mail_to_student(student_email, email_params, language=language)

elif not is_email_retired(student_email):
try:
CourseEnrollmentStarted.run_filter(
user=None, course_key=course_id, mode=None,
)
except CourseEnrollmentStarted.PreventEnrollment as exc:
raise EnrollmentNotAllowed(str(exc)) from exc

cea, _ = CourseEnrollmentAllowed.objects.get_or_create(course_id=course_id, email=student_email)
cea.auto_enroll = auto_enroll
cea.save()
Expand Down

0 comments on commit 02fcb57

Please sign in to comment.