-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add language support in courses #3335
base: master
Are you sure you want to change the base?
Conversation
91c897f
to
70a3859
Compare
b14ab48
to
0085b1c
Compare
0085b1c
to
8025f03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. A couple of small suggestions +
We should use select_related in the API Views and Catalog to avoid n+1 queries for the language table.
Also, I haven't noticed any discussion/comment but It would be a good idea to display the course language in the Catalog Card or a card in the product detail page. I know these will be done in a follow up but just wanted to leave my thoughts here for reference.
null=False, | ||
blank=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: null and blank default to False, can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These flags were added and then changed in the same PR and this thing has 2 migrations so I intentionally kept it like this to keep readability
if not has_language: | ||
assert external_course_page.language.name == "English" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not able to understand this test condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added to test the case where if there is no language key available from the external APIs the default English language should be assigned to the course. But, As discussed I'll add the else condition to check for provided language and I'll add a code comment above for more readability
courses/models.py
Outdated
|
||
class Meta: | ||
constraints = [ | ||
models.UniqueConstraint(Lower("name"), name="unique_language_name") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can provide a better message by passing violation_error_message
. Otherwise, it will display a less user-friendly message Constraint “unique_language_name” is violated.
.
bcdb271
to
7a8e3aa
Compare
@asadali145 I've addressed the feedback in 7a8e3aa. Let me know if all the changes look good to you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neatly done, Looks GooD!
"platform", | ||
"programpage__language", | ||
"externalprogrampage__language", | ||
) | ||
.prefetch_related(courses_prefetch, products_prefetch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed we need to select_related the course language for the program courses.
What are the relevant tickets?
https://github.com/mitodl/hq/issues/6239
Description (What does it do?)
CourseLanguage
to manage supported languages, The model haspriority
field that defines the sorting order of course by language on CatalogEnglish
English, Spanish, Portuguese, Mandarin, Italian, French
as per https://github.com/mitodl/hq/issues/6111Screenshots (if appropriate):
TBA
Manage Languages
Assign languages (CMS)
How can this be tested?
Testing language Model & data Prefill
Course Languages
should now be available in Django Admin with pre-filled languages as mentioned above. TheEnglish
language would have the priority set to1
whereas the other languages should have100
. This is because we want to sort the courses by English language for now. However, this priority key can be used to test different languages with different priority values.1
means highest priorityEnglish
by default)Testing External APIs
sync_external_course_runs --vendor-name emeritus/Global Alunmni
Testing internal APIs
api/courses
&/api/programs
have a language field in the JSON responseTesting Catalog Course sorting
Testing Seed Data
English
set to the by defaultThere are no frontend-level changes for now, except for the ones mentioned above
Additional Context