mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
470db1208d
commit
68baafc110
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||||
<title>{% block title %}{% endblock %}</title>
|
<title>{% block title %}{% endblock %}</title>
|
||||||
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}/m/css/base.css{% endblock %}" />
|
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/base.css{% endblock %}" />
|
||||||
{% block extrastyle %}{% endblock %}
|
{% block extrastyle %}{% endblock %}
|
||||||
{% block extrahead %}{% endblock %}
|
{% block extrahead %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -54,6 +54,11 @@ AUTH_SESSION_COOKIE = 'rizzo'
|
||||||
# List of locations of the template source files, in search order.
|
# List of locations of the template source files, in search order.
|
||||||
TEMPLATE_DIRS = ()
|
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
|
# Default e-mail address to use for various automated correspondence from
|
||||||
# the site managers.
|
# the site managers.
|
||||||
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
|
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
|
||||||
|
|
|
@ -10,3 +10,8 @@ MIDDLEWARE_CLASSES = (
|
||||||
'django.middleware.admin.AdminUserRequired',
|
'django.middleware.admin.AdminUserRequired',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'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/'
|
||||||
|
|
|
@ -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)
|
|
@ -7,6 +7,7 @@ from django.models.auth import log
|
||||||
from django.utils.html import strip_tags
|
from django.utils.html import strip_tags
|
||||||
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
|
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
|
||||||
from django.utils.text import get_text_list
|
from django.utils.text import get_text_list
|
||||||
|
from django.conf.settings import ADMIN_MEDIA_PREFIX
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
# Text to display within changelist table cells if the value is blank.
|
# 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.
|
# Search form.
|
||||||
if lookup_opts.admin.search_fields:
|
if lookup_opts.admin.search_fields:
|
||||||
raw_template.append('<div id="toolbar">\n<form id="changelist-search" action="" method="get">\n')
|
raw_template.append('<div id="toolbar">\n<form id="changelist-search" action="" method="get">\n')
|
||||||
raw_template.append('<label><img src="/m/img/admin/icon_searchbox.png" /></label> ')
|
raw_template.append('<label><img src="%simg/admin/icon_searchbox.png" /></label> ' % ADMIN_MEDIA_PREFIX)
|
||||||
raw_template.append('<input type="text" size="40" name="%s" value="%s" id="searchbar" /> ' % \
|
raw_template.append('<input type="text" size="40" name="%s" value="%s" id="searchbar" /> ' % \
|
||||||
(SEARCH_VAR, escape(query)))
|
(SEARCH_VAR, escape(query)))
|
||||||
raw_template.append('<input type="submit" value="Go" /> ')
|
raw_template.append('<input type="submit" value="Go" /> ')
|
||||||
|
@ -407,7 +408,7 @@ def change_list(request, app_label, module_name):
|
||||||
# Booleans are special: We use images.
|
# Booleans are special: We use images.
|
||||||
elif isinstance(f, meta.BooleanField) or isinstance(f, meta.NullBooleanField):
|
elif isinstance(f, meta.BooleanField) or isinstance(f, meta.NullBooleanField):
|
||||||
BOOLEAN_MAPPING = {True: 'yes', False: 'no', None: 'unknown'}
|
BOOLEAN_MAPPING = {True: 'yes', False: 'no', None: 'unknown'}
|
||||||
result_repr = '<img src="/m/img/admin/icon-%s.gif" alt="%s" />' % (BOOLEAN_MAPPING[field_val], field_val)
|
result_repr = '<img src="%simg/admin/icon-%s.gif" alt="%s" />' % (ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val)
|
||||||
# ImageFields are special: Use a thumbnail.
|
# ImageFields are special: Use a thumbnail.
|
||||||
elif isinstance(f, meta.ImageField):
|
elif isinstance(f, meta.ImageField):
|
||||||
from django.parts.media.photos import get_thumbnail_url
|
from django.parts.media.photos import get_thumbnail_url
|
||||||
|
@ -536,15 +537,15 @@ def _get_template(opts, app_label, add=False, change=False, show_delete=False, f
|
||||||
t.append('{% block extrahead %}')
|
t.append('{% block extrahead %}')
|
||||||
|
|
||||||
# Put in any necessary JavaScript imports.
|
# Put in any necessary JavaScript imports.
|
||||||
javascript_imports = ['/m/js/core.js', '/m/js/admin/RelatedObjectLookups.js']
|
javascript_imports = ['%sjs/core.js' % ADMIN_MEDIA_PREFIX, '%sjs/admin/RelatedObjectLookups.js' % ADMIN_MEDIA_PREFIX]
|
||||||
if 'collapse' in ' '.join([f[1].get('classes', '') for f in opts.admin.fields]):
|
if 'collapse' in ' '.join([f[1].get('classes', '') for f in opts.admin.fields]):
|
||||||
javascript_imports.append('/m/js/admin/CollapsedFieldsets.js')
|
javascript_imports.append('%sjs/admin/CollapsedFieldsets.js' % ADMIN_MEDIA_PREFIX)
|
||||||
if auto_populated_fields:
|
if auto_populated_fields:
|
||||||
javascript_imports.append('/m/js/urlify.js')
|
javascript_imports.append('%sjs/urlify.js' % ADMIN_MEDIA_PREFIX)
|
||||||
if opts.has_field_type(meta.DateTimeField) or opts.has_field_type(meta.TimeField) or opts.has_field_type(meta.DateField):
|
if opts.has_field_type(meta.DateTimeField) or opts.has_field_type(meta.TimeField) or opts.has_field_type(meta.DateField):
|
||||||
javascript_imports.extend(['/m/js/calendar.js', '/m/js/admin/DateTimeShortcuts.js'])
|
javascript_imports.extend(['%sjs/calendar.js' % ADMIN_MEDIA_PREFIX, '%sjs/admin/DateTimeShortcuts.js' % ADMIN_MEDIA_PREFIX])
|
||||||
if ordered_objects:
|
if ordered_objects:
|
||||||
javascript_imports.extend(['/m/js/getElementsBySelector.js', '/m/js/dom-drag.js', '/m/js/admin/ordering.js'])
|
javascript_imports.extend(['%sjs/getElementsBySelector.js' % ADMIN_MEDIA_PREFIX, '%sjs/dom-drag.js' % ADMIN_MEDIA_PREFIX, '%sjs/admin/ordering.js' % ADMIN_MEDIA_PREFIX])
|
||||||
if opts.admin.js:
|
if opts.admin.js:
|
||||||
javascript_imports.extend(opts.admin.js)
|
javascript_imports.extend(opts.admin.js)
|
||||||
for _, options in opts.admin.fields:
|
for _, options in opts.admin.fields:
|
||||||
|
@ -552,7 +553,7 @@ def _get_template(opts, app_label, add=False, change=False, show_delete=False, f
|
||||||
for field_list in options['fields']:
|
for field_list in options['fields']:
|
||||||
for f in field_list:
|
for f in field_list:
|
||||||
if f.rel and isinstance(f, meta.ManyToManyField) and f.rel.filter_interface:
|
if f.rel and isinstance(f, meta.ManyToManyField) and f.rel.filter_interface:
|
||||||
javascript_imports.extend(['/m/js/SelectBox.js', '/m/js/SelectFilter2.js'])
|
javascript_imports.extend(['%sjs/SelectBox.js' % ADMIN_MEDIA_PREFIX, '%sjs/SelectFilter2.js' % ADMIN_MEDIA_PREFIX])
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
break
|
break
|
||||||
|
@ -737,7 +738,7 @@ def _get_admin_field_form_widget(field, name_prefix, rel, add, change):
|
||||||
if use_raw_id_admin(field):
|
if use_raw_id_admin(field):
|
||||||
t.append(' <a href="../../../%s/%s/" class="related-lookup" id="lookup_%s" onclick="return showRelatedObjectLookupPopup(this);">' % \
|
t.append(' <a href="../../../%s/%s/" class="related-lookup" id="lookup_%s" onclick="return showRelatedObjectLookupPopup(this);">' % \
|
||||||
(field.rel.to.app_label, field.rel.to.module_name, field_id))
|
(field.rel.to.app_label, field.rel.to.module_name, field_id))
|
||||||
t.append('<img src="/m/img/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a>')
|
t.append('<img src="%simg/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a>' % ADMIN_MEDIA_PREFIX)
|
||||||
# fields with relationships to editable objects get an "add another" link,
|
# fields with relationships to editable objects get an "add another" link,
|
||||||
# but only if the field doesn't have raw_admin ('cause in that case they get
|
# but only if the field doesn't have raw_admin ('cause in that case they get
|
||||||
# the "add" button in the popup)
|
# the "add" button in the popup)
|
||||||
|
@ -745,7 +746,7 @@ def _get_admin_field_form_widget(field, name_prefix, rel, add, change):
|
||||||
t.append('{%% if perms.%s.%s %%}' % (field.rel.to.app_label, field.rel.to.get_add_permission()))
|
t.append('{%% if perms.%s.%s %%}' % (field.rel.to.app_label, field.rel.to.get_add_permission()))
|
||||||
t.append(' <a href="../../../%s/%s/add/" class="add-another" id="add_%s" onclick="return showAddAnotherPopup(this);">' % \
|
t.append(' <a href="../../../%s/%s/add/" class="add-another" id="add_%s" onclick="return showAddAnotherPopup(this);">' % \
|
||||||
(field.rel.to.app_label, field.rel.to.module_name, field_id))
|
(field.rel.to.app_label, field.rel.to.module_name, field_id))
|
||||||
t.append('<img src="/m/img/admin/icon_addlink.gif" width="10" height="10" alt="Add Another" /></a>')
|
t.append('<img src="%simg/admin/icon_addlink.gif" width="10" height="10" alt="Add Another" /></a>' % ADMIN_MEDIA_PREFIX)
|
||||||
t.append('{% endif %}')
|
t.append('{% endif %}')
|
||||||
return ''.join(t)
|
return ''.join(t)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue