From 2b25c9fc785154bfe33d2d388e56a4f209f52a0f Mon Sep 17 00:00:00 2001 From: Giulio Gratta <giuliog@stanford.edu> Date: Thu, 12 Jan 2017 11:17:25 -0800 Subject: [PATCH] Enable DEFAULT_MODE to be customized in config - Keeps platform set default of "Audit" to be backwards compatible and not break stuff - get COURSE_MODE_DEFAULTS from config if set --- cms/envs/common.py | 2 +- common/djangoapps/course_modes/models.py | 15 +++++++++++++-- lms/envs/aws.py | 3 +++ lms/envs/common.py | 12 ++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index 84d171c8d9b..cbe0543cf5d 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -59,7 +59,7 @@ from lms.envs.common import ( # The following setting is included as it is used to check whether to # display credit eligibility table on the CMS or not. ENABLE_CREDIT_ELIGIBILITY, YOUTUBE_API_KEY, - DEFAULT_COURSE_ABOUT_IMAGE_URL, + COURSE_MODE_DEFAULTS, DEFAULT_COURSE_ABOUT_IMAGE_URL, # Django REST framework configuration REST_FRAMEWORK, diff --git a/common/djangoapps/course_modes/models.py b/common/djangoapps/course_modes/models.py index 37df4c707be..55c62c177e5 100644 --- a/common/djangoapps/course_modes/models.py +++ b/common/djangoapps/course_modes/models.py @@ -6,6 +6,7 @@ from datetime import datetime, timedelta import pytz from config_models.models import ConfigurationModel +from django.conf import settings from django.core.exceptions import ValidationError from django.db import models from django.db.models import Q @@ -119,8 +120,18 @@ class CourseMode(models.Model): NO_ID_PROFESSIONAL_MODE = "no-id-professional" CREDIT_MODE = "credit" - DEFAULT_MODE = Mode(AUDIT, _('Audit'), 0, '', 'usd', None, None, None, None) - DEFAULT_MODE_SLUG = AUDIT + DEFAULT_MODE = Mode( + settings.COURSE_MODE_DEFAULTS['slug'], + settings.COURSE_MODE_DEFAULTS['name'], + settings.COURSE_MODE_DEFAULTS['min_price'], + settings.COURSE_MODE_DEFAULTS['suggested_prices'], + settings.COURSE_MODE_DEFAULTS['currency'], + settings.COURSE_MODE_DEFAULTS['expiration_datetime'], + settings.COURSE_MODE_DEFAULTS['description'], + settings.COURSE_MODE_DEFAULTS['sku'], + settings.COURSE_MODE_DEFAULTS['bulk_sku'], + ) + DEFAULT_MODE_SLUG = settings.COURSE_MODE_DEFAULTS['slug'] # Modes utilized for audit/free enrollments AUDIT_MODES = [AUDIT, HONOR] diff --git a/lms/envs/aws.py b/lms/envs/aws.py index ad4018200d8..d120f432090 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -137,6 +137,9 @@ if STATIC_URL_BASE: # DEFAULT_COURSE_ABOUT_IMAGE_URL specifies the default image to show for courses that don't provide one DEFAULT_COURSE_ABOUT_IMAGE_URL = ENV_TOKENS.get('DEFAULT_COURSE_ABOUT_IMAGE_URL', DEFAULT_COURSE_ABOUT_IMAGE_URL) +# COURSE_MODE_DEFAULTS specifies the course mode to use for courses that do not set one +COURSE_MODE_DEFAULTS = ENV_TOKENS.get('COURSE_MODE_DEFAULTS', COURSE_MODE_DEFAULTS) + # MEDIA_ROOT specifies the directory where user-uploaded files are stored. MEDIA_ROOT = ENV_TOKENS.get('MEDIA_ROOT', MEDIA_ROOT) MEDIA_URL = ENV_TOKENS.get('MEDIA_URL', MEDIA_URL) diff --git a/lms/envs/common.py b/lms/envs/common.py index ad435f1421a..29790a0170a 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -613,6 +613,18 @@ COURSE_SETTINGS = { } } +COURSE_MODE_DEFAULTS = { + 'bulk_sku': None, + 'currency': 'usd', + 'description': None, + 'expiration_datetime': None, + 'min_price': 0, + 'name': _('Audit'), + 'sku': None, + 'slug': 'audit', + 'suggested_prices': '', +} + # IP addresses that are allowed to reload the course, etc. # TODO (vshnayder): Will probably need to change as we get real access control in. LMS_MIGRATION_ALLOWED_IPS = [] -- GitLab