From b03ee49a8259d71ba98918d562203a55d8e380d7 Mon Sep 17 00:00:00 2001 From: Toby Lawrence Date: Thu, 4 Feb 2016 21:15:05 -0500 Subject: [PATCH] Fix up the excluded extensions bit. This adds the missing admin class, and registration of it, required to actually change the value of the excluded extensions configuration. --- common/djangoapps/static_replace/admin.py | 22 +++++++++++++++++++++- common/djangoapps/static_replace/models.py | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/static_replace/admin.py b/common/djangoapps/static_replace/admin.py index d475d61b2f..8d9426cf7c 100644 --- a/common/djangoapps/static_replace/admin.py +++ b/common/djangoapps/static_replace/admin.py @@ -5,7 +5,7 @@ that gets prepended to asset URLs in order to serve them from, say, a CDN. from django.contrib import admin from config_models.admin import ConfigurationModelAdmin -from .models import AssetBaseUrlConfig +from .models import AssetBaseUrlConfig, AssetExcludedExtensionsConfig class AssetBaseUrlConfigAdmin(ConfigurationModelAdmin): @@ -27,4 +27,24 @@ class AssetBaseUrlConfigAdmin(ConfigurationModelAdmin): return self.list_display +class AssetExcludedExtensionsConfigAdmin(ConfigurationModelAdmin): + """ + Basic configuration for asset base URL. + """ + list_display = [ + 'excluded_extensions' + ] + + def get_list_display(self, request): + """ + Restore default list_display behavior. + + ConfigurationModelAdmin overrides this, but in a way that doesn't + respect the ordering. This lets us customize it the usual Django admin + way. + """ + return self.list_display + + admin.site.register(AssetBaseUrlConfig, AssetBaseUrlConfigAdmin) +admin.site.register(AssetExcludedExtensionsConfig, AssetExcludedExtensionsConfigAdmin) diff --git a/common/djangoapps/static_replace/models.py b/common/djangoapps/static_replace/models.py index 514adbbe77..b3c09e3945 100644 --- a/common/djangoapps/static_replace/models.py +++ b/common/djangoapps/static_replace/models.py @@ -48,7 +48,7 @@ class AssetExcludedExtensionsConfig(ConfigurationModel): return map(add_period, cls.current().excluded_extensions.split()) def __repr__(self): - return ''.format(self.get_excluded_extensions().split()) + return ''.format(self.get_excluded_extensions()) def __unicode__(self): return unicode(repr(self))