Skip to content

Commit

Permalink
♻️(settings) remove JS_SELECTOR_REGEXP
Browse files Browse the repository at this point in the history
As it has been done in backend, we only use the course regexp to both select the
lms api and extract the course id. So `JS_SELECTOR_REGEXP` is deprecated.
  • Loading branch information
jbpenrath committed Jan 11, 2021
1 parent bb0d8aa commit 2ce9dfa
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unrealeased]

### Fixed

- Deprecate `JS_SELECTOR_REGEXP`

## [2.0.0] - 2021-01-11

### Changed
Expand Down
1 change: 0 additions & 1 deletion docs/lms-connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ RICHIE_LMS_BACKENDS=[
"BACKEND": "richie.apps.courses.lms.edx.EdXLMSBackend",
"COURSE_REGEX": r"^.*/courses/(?P<course_id>.*)/course/?$",
"JS_BACKEND": "openedx-hawthorn",
"JS_SELECTOR_REGEX": r".*lms-example2.org.*",
"JS_COURSE_REGEX": r"^.*/course/(?<course_id>[0-9]*)$",
},
]
Expand Down
4 changes: 0 additions & 4 deletions sandbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,6 @@ class Base(StyleguideMixin, DRFMixin, RichieCoursesConfigurationMixin, Configura
environ_name="EDX_JS_COURSE_REGEX",
environ_prefix=None,
),
"JS_SELECTOR_REGEX": values.Value(
r".*", environ_name="EDX_JS_SELECTOR_REGEX", environ_prefix=None
),
}
]
RICHIE_COURSE_RUN_SYNC_SECRETS = values.ListValue([])
Expand Down Expand Up @@ -582,7 +579,6 @@ class Test(Base):
"COURSE_REGEX": r"^.*/courses/(?P<course_id>.*)/course/?$",
"JS_BACKEND": "base",
"JS_COURSE_REGEX": r"^.*/courses/(?<course_id>.*)/course/?$",
"JS_SELECTOR_REGEX": r".*",
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('<CourseRunEnrollment />', () => {
backend: ApiBackend.OPENEDX_HAWTHORN,
course_regexp: '(?<course_id>.*)',
endpoint,
selector_regexp: '.*',
},
],
})
Expand Down
1 change: 0 additions & 1 deletion src/frontend/js/types/commonDataProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Nullable } from 'utils/types';
*/
export interface LMSBackend {
backend: string;
selector_regexp: RegExp | string;
course_regexp: RegExp | string;
endpoint: string;
}
Expand Down
1 change: 0 additions & 1 deletion src/frontend/js/utils/api/lms/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ describe('Base API', () => {
backend: ApiBackend.BASE,
course_regexp: '(?<course_id>.*)',
endpoint: 'https://demo.endpoint/api',
selector_regexp: '.*',
},
],
}).generate();
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/js/utils/api/lms/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ describe('API LMS', () => {
{
backend: ApiBackend.BASE,
endpoint: 'https://demo.endpoint/api',
selector_regexp: /.*base.org\/.*/,
course_regexp: /.*base.org\/.*/,
},
{
backend: ApiBackend.OPENEDX_HAWTHORN,
endpoint: 'https://edx.endpoint/api',
selector_regexp: /.*edx.org\/.*/,
course_regexp: /.*edx.org\/.*/,
},
],
environment: 'test',
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/js/utils/api/lms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (!context) throw new Error('No context frontend context available');
const LMS_BACKENDS = context.lms_backends;

const selectAPIWithUrl = (url: string) => {
const API = LMS_BACKENDS.find((lms) => new RegExp(lms.selector_regexp).test(url));
const API = LMS_BACKENDS.find((lms) => new RegExp(lms.course_regexp).test(url));
return API;
};

Expand Down
1 change: 0 additions & 1 deletion src/frontend/js/utils/api/lms/openedx-hawthorn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('OpenEdX Hawthorn API', () => {
backend: ApiBackend.OPENEDX_HAWTHORN,
course_regexp: 'course_id=(?<course_id>.*$)',
endpoint: EDX_ENDPOINT,
selector_regexp: '.*',
},
],
}).generate();
Expand Down
1 change: 0 additions & 1 deletion src/frontend/js/utils/test/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const ContextFactory = (context: Partial<CommonDataProps['context']> = {}
lms_backends: [
{
backend: ApiBackend.BASE,
selector_regexp: '.*',
course_regexp: '.*',
endpoint: 'https://endpoint.test',
},
Expand Down
1 change: 0 additions & 1 deletion src/richie/apps/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def site_metas(request):
"endpoint": lms["BASE_URL"],
"backend": lms["JS_BACKEND"],
"course_regexp": lms["JS_COURSE_REGEX"],
"selector_regexp": lms["JS_SELECTOR_REGEX"],
}
for lms in getattr(settings, "RICHIE_LMS_BACKENDS", [])
]
Expand Down
2 changes: 0 additions & 2 deletions tests/apps/courses/test_templates_course_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ def test_templates_course_detail_runs_ongoing_open(self):
"JS_BACKEND": "openedx-hawthorn",
"COURSE_REGEX": r".*",
"JS_COURSE_REGEX": r"^.*/courses/(?<course_id>.*)/course/?$",
"JS_SELECTOR_REGEX": r".*",
"BASE_URL": "http://edx:8073",
"API_TOKEN": "fakesecret",
}
Expand Down Expand Up @@ -546,7 +545,6 @@ def test_templates_course_detail_runs_future_open(self):
"JS_BACKEND": "openedx-hawthorn",
"COURSE_REGEX": r".*",
"JS_COURSE_REGEX": r"^.*/courses/(?<course_id>.*)/course/?$",
"JS_SELECTOR_REGEX": r".*",
"BASE_URL": "http://edx:8073",
"API_TOKEN": "fakesecret",
}
Expand Down

0 comments on commit 2ce9dfa

Please sign in to comment.