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

feat: having released_languages tenant and site aware DS-553 #184

Merged
merged 3 commits into from
Jun 26, 2023

Conversation

MaferMazu
Copy link
Contributor

@MaferMazu MaferMazu commented Jun 21, 2023

Description

This PR extract LC-V2 from the platform to eox-tenant.

LC-V2 allows you to have released_languages site aware in: openedx/core/djangoapps/lang_pref/api.py, openedx/core/djangoapps/dark_lang/middleware.py. And set a default value to HTTP_ACCEPT_LANGUAGE.

More context: LC-V2 Doc

Testing instructions

SetUp

  • You need to have a Tutor environment with eox-tenant installed with this version.
  • You need to add some settings for eox-tenant and the selectors to work (you can add it in env/apps/openedx/config/lms.env.yml and in env/apps/openedx/config/cms.env.yml):
    • USE_EOX_TENANT: true
    • Y en FEATURES:
      • EDNX_SITE_AWARE_LOCALE: true
      • SHOW_FOOTER_LANGUAGE_SELECTOR: true
      • SHOW_HEADER_LANGUAGE_SELECTOR: true
  • Create a Tenant A with this config:
 {
    "EDNX_USE_SIGNAL": true,
    "PLATFORM_NAME": "Tenant A",
    "SITE_NAME": "tenant-a.local.overhang.io:8000",
    "course_org_filter": [
        "edX"
    ],
    "released_languages": "en, es-419, pt-BR, ru, da, ar, it",
    "LANGUAGE_CODE":"es-419"
}
  • Create a Tenant B:
 {
    "EDNX_USE_SIGNAL": true,
    "PLATFORM_NAME": "Tenant B",
    "SITE_NAME": "tenant-b.local.overhang.io:8000",
    "course_org_filter": [
        "edX"
    ],
    "released_languages": "en, ar, fr"
}
  • Create a tenant with the Studio route:
{
    "EDNX_USE_SIGNAL": true,
    "LANGUAGE_CODE": "pt-BR",
    "PLATFORM_NAME": "Studio Test",
    "SITE_NAME": "studio.local.overhang.io:8001",
    "released_languages": "en, es-419, pt-BR, ru, da, ar, it"
}

How to test it

  • Visit tenant-a.local.overhang.io:8000 and tenant-b.local.overhang.io:8000 and you are going to see different languages in the header and footer dropdown, depending on release_languages config (Test the API section).
  • Enter studio.local.overhang.io:8001 and see the dropdown options. (Testing the Studio)
  • In your terminal run: curl http://tenant-a.local.overhang.io:8000 -s 2>&1 | head -n 15 and you should see the LANGUAGE_CODE defined by site, for example in tenant-a is es-419. (Testing the default HTTP, and also the middleware)

Additional information

Implementation

  • This adds two "proxies", the first one to override the API and another to override the middleware and set a default value to HTTP_ACCEPT_LANGUAGE.
  • We create a backend to inherit from DarkLangMiddleware.

About this feature

  • If you are not login you can change the lang, but you are not going to maintain that lang (the middleware always reset to the LANGUAGE_CODE)
  • If you are login you can change the lang with the footer and maintain that config. Also, you can edit the lang in your account settings with http://tenant-a.local.overhang.io:8000/account/settings
  • Another thing is if you used http://tenant-a.local.overhang.io:8000/update_lang/ that has the maximum priority. If you want to try the footer and header feature for languages I recommend not setting the lang with /update_lang/ or if you already have settled you can reset the configuration in that update page.

Checklist for Merge

  • Updated documentation
  • Rebased master/main
  • Squashed commits

@MaferMazu MaferMazu changed the title feat: having released_languages tenant and site aware feat: having released_languages tenant and site aware DS-553 Jun 22, 2023
Copy link
Contributor

@Asespinel Asespinel left a comment

Choose a reason for hiding this comment

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

Hey everybody, after I tested all the changes in my local environment, I had no issues at all. I'm approving the pr and I'm attaching the screenshots.

API Section

Tenant A:
api-tenanta
Tenant B:
api-tenantb

Studio Section

studio

HTTP+Middleware Section

http+middleware

Thanks for the clear testing instructions!

@Alec4r
Copy link
Member

Alec4r commented Jun 24, 2023

@MaferMazu did you deploy this changes in our olive platform? could we test it there or we need to test in local?

@Alec4r
Copy link
Member

Alec4r commented Jun 24, 2023

@MaferMazu did you deploy this changes in our olive platform? could we test it there or we need to test in local?

All it's good for me, but I would like test it in a "production" environment.

Copy link
Member

@JuanDavidBuitrago JuanDavidBuitrago left a comment

Choose a reason for hiding this comment

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

I tested it in my local, and it's working as expected.

@MaferMazu
Copy link
Contributor Author

@Alec4r I don't have this in a staging environment. I will merge this according to the comments, but next time I'll upload it to the stage to make it easier to try.

@MaferMazu MaferMazu merged commit 2350c81 into master Jun 26, 2023
luisfelipec95 pushed a commit that referenced this pull request Jul 6, 2023
* feat: having released_languages tenant and site aware

* fix: add darklangmiddleware backend for test

* fix: correct the format of the language_options in the proxy
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.

4 participants