Skip to content
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

Fix: [ENT-8400]: added transcript_languages_search_facet_names to CourseRunSerializer #4302

Merged

Conversation

mahamakifdar19
Copy link
Contributor

@mahamakifdar19 mahamakifdar19 commented Mar 26, 2024

Ticket

ENT-8400

Description

  • Reapplies PR 4269 that was reverted and resolves the mentioned issue.
  • The error occurred because the language Tagalog was stored in the LanguageTag model without a corresponding name_t (Name for translation) in the LanguageTagTranslation model. This caused an error when the existing get_search_facet_display method looked for a corresponding name for translation.

Resolution

I've added a validation check to verify the existence of the corresponding name_t (Name for translation) in the LanguageTagTranslation model before accessing it, furthermore I have disabled the translation flag for get_transcript_languages_search_facet_names because we do not require translated transcript language names, and not all languages stored in transcript_languages have a corresponding name for translation stored.

File "/edx/app/discovery/discovery/course_discovery/apps/api/serializers.py", line 1096, in get_transcript_languages_search_facet_names
    transcript_languages_facet_names.append(language.get_search_facet_display(translate=True))
  File "/edx/app/discovery/discovery/course_discovery/apps/ietf_language_tags/models.py", line 29, in get_search_facet_display
    return self.translated_macrolanguage if translate else self.macrolanguage
  File "/edx/app/discovery/discovery/course_discovery/apps/ietf_language_tags/models.py", line 22, in translated_macrolanguage
    return self.name_t.split('-')[0].strip()
  File "/edx/app/discovery/venvs/discovery/lib/python3.8/site-packages/parler/fields.py", line 142, in __get__
    translation = instance._get_translated_model(use_fallback=True, meta=meta)
  File "/edx/app/discovery/venvs/discovery/lib/python3.8/site-packages/parler/models.py", line 620, in _get_translated_model
    raise meta.model.DoesNotExist(
parler.models.DoesNotExist: language tag does not have a translation for the current language!
language tag ID #tl, language=en (tried fallbacks en)
Attempted to read attribute name_t.

Copy link
Contributor

@saleem-latif saleem-latif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good 👍🏼

@DawoudSheraz DawoudSheraz merged commit a5b1e7e into openedx:master Mar 27, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants