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
|
|
1 | 1 | from functools import update_wrapper, partial |
2 | 2 | from django import forms |
| 3 | from django.conf import settings |
3 | 4 | from django.forms.formsets import all_valid |
4 | 5 | from django.forms.models import (modelform_factory, modelformset_factory, |
5 | 6 | inlineformset_factory, BaseInlineFormSet) |
… |
… |
def urls(self):
|
394 | 395 | |
395 | 396 | @property |
396 | 397 | def media(self): |
| 398 | extra = "" if settings.DEBUG else ".min" |
397 | 399 | js = [ |
398 | 400 | 'core.js', |
399 | 401 | 'admin/RelatedObjectLookups.js', |
400 | | 'jquery.min.js', |
| 402 | 'jquery%s.js' % extra, |
401 | 403 | 'jquery.init.js' |
402 | 404 | ] |
403 | 405 | if self.actions is not None: |
404 | | js.append('actions.min.js') |
| 406 | js.append('actions%s.js' % extra) |
405 | 407 | if self.prepopulated_fields: |
406 | | js.extend(['urlify.js', 'prepopulate.min.js']) |
| 408 | js.extend(['urlify.js', 'prepopulate%s.js' % extra]) |
407 | 409 | if self.opts.get_ordered_objects(): |
408 | 410 | js.extend(['getElementsBySelector.js', 'dom-drag.js' , 'admin/ordering.js']) |
409 | 411 | return forms.Media(js=[static('admin/js/%s' % url) for url in js]) |
… |
… |
def __init__(self, parent_model, admin_site):
|
1371 | 1373 | |
1372 | 1374 | @property |
1373 | 1375 | 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] |
1375 | 1378 | if self.prepopulated_fields: |
1376 | | js.extend(['urlify.js', 'prepopulate.min.js']) |
| 1379 | js.extend(['urlify.js', 'prepopulate%s.js' % extra]) |
1377 | 1380 | if self.filter_vertical or self.filter_horizontal: |
1378 | 1381 | js.extend(['SelectBox.js', 'SelectFilter2.js']) |
1379 | 1382 | return forms.Media(js=[static('admin/js/%s' % url) for url in js]) |