From 68baafc1100ceae5c8073975f8561e101a4ec1a4 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 16 Jul 2005 16:38:28 +0000 Subject: [PATCH] Added ADMIN_MEDIA_PREFIX setting instead of hard-coding /m/ git-svn-id: http://code.djangoproject.com/svn/django/trunk@108 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/conf/admin_templates/base.html | 2 +- django/conf/global_settings.py | 5 +++++ .../conf/project_template/settings/admin.py | 5 +++++ django/templatetags/adminmedia.py | 18 ++++++++++++++++ django/views/admin/main.py | 21 ++++++++++--------- 5 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 django/templatetags/adminmedia.py diff --git a/django/conf/admin_templates/base.html b/django/conf/admin_templates/base.html index a977d202e29..dc0b18faef4 100644 --- a/django/conf/admin_templates/base.html +++ b/django/conf/admin_templates/base.html @@ -3,7 +3,7 @@ {% block title %}{% endblock %} - + {% block extrastyle %}{% endblock %} {% block extrahead %}{% endblock %} diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index ebf6a46ceb7..1c5c589ed5c 100644 --- a/django/conf/global_settings.py +++ b/django/conf/global_settings.py @@ -54,6 +54,11 @@ AUTH_SESSION_COOKIE = 'rizzo' # List of locations of the template source files, in search order. TEMPLATE_DIRS = () +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = '/media/' + # Default e-mail address to use for various automated correspondence from # the site managers. DEFAULT_FROM_EMAIL = 'webmaster@localhost' diff --git a/django/conf/project_template/settings/admin.py b/django/conf/project_template/settings/admin.py index 0cd2cb6c553..405a5ebad8c 100644 --- a/django/conf/project_template/settings/admin.py +++ b/django/conf/project_template/settings/admin.py @@ -10,3 +10,8 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.admin.AdminUserRequired', 'django.middleware.common.CommonMiddleware', ) + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = '/media/' diff --git a/django/templatetags/adminmedia.py b/django/templatetags/adminmedia.py new file mode 100644 index 00000000000..a3f2dd9ca92 --- /dev/null +++ b/django/templatetags/adminmedia.py @@ -0,0 +1,18 @@ +from django.core import template + +class AdminMediaPrefixNode(template.Node): + def render(self, context): + try: + from django.conf.settings import ADMIN_MEDIA_PREFIX + except ImportError: + return '' + return ADMIN_MEDIA_PREFIX + +def admin_media_prefix(parser, token): + """ + {% admin_media_prefix %} + """ + bits = token.contents.split() + return AdminMediaPrefixNode() + +template.register_tag('admin_media_prefix', admin_media_prefix) diff --git a/django/views/admin/main.py b/django/views/admin/main.py index 2138f070660..39ed83f9025 100644 --- a/django/views/admin/main.py +++ b/django/views/admin/main.py @@ -7,6 +7,7 @@ from django.models.auth import log from django.utils.html import strip_tags from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect from django.utils.text import get_text_list +from django.conf.settings import ADMIN_MEDIA_PREFIX import operator # Text to display within changelist table cells if the value is blank. @@ -276,7 +277,7 @@ def change_list(request, app_label, module_name): # Search form. if lookup_opts.admin.search_fields: raw_template.append('
\n