Code

Ticket #5704: 5704-r17038.diff

File 5704-r17038.diff, 1.8 KB (added by claudep, 2 years ago)

Updated patch after media -> static renaming

Line 
1diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
2index 91b81a4..3a0ad74 100644
3--- a/django/contrib/admin/options.py
4+++ b/django/contrib/admin/options.py
5@@ -779,7 +779,9 @@ class ModelAdmin(BaseModelAdmin):
6             return HttpResponseRedirect(post_url_continue % pk_value)
7 
8         if "_popup" in request.POST:
9-            return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' % \
10+            return HttpResponse(
11+                '<!DOCTYPE html><html><head><title></title></head><body>'
12+                '<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script></body></html>' % \
13                 # escape() calls force_unicode.
14                 (escape(pk_value), escapejs(obj)))
15         elif "_addanother" in request.POST:
16diff --git a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
17index 1bc78f8..ce54fa5 100644
18--- a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
19+++ b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
20@@ -74,11 +74,12 @@ function dismissAddAnotherPopup(win, newId, newRepr) {
21     var name = windowname_to_id(win.name);
22     var elem = document.getElementById(name);
23     if (elem) {
24-        if (elem.nodeName == 'SELECT') {
25+        var elemName = elem.nodeName.toUpperCase();
26+        if (elemName == 'SELECT') {
27             var o = new Option(newRepr, newId);
28             elem.options[elem.options.length] = o;
29             o.selected = true;
30-        } else if (elem.nodeName == 'INPUT') {
31+        } else if (elemName == 'INPUT') {
32             if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
33                 elem.value += ',' + newId;
34             } else {