Skip to content

Conversation

@jignaciopm
Copy link
Contributor

@jignaciopm jignaciopm commented Jan 18, 2026

This PR updates the eox-theming plugin to correctly inject its storage backends in compliance with Django 5.2 requirements. It ensures our custom logic for handling absolute URLs remains functional, preventing broken assets (such as logos) across the platform.

Context & Problem

In recent Django versions (5.2+), the STATICFILES_STORAGE setting has been deprecated in favor of the STORAGES dictionary. Additionally, the internal implementation of Django’s base storage .url() method was changed from using urljoin (which intelligently detected absolute URLs) to a simple string concatenation.

Because of this change, when the platform requested a static asset that was already an absolute URL (e.g., a Bragi logo hosted on S3), the upgraded Django logic was prepending the STATIC_URL prefix, resulting in broken paths like:
https://your-platform.com/static/https%3A/s3.amazonaws.com/bragi-assets/logo.png

This specifically broke the rendering of Bragi logos and other themed assets that rely on external absolute URLs.

You can see more information through:

Solution

We utilize our AbsoluteUrlAssetsMixin within the eox-theming storage classes. This mixin overrides the .url() method to:

  1. Check: If the name starts with http:// or https://.
  2. Action: Return the name immediately as-is.
  3. Fallback: If it is a relative path, proceed with standard Django/Theming resolution.

To ensure this mixin is correctly applied in modern Django versions, this PR:

  • Migrates storage injection from STATICFILES_STORAGE to the STORAGES['staticfiles'] dictionary.
  • Adds defensive initialization (hasattr and setdefault) to prevent AttributeError during tests where the settings object might be a dummy or partially initialized class.

Technical Verification & Evidence

This change has been rigorously tested:

  • Environment: Tested on Tutor Ulmo DEV.
  • Visual Confirmation: Bragi logos are now rendering correctly, bypassing the /static/ prefix.
  • LMS Shell Verification: Confirmed that the new configuration is correctly loaded into the Django settings:
In [3]: settings.STORAGES
Out[3]: 
{
  'default': {'BACKEND': 'django.core.files.storage.FileSystemStorage'},
  'staticfiles': {'BACKEND': 'eox_theming.theming.storage.EoxDevelopmentStorage'}
}

LMS + Bragi (Ulmo) Before:

image

LMS + Bragi (Ulmo) After:

image

Changes

  • Modified eox_theming/settings/common.py to populate settings.STORAGES['staticfiles'] using a non-destructive approach.
  • Fixed a traceback in the test suite where the STORAGES attribute was missing from the SettingsClass dummy object.

Impact

  • Fixed: Rendering of Bragi logos and external themed assets.
  • Compatibility: This change is only compatible with Ulmo or higher.
  • Stability: Restores the ability to run plugin tests (make test-python) without configuration errors.

Checklist for Merge

  • Tested in a remote environment
  • Updated documentation
  • Rebased master/main
  • Squashed commits

@jignaciopm jignaciopm requested a review from a team as a code owner January 18, 2026 19:47
@jignaciopm jignaciopm changed the base branch from master to jipm/update-integration-test January 19, 2026 01:41
@jignaciopm jignaciopm changed the base branch from jipm/update-integration-test to master January 19, 2026 15:20
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.

2 participants