From 85b3bfe4f6512e4e03d3c26793ed5ad095d73993 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Fri, 26 Jun 2015 15:24:30 -0400 Subject: [PATCH] Add feature flag for Import/Export API in LMS This feature flag gates the exposure of the Full course/library Import/Export API URLs in the LMS. This allows openedX deployments that operate without Studio to take advantage of the API, while others may turn the feature off to reserve all content authoring for Studio. --- lms/envs/common.py | 3 +++ lms/envs/test.py | 3 +++ lms/urls.py | 9 ++++++--- .../core/djangoapps/import_export/courses/tests/utils.py | 8 ++++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index 989c50583b..1035fd0e11 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -408,6 +408,9 @@ FEATURES = { # Credit course API 'ENABLE_CREDIT_API': False, + + # Full Course/Library Import/Export API + 'ENABLE_IMPORT_EXPORT_LMS': False, } # Ignore static asset files on import which match this pattern diff --git a/lms/envs/test.py b/lms/envs/test.py index 58683cb969..8c7cc0b0ca 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -493,3 +493,6 @@ PROFILE_IMAGE_MIN_BYTES = 100 FEATURES['ENABLE_LTI_PROVIDER'] = True INSTALLED_APPS += ('lti_provider',) AUTHENTICATION_BACKENDS += ('lti_provider.users.LtiBackend',) + +# Enable the Full Course/Library Import/Export API +FEATURES['ENABLE_IMPORT_EXPORT_LMS'] = True diff --git a/lms/urls.py b/lms/urls.py index 8ce499cf2c..8199641653 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -89,11 +89,14 @@ urlpatterns = ( # Video Abstraction Layer used to allow video teams to manage video assets # independently of courseware. https://github.com/edx/edx-val url(r'^api/val/v0/', include('edxval.urls')), - - # Full Course/Library Import/Export API - url(r'^api/import_export/v1/', include('openedx.core.djangoapps.import_export.urls')), ) +# Full Course/Library Import/Export API +if settings.FEATURES["ENABLE_IMPORT_EXPORT_LMS"]: + urlpatterns += ( + url(r'^api/import_export/v1/', include('openedx.core.djangoapps.import_export.urls')), + ) + if settings.FEATURES["ENABLE_COMBINED_LOGIN_REGISTRATION"]: # Backwards compatibility with old URL structure, but serve the new views urlpatterns += ( diff --git a/openedx/core/djangoapps/import_export/courses/tests/utils.py b/openedx/core/djangoapps/import_export/courses/tests/utils.py index 5cb3f22f75..00f3d908a1 100644 --- a/openedx/core/djangoapps/import_export/courses/tests/utils.py +++ b/openedx/core/djangoapps/import_export/courses/tests/utils.py @@ -3,16 +3,16 @@ Utilities for contentstore tests ''' from datetime import timedelta - +from django.conf import settings from django.utils import timezone + +from provider.oauth2.models import AccessToken, Client as OAuth2Client +from provider import constants from rest_framework.test import APIClient from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -from django.conf import settings -from provider.oauth2.models import AccessToken, Client as OAuth2Client -from provider import constants TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT