Skip to content

feat: make case sensitive name org field (#262)#263

Open
johanseto wants to merge 1 commit into
masterfrom
jlc/case-sensitive-tenant-organizations-name
Open

feat: make case sensitive name org field (#262)#263
johanseto wants to merge 1 commit into
masterfrom
jlc/case-sensitive-tenant-organizations-name

Conversation

@johanseto

@johanseto johanseto commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

The Problem

In Open edX, the SiteConfiguration model is monkey-patched or tenant proxied by eox-tenant to manage data on a tenant-by-tenant basis. As part of this, the has_org(org) method—which determines if a site is associated with a specific organization—is not overridden by the tenant_wise proxy to check against the organizations stored in eox_tenant's TenantOrganizations, but the get_all_orgs() method yes.

In the original get_all_courses of OpenEdX which returns both results in the course_org_filter.
https://github.com/openedx/openedx-platform/blob/30269ea08f92b13534d48a59c0effc71f811ac68/openedx/core/djangoapps/site_configuration/models.py#L115C9-L130

image

However, this override introduced a strict case-sensitivity issue. If the org parameter passed to has_org() is in lowercase, but the corresponding TenantOrganization was originally created in uppercase (or vice versa), the match fails and the method incorrectly returns False. Because get_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.

def get_all_orgs(cls):
"""
This returns a set of orgs that are considered within all microsites and TenantConfig.
This can be used, for example, to do filtering
"""
# Check the cache first
org_filter_set = cache.get(TENANT_ALL_ORGS_CACHE_KEY)
if org_filter_set:
return org_filter_set
org_filter_set = set(TenantOrganization.objects.all().values_list("name", flat=True))
cls.set_key_to_cache(TENANT_ALL_ORGS_CACHE_KEY, org_filter_set)
return org_filter_set

Because due the casing in TenantOrganization the course_org_filter the tenantConfig only created one TenantOrganization, in this case the Uppercase, but the lower not.

2026-06-24_16-59 image

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

  1. Run migrations.
  2. Create a TenantOrganization with an uppercase name (e.g., MYORG).

Validate the get_or_create method of the ORM allows to create TenantOrganization based on the case of the name column.

Before

2026-06-22_18-44 2026-06-22_18-40

After

2026-06-22_18-46 2026-06-22_18-41

* 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)
@johanseto johanseto requested a review from a team as a code owner June 24, 2026 21:43
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.

1 participant