diff --git a/lms/envs/common.py b/lms/envs/common.py index 9541c5acc8..9b4804880f 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -317,9 +317,6 @@ FEATURES = { # Set to True to change the course sorting behavior by their start dates, latest first. 'ENABLE_COURSE_SORTING_BY_START_DATE': True, - # Flag to enable new user account APIs. - 'ENABLE_USER_REST_API': True, - # Expose Mobile REST API. Note that if you use this, you must also set # ENABLE_OAUTH2_PROVIDER to True 'ENABLE_MOBILE_REST_API': False, diff --git a/lms/envs/test.py b/lms/envs/test.py index 497faa55e6..c2019fe76e 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -268,7 +268,6 @@ FEATURES['ENABLE_OAUTH2_PROVIDER'] = True FEATURES['ENABLE_MOBILE_REST_API'] = True FEATURES['ENABLE_MOBILE_SOCIAL_FACEBOOK_FEATURES'] = True FEATURES['ENABLE_VIDEO_ABSTRACTION_LAYER_API'] = True -FEATURES['ENABLE_USER_REST_API'] = True ###################### Payment ##############################3 # Enable fake payment processing page diff --git a/lms/urls.py b/lms/urls.py index 169253ea85..92fac5da90 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -86,13 +86,13 @@ urlpatterns = ( # Course content API url(r'^api/course_structure/', include('course_structure_api.urls', namespace='course_structure_api')), -) -if settings.FEATURES["ENABLE_USER_REST_API"]: - urlpatterns += ( - url(r'^api/user/', include('openedx.core.djangoapps.user_api.urls')), - url(r'^api/profile_images/', include('openedx.core.djangoapps.profile_images.urls')), - ) + # User API endpoints + url(r'^api/user/', include('openedx.core.djangoapps.user_api.urls')), + + # Profile Images API endpoints + url(r'^api/profile_images/', include('openedx.core.djangoapps.profile_images.urls')), +) if settings.FEATURES["ENABLE_COMBINED_LOGIN_REGISTRATION"]: # Backwards compatibility with old URL structure, but serve the new views diff --git a/openedx/core/djangoapps/profile_images/urls.py b/openedx/core/djangoapps/profile_images/urls.py index a2e73c73ac..0f8dd3dbae 100644 --- a/openedx/core/djangoapps/profile_images/urls.py +++ b/openedx/core/djangoapps/profile_images/urls.py @@ -10,12 +10,12 @@ USERNAME_PATTERN = r'(?P[\w.+-]+)' urlpatterns = patterns( '', url( - r'^v0/' + USERNAME_PATTERN + '/upload$', + r'^v1/' + USERNAME_PATTERN + '/upload$', ProfileImageUploadView.as_view(), name="profile_image_upload" ), url( - r'^v0/' + USERNAME_PATTERN + '/remove$', + r'^v1/' + USERNAME_PATTERN + '/remove$', ProfileImageRemoveView.as_view(), name="profile_image_remove" ), diff --git a/openedx/core/djangoapps/profile_images/views.py b/openedx/core/djangoapps/profile_images/views.py index 2fba31821d..83e741c3aa 100644 --- a/openedx/core/djangoapps/profile_images/views.py +++ b/openedx/core/djangoapps/profile_images/views.py @@ -42,7 +42,7 @@ class ProfileImageUploadView(APIView): **Example Requests**: - POST /api/profile_images/v0/{username}/upload + POST /api/profile_images/v1/{username}/upload **Response for POST** @@ -65,7 +65,7 @@ class ProfileImageUploadView(APIView): def post(self, request, username): """ - POST /api/profile_images/v0/{username}/upload + POST /api/profile_images/v1/{username}/upload """ # validate request: # verify that the user's @@ -119,7 +119,7 @@ class ProfileImageRemoveView(APIView): **Example Requests**: - POST /api/profile_images/v0/{username}/remove + POST /api/profile_images/v1/{username}/remove **Response for POST** @@ -139,7 +139,7 @@ class ProfileImageRemoveView(APIView): def post(self, request, username): # pylint: disable=unused-argument """ - POST /api/profile_images/v0/{username}/remove + POST /api/profile_images/v1/{username}/remove """ try: # update the user account to reflect that the images were removed. diff --git a/openedx/core/djangoapps/user_api/accounts/views.py b/openedx/core/djangoapps/user_api/accounts/views.py index 19c8649030..924e669e22 100644 --- a/openedx/core/djangoapps/user_api/accounts/views.py +++ b/openedx/core/djangoapps/user_api/accounts/views.py @@ -28,9 +28,9 @@ class AccountView(APIView): **Example Requests**: - GET /api/user/v0/accounts/{username}/[?view=shared] + GET /api/user/v1/accounts/{username}/[?view=shared] - PATCH /api/user/v0/accounts/{username}/{"key":"value"} "application/merge-patch+json" + PATCH /api/user/v1/accounts/{username}/{"key":"value"} "application/merge-patch+json" **Response Values for GET** @@ -154,7 +154,7 @@ class AccountView(APIView): def get(self, request, username): """ - GET /api/user/v0/accounts/{username}/ + GET /api/user/v1/accounts/{username}/ """ try: account_settings = get_account_settings(request.user, username, view=request.QUERY_PARAMS.get('view')) @@ -169,7 +169,7 @@ class AccountView(APIView): def patch(self, request, username): """ - PATCH /api/user/v0/accounts/{username}/ + PATCH /api/user/v1/accounts/{username}/ Note that this implementation is the "merge patch" implementation proposed in https://tools.ietf.org/html/rfc7396. The content_type must be "application/merge-patch+json" or diff --git a/openedx/core/djangoapps/user_api/preferences/tests/test_views.py b/openedx/core/djangoapps/user_api/preferences/tests/test_views.py index 8ebbf282e9..461923b807 100644 --- a/openedx/core/djangoapps/user_api/preferences/tests/test_views.py +++ b/openedx/core/djangoapps/user_api/preferences/tests/test_views.py @@ -25,7 +25,7 @@ TOO_LONG_PREFERENCE_KEY = u"x" * 256 @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') class TestPreferencesAPI(UserAPITestCase): """ - Unit tests /api/user/v0/accounts/{username}/ + Unit tests /api/user/v1/accounts/{username}/ """ def setUp(self): super(TestPreferencesAPI, self).setUp() @@ -342,7 +342,7 @@ class TestPreferencesAPITransactions(TransactionTestCase): @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') class TestPreferencesDetailAPI(UserAPITestCase): """ - Unit tests /api/user/v0/accounts/{username}/{preference_key} + Unit tests /api/user/v1/accounts/{username}/{preference_key} """ def setUp(self): super(TestPreferencesDetailAPI, self).setUp() diff --git a/openedx/core/djangoapps/user_api/preferences/views.py b/openedx/core/djangoapps/user_api/preferences/views.py index 695d811f4d..8c55ce9de3 100644 --- a/openedx/core/djangoapps/user_api/preferences/views.py +++ b/openedx/core/djangoapps/user_api/preferences/views.py @@ -33,9 +33,9 @@ class PreferencesView(APIView): **Example Requests**: - GET /api/user/v0/preferences/{username}/ + GET /api/user/v1/preferences/{username}/ - PATCH /api/user/v0/preferences/{username}/ with content_type "application/merge-patch+json" + PATCH /api/user/v1/preferences/{username}/ with content_type "application/merge-patch+json" **Response Value for GET** @@ -71,7 +71,7 @@ class PreferencesView(APIView): def get(self, request, username): """ - GET /api/user/v0/preferences/{username}/ + GET /api/user/v1/preferences/{username}/ """ try: user_preferences = get_user_preferences(request.user, username=username) @@ -84,7 +84,7 @@ class PreferencesView(APIView): def patch(self, request, username): """ - PATCH /api/user/v0/preferences/{username}/ + PATCH /api/user/v1/preferences/{username}/ """ if not request.DATA or not getattr(request.DATA, "keys", None): error_message = _("No data provided for user preference update") @@ -126,11 +126,11 @@ class PreferencesDetailView(APIView): **Example Requests**: - GET /api/user/v0/preferences/{username}/{preference_key} + GET /api/user/v1/preferences/{username}/{preference_key} - PUT /api/user/v0/preferences/{username}/{preference_key} + PUT /api/user/v1/preferences/{username}/{preference_key} - DELETE /api/user/v0/preferences/{username}/{preference_key} + DELETE /api/user/v1/preferences/{username}/{preference_key} **Response Values for GET** @@ -167,7 +167,7 @@ class PreferencesDetailView(APIView): def get(self, request, username, preference_key): """ - GET /api/user/v0/preferences/{username}/{preference_key} + GET /api/user/v1/preferences/{username}/{preference_key} """ try: value = get_user_preference(request.user, preference_key, username=username) @@ -182,7 +182,7 @@ class PreferencesDetailView(APIView): def put(self, request, username, preference_key): """ - PUT /api/user/v0/preferences/{username}/{preference_key} + PUT /api/user/v1/preferences/{username}/{preference_key} """ try: set_user_preference(request.user, preference_key, request.DATA, username=username) @@ -210,7 +210,7 @@ class PreferencesDetailView(APIView): def delete(self, request, username, preference_key): """ - DELETE /api/user/v0/preferences/{username}/{preference_key} + DELETE /api/user/v1/preferences/{username}/{preference_key} """ try: preference_existed = delete_user_preference(request.user, preference_key, username=username) diff --git a/openedx/core/djangoapps/user_api/urls.py b/openedx/core/djangoapps/user_api/urls.py index 688634bb57..8ae0414941 100644 --- a/openedx/core/djangoapps/user_api/urls.py +++ b/openedx/core/djangoapps/user_api/urls.py @@ -12,17 +12,17 @@ USERNAME_PATTERN = r'(?P[\w.+-]+)' urlpatterns = patterns( '', url( - r'^v0/accounts/' + USERNAME_PATTERN + '$', + r'^v1/accounts/' + USERNAME_PATTERN + '$', AccountView.as_view(), name="accounts_api" ), url( - r'^v0/preferences/' + USERNAME_PATTERN + '$', + r'^v1/preferences/' + USERNAME_PATTERN + '$', PreferencesView.as_view(), name="preferences_api" ), url( - r'^v0/preferences/' + USERNAME_PATTERN + '/(?P[a-zA-Z0-9_]+)$', + r'^v1/preferences/' + USERNAME_PATTERN + '/(?P[a-zA-Z0-9_]+)$', PreferencesDetailView.as_view(), name="preferences_detail_api" ),