Skip to content

Commit

Permalink
refactor: remove Darklang middleware because it is not being used
Browse files Browse the repository at this point in the history
  • Loading branch information
luisfelipec95 committed Jul 5, 2023
1 parent e04fbb1 commit 4c03478
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 75 deletions.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions eox_tenant/edxapp_wrapper/dark_lang_middleware.py

This file was deleted.

1 change: 0 additions & 1 deletion eox_tenant/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def plugin_settings(settings):
settings.EDXMAKO_MODULE_BACKEND = 'eox_tenant.edxapp_wrapper.backends.edxmako_l_v1'
settings.UTILS_MODULE_BACKEND = 'eox_tenant.edxapp_wrapper.backends.util_h_v1'
settings.CHANGE_DOMAIN_DEFAULT_SITE_NAME = "stage.edunext.co"
settings.DARK_LANG_MIDDLEWARE = 'eox_tenant.edxapp_wrapper.backends.dark_lang_middleware_o_v1'
settings.EOX_TENANT_LOAD_PERMISSIONS = True
settings.EOX_TENANT_APPEND_LMS_MIDDLEWARE_CLASSES = False
settings.USE_EOX_TENANT = False
Expand Down
1 change: 0 additions & 1 deletion eox_tenant/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class SettingsClass:
GET_THEMING_HELPERS = 'eox_tenant.edxapp_wrapper.backends.theming_helpers_test_v1'
EOX_TENANT_USERS_BACKEND = 'eox_tenant.edxapp_wrapper.backends.users_test_v1'
EOX_TENANT_BEARER_AUTHENTICATION = 'eox_tenant.edxapp_wrapper.backends.bearer_authentication_test_v1'
DARK_LANG_MIDDLEWARE = 'eox_tenant.edxapp_wrapper.backends.dark_lang_middleware_o_test_v1'

COURSE_KEY_PATTERN = r'(?P<course_key_string>[^/+]+(/|\+)[^/+]+(/|\+)[^/?]+)'
COURSE_ID_PATTERN = COURSE_KEY_PATTERN.replace('course_key_string', 'course_id')
Expand Down
7 changes: 1 addition & 6 deletions eox_tenant/tenant_wise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from eox_tenant.constants import LMS_ENVIRONMENT
from eox_tenant.tenant_aware_functions.released_languages import tenant_languages
from eox_tenant.tenant_wise.proxies import DarkLangMiddlewareProxy, TenantSiteConfigProxy
from eox_tenant.tenant_wise.proxies import TenantSiteConfigProxy


def load_tenant_wise_overrides():
Expand Down Expand Up @@ -39,11 +39,6 @@ def load_tenant_wise_overrides():
model='released_languages',
proxy=tenant_languages
)
set_as_proxy(
modules='openedx.core.djangoapps.dark_lang.middleware',
model='DarkLangMiddleware',
proxy=DarkLangMiddlewareProxy
)


def set_as_proxy(modules, model, proxy):
Expand Down
38 changes: 0 additions & 38 deletions eox_tenant/tenant_wise/proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
from django.conf import settings
from django.core.cache import cache

from eox_tenant.edxapp_wrapper.dark_lang_middleware import get_dark_lang_middleware
from eox_tenant.edxapp_wrapper.site_configuration_module import get_site_configuration_models
from eox_tenant.models import Microsite, TenantConfig, TenantOrganization
from eox_tenant.utils import clean_serializable_values

SiteConfigurationModels = get_site_configuration_models()
DarkLangMiddleware = get_dark_lang_middleware()

TENANT_ALL_ORGS_CACHE_KEY = "tenant.all_orgs_list"
EOX_TENANT_CACHE_KEY_TIMEOUT = getattr(
Expand Down Expand Up @@ -198,39 +196,3 @@ def pre_load_values_by_org(cls, val_name):
cls.set_key_to_cache(key, result)

cls.set_key_to_cache(pre_load_value_key, True)


class DarkLangMiddlewareProxy(DarkLangMiddleware):
"""This Middleware will be used if you have FEATURES["EDNX_SITE_AWARE_LOCALE"] in True.
This take the released_languages from the site aware settings, and set a HTTP_ACCEPT_LANGUAGE if
you don't have one."""

class Meta:
""" Set as a proxy model. """
proxy = True

@property
def released_langs(self):
"""
Current list of released languages from settings.
"""

get_language_options = getattr(settings, "released_languages", "")
language_options = [lang.lower().strip() for lang in get_language_options.split(',')]
if settings.LANGUAGE_CODE not in language_options:
language_options.append(settings.LANGUAGE_CODE)
return language_options

def process_request(self, request):
"""
This will be run when you do a request, and prevent user from requesting un-released languages.
"""

# If the request doesn't have HTTP_ACCEPT_LANGUAGE, eduNEXT set it to
# settings.LANGUAGE_CODE that is site aware so that
# django.utils.locale.LocaleMiddleware can pick it up
accept = request.META.get('HTTP_ACCEPT_LANGUAGE', None)
if not accept:
request.META['HTTP_ACCEPT_LANGUAGE'] = f"{settings.LANGUAGE_CODE};q=0.1"

self._clean_accept_headers(request)

0 comments on commit 4c03478

Please sign in to comment.