feat: make case sensitive name org field (#262)#263
Open
johanseto wants to merge 1 commit into
Open
Conversation
* feat: make case sensitive name org field * feat: fix testing migrations * feat: more explicit collation depending dbengine * chore: clean unnecesary file (cherry picked from commit 3e2c74f)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Problem
In Open edX, the
SiteConfigurationmodel is monkey-patched or tenant proxied byeox-tenantto manage data on a tenant-by-tenant basis. As part of this, thehas_org(org)method—which determines if a site is associated with a specific organization—is not overridden by thetenant_wiseproxy to check against the organizations stored ineox_tenant'sTenantOrganizations, but theget_all_orgs()method yes.In the original
get_all_coursesof OpenEdX which returns both results in thecourse_org_filter.https://github.com/openedx/openedx-platform/blob/30269ea08f92b13534d48a59c0effc71f811ac68/openedx/core/djangoapps/site_configuration/models.py#L115C9-L130
However, this override introduced a strict case-sensitivity issue. If the
orgparameter passed tohas_org()is in lowercase, but the correspondingTenantOrganizationwas originally created in uppercase (or vice versa), the match fails and the method incorrectly returnsFalse. Becauseget_all_orgs()is overridden by tenant-wise loading only the organization once in its original casing, any course created with an alternate casing would not be recognized, resulting in the tenant failing to load those courses.eox-tenant/eox_tenant/tenant_wise/proxies.py
Lines 109 to 124 in aca527b
Because due the casing in TenantOrganization the
course_org_filterthe tenantConfig only created one TenantOrganization, in this case the Uppercase, but the lower not.The Solution
This PR resolves the case-sensitivity mismatch by ensuring that both the lowercase and uppercase variations of the organization are handled and created. Instead of relying on a single, strictly-cased organization record, multiple casing formats are supported. This guarantees that
has_org()successfully resolves the organization check regardless of the casing the user uses during course creation.Test
TenantOrganizationwith an uppercase name (e.g.,MYORG).Validate the get_or_create method of the ORM allows to create
TenantOrganizationbased on the case of thenamecolumn.Before
After