Ticket #17521: fix-js-for-debug-v1.patch

File fix-js-for-debug-v1.patch, 2.4 KB (added by tswicegood, 3 years ago)
  • django/contrib/admin/options.py

    From 919ce0aabb7a390952eaf724412c37bdefe68ad5 Mon Sep 17 00:00:00 2001
    From: Travis Swicegood <development@domain51.com>
    Date: Mon, 9 Jan 2012 11:56:12 -0600
    Subject: [PATCH] Only use minified JavaScript when DEBUG is off
    
    This makes it easier to inspect the code that is being used when trying
    to track down a problem in the JavaScript.
    ---
     django/contrib/admin/options.py |   13 ++++++++-----
     1 files changed, 8 insertions(+), 5 deletions(-)
    
    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 3a0ad74..ee4ff97 100644
    a b  
    11from functools import update_wrapper, partial
    22from django import forms
     3from django.conf import settings
    34from django.forms.formsets import all_valid
    45from django.forms.models import (modelform_factory, modelformset_factory,
    56    inlineformset_factory, BaseInlineFormSet)
    def urls(self): 
    394395
    395396    @property
    396397    def media(self):
     398        extra = "" if settings.DEBUG else ".min"
    397399        js = [
    398400            'core.js',
    399401            'admin/RelatedObjectLookups.js',
    400             'jquery.min.js',
     402            'jquery%s.js' % extra,
    401403            'jquery.init.js'
    402404        ]
    403405        if self.actions is not None:
    404             js.append('actions.min.js')
     406            js.append('actions%s.js' % extra)
    405407        if self.prepopulated_fields:
    406             js.extend(['urlify.js', 'prepopulate.min.js'])
     408            js.extend(['urlify.js', 'prepopulate%s.js' % extra])
    407409        if self.opts.get_ordered_objects():
    408410            js.extend(['getElementsBySelector.js', 'dom-drag.js' , 'admin/ordering.js'])
    409411        return forms.Media(js=[static('admin/js/%s' % url) for url in js])
    def __init__(self, parent_model, admin_site): 
    13711373
    13721374    @property
    13731375    def media(self):
    1374         js = ['jquery.min.js', 'jquery.init.js', 'inlines.min.js']
     1376        extra = "" if settings.DEBUG else ".min"
     1377        js = ['jquery%s.js' % extra, 'jquery.init.js', "inlines%s.js" % extra]
    13751378        if self.prepopulated_fields:
    1376             js.extend(['urlify.js', 'prepopulate.min.js'])
     1379            js.extend(['urlify.js', 'prepopulate%s.js' % extra])
    13771380        if self.filter_vertical or self.filter_horizontal:
    13781381            js.extend(['SelectBox.js', 'SelectFilter2.js'])
    13791382        return forms.Media(js=[static('admin/js/%s' % url) for url in js])
Back to Top