Ticket #2569: adminforeign.diff
File adminforeign.diff, 4.4 KB (added by , 18 years ago) |
---|
-
django/contrib/admin/media/js/admin/RelatedObjectLookups.js
36 36 } 37 37 38 38 function dismissAddAnotherPopup(win, newId, newRepr) { 39 alert(win.name); 39 40 var name = win.name.replace(/___/g, '.'); 40 41 var elem = document.getElementById(name); 41 42 if (elem) { … … 55 56 } 56 57 win.close(); 57 58 } 59 60 function showEditPopup(triggeringLink) { 61 var name = triggeringLink.id.replace(/^edit_/,''); 62 name = name.replace(/\./g,'___'); 63 var elem = document.getElementById(name); 64 if (elem) { 65 if (elem.nodeName == 'SELECT') { 66 var id = elem.options[elem.selectedIndex].value 67 var win = window.open(triggeringLink.href + id + '?_popup=1',name, 'height=500,width=800,resizable=yes,scrollbars=yes'); 68 } 69 } 70 return false; 71 } 72 73 function dismissEditPopup(win, newId, newRepr) { 74 var name = win.name.replace(/___/g, '.'); 75 var elem = document.getElementById(name); 76 if(elem) { 77 if( elem.nodeName == 'SELECT') { 78 var o = new Option(newRepr, newId); 79 elem.options[elem.selectedIndex] = o; 80 o.selected = true; 81 } 82 } 83 win.close(); 84 } -
django/contrib/admin/views/main.py
341 341 LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, pk_value, str(new_object), CHANGE, change_message) 342 342 343 343 msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': opts.verbose_name, 'obj': new_object} 344 if request.REQUEST.has_key("_popup"): 345 http_response = '<script type="text/javascript">opener.dismissEditPopup(window, %s, "%s");</script>' % \ 346 (pk_value, str(new_object).replace('"', '\\"')) 347 return HttpResponse(http_response) 344 348 if request.POST.has_key("_continue"): 345 349 request.user.message_set.create(message=msg + ' ' + _("You may edit it again below.")) 346 350 if request.REQUEST.has_key('_popup'): -
django/contrib/admin/templates/widget/one_to_one.html
1 {% load admin_modify adminmedia %} 1 2 {% if add %}{% include "widget/foreign.html" %}{% endif %} 2 {% if change %}{% if bound_field.existing_display %} <strong>{{ bound_field.existing_display|truncatewords:"14"|escape }}</strong>{% endif %}{% endif %} 3 {% if change %} 4 {% if bound_field.existing_display %} <a href="{{ bound_field.related_url }}{{ bound_field.existing_display}}"><strong>{{ bound_field.existing_display|truncatewords:"14"|escape }}</strong></a>{% endif %}{% endif %} -
django/contrib/admin/templates/widget/foreign.html
8 8 {% endif %} 9 9 {% else %} 10 10 {% if bound_field.needs_add_label %} 11 <a href="{{ bound_field.related_url }}add/" class="add-another" id="add_{{ bound_field.element_id }}" onclick="return showAddAnotherPopup(this);"> <img src="{% admin_media_prefix %}img/admin/icon_addlink.gif" width="10" height="10" alt="Add Another"/></a> 12 {% endif %}{% endif %} 11 <a href="{{ bound_field.related_url }}add/" class="add-another" id="add_{{ bound_field.element_id }}" onclick="return showAddAnotherPopup(this);"> <img src="{% admin_media_prefix %}img/admin/icon_addlink.gif" width="10" height="10" alt="Add Another"/></a> 12 <a href="{{ bound_field.related_url }}" class="related-lookup" id="edit_{{ bound_field.element_id }}" onclick="return showEditPopup(this);"> <img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a> 13 14 {% endif %} 15 {% endif %} 13 16 {% if change %} 14 17 {% if bound_field.field.primary_key %} 15 18 {{ bound_field.original_value }}