Commit 6c3b94d2 by Andy Armstrong

Bump User API and Profile Images API to v1

TNL-1669
parent a37166c3
......@@ -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,
......
......@@ -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
......
......@@ -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
......
......@@ -10,12 +10,12 @@ USERNAME_PATTERN = r'(?P<username>[\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"
),
......
......@@ -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.
......
......@@ -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
......
......@@ -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()
......
......@@ -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)
......
......@@ -12,17 +12,17 @@ USERNAME_PATTERN = r'(?P<username>[\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<preference_key>[a-zA-Z0-9_]+)$',
r'^v1/preferences/' + USERNAME_PATTERN + '/(?P<preference_key>[a-zA-Z0-9_]+)$',
PreferencesDetailView.as_view(),
name="preferences_detail_api"
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment