Skip to content
Snippets Groups Projects
Commit 6802a38a authored by Dave St.Germain's avatar Dave St.Germain
Browse files

Added master's track

Added mode option to course enrollment management command
parent 4b4957ad
No related merge requests found
......@@ -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
......@@ -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 = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment