Ticket #4134: django-0.96-contrib-admin-raw_id_admin-repr_on_select_change.diff
File django-0.96-contrib-admin-raw_id_admin-repr_on_select_change.diff, 2.5 KB (added by , 18 years ago) |
---|
-
media/js/admin/RelatedObjectLookups.js
11 11 } else { 12 12 href = triggeringLink.href + '?pop=1'; 13 13 } 14 var win = window.open(href, name, 'height=500,width= 800,resizable=yes,scrollbars=yes');14 var win = window.open(href, name, 'height=500,width=1000,resizable=yes,scrollbars=yes'); 15 15 win.focus(); 16 16 return false; 17 17 } 18 18 19 function dismissRelatedLookupPopup(win, chosenId ) {19 function dismissRelatedLookupPopup(win, chosenId, chosenRepr) { 20 20 var name = win.name.replace(/___/g, '.'); 21 21 var elem = document.getElementById(name); 22 22 if (elem.className.indexOf('vRawIdAdminField') != -1 && elem.value) { 23 23 elem.value += ',' + chosenId; 24 24 } else { 25 document.getElementById(name).value = chosenId; 25 var node = document.getElementById(name); 26 var parentNode = node.parentNode; 27 var strongNodes = parentNode.getElementsByTagName("strong"); 28 node.value = chosenId; 29 if (strongNodes.length==1) { 30 // change repr 31 strongNodes[0].innerHTML = chosenRepr; 32 } else if (strongNodes.length==0) { 33 // add repr 34 var strong = document.createElement("strong"); 35 strong.innerHTML = chosenRepr; 36 parentNode.appendChild(strong); 37 } 26 38 } 27 39 win.close(); 28 40 } -
templatetags/admin_list.py
8 8 from django.utils.text import capfirst 9 9 from django.utils.translation import get_date_formats, get_partial_date_formats 10 10 from django.template import Library 11 from django.template.defaultfilters import truncatewords 11 12 import datetime 12 13 13 14 register = Library() … … 187 188 url = cl.url_for_result(result) 188 189 result_id = str(getattr(result, pk)) # str() is needed in case of 23L (long ints) 189 190 yield ('<%s%s><a href="%s"%s>%s</a></%s>' % \ 190 (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r ); return false;"' % result_id or ''), result_repr, table_tag))191 (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r, %r); return false;"' % (result_id or '', escape(truncatewords(result_repr,14)))), result_repr, table_tag)) 191 192 else: 192 193 yield ('<td%s>%s</td>' % (row_class, result_repr)) 193 194