From 6802a38a9d8a0fae61cf8a53cb591377406b3ae3 Mon Sep 17 00:00:00 2001 From: "Dave St.Germain" Date: Thu, 7 Feb 2019 15:42:40 -0500 Subject: [PATCH] Added master's track Added mode option to course enrollment management command --- .../management/commands/enroll_user_in_course.py | 15 ++++++++++++--- lms/envs/common.py | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/common/djangoapps/enrollment/management/commands/enroll_user_in_course.py b/common/djangoapps/enrollment/management/commands/enroll_user_in_course.py index 033ed26565..3f393c71c0 100644 --- a/common/djangoapps/enrollment/management/commands/enroll_user_in_course.py +++ b/common/djangoapps/enrollment/management/commands/enroll_user_in_course.py @@ -12,9 +12,10 @@ class Command(BaseCommand): Enroll a user into a course """ help = """ - This enrolls a user into a given course with the default mode (e.g., 'honor', 'audit', etc). + This enrolls a user into a given course User email and course ID are required. + Mode is optional. It defaults to the default mode (e.g., 'honor', 'audit', etc). example: # Enroll a user test@example.com into the demo course @@ -35,7 +36,14 @@ class Command(BaseCommand): '-c', '--course', nargs=1, required=True, - help='course ID to enroll the user in') + help='course ID to enroll the user in' + ) + parser.add_argument( + '-m', '--mode', + required=False, + default=None, + help='course mode to enroll the user in' + ) def handle(self, *args, **options): """ @@ -43,10 +51,11 @@ class Command(BaseCommand): """ email = options['email'][0] course = options['course'][0] + mode = options['mode'] user = User.objects.get(email=email) try: - add_enrollment(user.username, course) + add_enrollment(user.username, course, mode=mode) except CourseEnrollmentExistsError: # If the user is already enrolled in the course, do nothing. pass diff --git a/lms/envs/common.py b/lms/envs/common.py index ffbeff77b5..2a8db707e9 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -3383,6 +3383,12 @@ COURSE_ENROLLMENT_MODES = { "display_name": _("Honor"), "min_price": 0 }, + "masters": { + "id": 7, + "slug": "masters", + "display_name": _("Master's"), + "min_price": 0 + }, } CONTENT_TYPE_GATE_GROUP_IDS = {