From 4380ee820da9be863fa174dbe6a3ecdce71ed72f Mon Sep 17 00:00:00 2001 From: Bryan Wilson <bryanlandia@gmail.com> Date: Thu, 3 Jun 2021 16:10:18 -0700 Subject: [PATCH] Avoid /api/courses/ overlap with Open edX COURSE_REGEX. /courses/general/course-v1... and /courses/detail/course-v1... will be matched by Open edX request util and other course id REGEX's as a course with id of general/course-v1 etc. and result in 500 errors particulary in some middlewares. Addresses #361 --- figures/urls.py | 4 ++-- frontend/src/apiConfig.js | 4 ++-- old-docs/api-reference.md | 8 ++++---- tests/views/test_general_course_data_view.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/figures/urls.py b/figures/urls.py index 062abe65..b49b9805 100644 --- a/figures/urls.py +++ b/figures/urls.py @@ -77,12 +77,12 @@ base_name='courses-index') router.register( - r'courses/general', + r'courses-general', views.GeneralCourseDataViewSet, base_name='courses-general') router.register( - r'courses/detail', + r'courses-detail', views.CourseDetailsViewSet, base_name='courses-detail') diff --git a/frontend/src/apiConfig.js b/frontend/src/apiConfig.js index c5c381bc..1db3599d 100644 --- a/frontend/src/apiConfig.js +++ b/frontend/src/apiConfig.js @@ -4,8 +4,8 @@ const apiConfig = { edxUserInfoApi: '/api/user/v1/accounts/', courseEnrollmentsApi: '/figures/api/course-enrollments/', generalSiteMetrics: '/figures/api/general-site-metrics/', - coursesGeneral: '/figures/api/courses/general/', - coursesDetailed: '/figures/api/courses/detail/', + coursesGeneral: '/figures/api/courses-general/', + coursesDetailed: '/figures/api/courses-detail/', learnersGeneral: '/figures/api/users/general/', learnersDetailed: '/figures/api/users/detail/', reportingCsvReportsApi: '/reporting/api/csv-reports/', diff --git a/old-docs/api-reference.md b/old-docs/api-reference.md index 468f5a1c..22ecceb8 100644 --- a/old-docs/api-reference.md +++ b/old-docs/api-reference.md @@ -278,7 +278,7 @@ To get the set of general site metrics: To get a list of all courses with general (summary) metrics for each: ``` -/figures/api/courses/general/ +/figures/api/courses-general/ ``` ### Course Details @@ -286,7 +286,7 @@ To get a list of all courses with general (summary) metrics for each: This endpoint provides a combination of course information and learner activity ``` -/figures/api/courses/detail/ +/figures/api/courses-detail/ ``` To get the data for a specific course: @@ -298,13 +298,13 @@ To get the data for a specific course: Example: ``` -/figures/api/courses/detail/course-v1:edX+DemoX+Demo_Course/ +/figures/api/courses-detail/course-v1:edX+DemoX+Demo_Course/ ``` You can also filter on org: ``` -/figures/api/courses/detail/?org=edX +/figures/api/courses-detail/?org=edX ``` diff --git a/tests/views/test_general_course_data_view.py b/tests/views/test_general_course_data_view.py index cb0a0172..01c3a1b7 100644 --- a/tests/views/test_general_course_data_view.py +++ b/tests/views/test_general_course_data_view.py @@ -101,7 +101,7 @@ class TestGeneralCourseDataViewSet(BaseViewTest): '''Tests the UserIndexView view class ''' - request_path = 'api/courses/general' + request_path = 'api/courses-general' view_class = GeneralCourseDataViewSet @pytest.fixture(autouse=True)