admin.py 1.42 KB
Newer Older
1 2 3 4
"""
Django admin page for AssetBaseUrlConfig, which allows you to set the base URL
that gets prepended to asset URLs in order to serve them from, say, a CDN.
"""
5
from config_models.admin import ConfigurationModelAdmin
6 7
from django.contrib import admin

8
from .models import AssetBaseUrlConfig, AssetExcludedExtensionsConfig
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29


class AssetBaseUrlConfigAdmin(ConfigurationModelAdmin):
    """
    Basic configuration for asset base URL.
    """
    list_display = [
        'base_url'
    ]

    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


30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
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


49
admin.site.register(AssetBaseUrlConfig, AssetBaseUrlConfigAdmin)
50
admin.site.register(AssetExcludedExtensionsConfig, AssetExcludedExtensionsConfigAdmin)