Ticket #3417: django-hb.diff

File django-hb.diff, 3.7 KB (added by Henry Baldursson <henry.baldursson@…>, 18 years ago)

Patch for templatetags, relevant to 0.95.1 release

  • django/contrib/admin/templatetags/admin_list.py

    diff -urN Django-0.95.1/django/contrib/admin/templatetags/admin_list.py Django-0.95.1-hb/django/contrib/admin/templatetags/admin_list.py
    old new  
    99from django.utils.translation import get_date_formats, get_partial_date_formats
    1010from django.template import Library
    1111import datetime
     12from urlparse import urljoin
    1213
    1314register = Library()
    1415
     
    148149            # Booleans are special: We use images.
    149150            elif isinstance(f, models.BooleanField) or isinstance(f, models.NullBooleanField):
    150151                BOOLEAN_MAPPING = {True: 'yes', False: 'no', None: 'unknown'}
    151                 result_repr = '<img src="%simg/admin/icon-%s.gif" alt="%s" />' % (settings.ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val)
     152                result_repr = '<img src="%simg/admin/icon-%s.gif" alt="%s" />' % (urljoin(settings.MEDIA_URL, settings.ADMIN_MEDIA_PREFIX), BOOLEAN_MAPPING[field_val], field_val)
    152153            # FloatFields are special: Zero-pad the decimals.
    153154            elif isinstance(f, models.FloatField):
    154155                if field_val is not None:
  • django/contrib/admin/templatetags/admin_modify.py

    diff -urN Django-0.95.1/django/contrib/admin/templatetags/admin_modify.py Django-0.95.1-hb/django/contrib/admin/templatetags/admin_modify.py
    old new  
    77from django.db.models.related import BoundRelatedObject
    88from django.conf import settings
    99import re
     10from urlparse import urljoin
    1011
    1112register = template.Library()
    1213
     
    2930        <script type="text/javascript" src="/media/admin/js/calendar.js">
    3031    """
    3132
    32     return '<script type="text/javascript" src="%s%s"></script>' % (settings.ADMIN_MEDIA_PREFIX, script_path)
     33    return '<script type="text/javascript" src="%s%s"></script>' % (urljoin(settings.MEDIA_URL, settings.ADMIN_MEDIA_PREFIX), script_path)
    3334include_admin_script = register.simple_tag(include_admin_script)
    3435
    3536def submit_row(context):
     
    196197    if f.rel and isinstance(f.rel, models.ManyToManyRel) and f.rel.filter_interface:
    197198        return '<script type="text/javascript">addEvent(window, "load", function(e) {' \
    198199              ' SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n' % (
    199               f.name, f.verbose_name, f.rel.filter_interface-1, settings.ADMIN_MEDIA_PREFIX)
     200              f.name, f.verbose_name, f.rel.filter_interface-1, urljoin(settings.MEDIA_URL, settings.ADMIN_MEDIA_PREFIX))
    200201    else:
    201202        return ''
    202203filter_interface_script_maybe = register.simple_tag(filter_interface_script_maybe)
  • django/contrib/admin/templatetags/adminmedia.py

    diff -urN Django-0.95.1/django/contrib/admin/templatetags/adminmedia.py Django-0.95.1-hb/django/contrib/admin/templatetags/adminmedia.py
    old new  
    11from django.template import Library
     2from urlparse import urljoin
    23
    34register = Library()
    45
    56def admin_media_prefix():
    67    """
    7     Returns the string contained in the setting ADMIN_MEDIA_PREFIX.
     8    Returns the string contained in the settings MEDIA_URL and ADMIN_MEDIA_PREFIX.
    89    """
    910    try:
    1011        from django.conf import settings
    1112    except ImportError:
    1213        return ''
    13     return settings.ADMIN_MEDIA_PREFIX
     14    return urljoin(settings.MEDIA_URL, settings.ADMIN_MEDIA_PREFIX)
    1415admin_media_prefix = register.simple_tag(admin_media_prefix)
Back to Top