Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #620 -- raw_id_admin and limit_choices_to now play well togethe…

…r (thanks to David Schein)

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2414 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0df9fb8f9abdb0fbc1ba8b249ae9b71cc06af8e2 1 parent 3723f83
Jacob Kaplan-Moss authored February 27, 2006
8  django/contrib/admin/media/js/admin/RelatedObjectLookups.js
@@ -3,7 +3,13 @@
3 3
 
4 4
 function showRelatedObjectLookupPopup(triggeringLink) {
5 5
     var name = triggeringLink.id.replace(/^lookup_/, '');
6  
-    var win = window.open(triggeringLink.href + '?pop=1', name, 'height=500,width=740,resizable=yes,scrollbars=yes');
  6
+    var href
  7
+    if (triggeringLink.href.search(/\?/) >= 0) {
  8
+        href = triggeringLink.href + '&pop=1';
  9
+    } else {
  10
+        href = triggeringLink.href + '?pop=1'
  11
+    }
  12
+    var win = window.open(href, name, 'height=500,width=740,resizable=yes,scrollbars=yes');
7 13
     win.focus();
8 14
     return false;
9 15
 }
4  django/contrib/admin/templates/widget/foreign.html
... ...
@@ -1,7 +1,11 @@
1 1
 {% load admin_modify adminmedia %}
2 2
 {% output_all bound_field.form_fields %}
3 3
 {% if bound_field.raw_id_admin %}
  4
+{% if bound_field.field.rel.limit_choices_to %}
  5
+    <a href="../../../{{ bound_field.field.rel.to.app_label }}/{{ bound_field.field.rel.to.module_name }}/?{% for limit_choice in bound_field.field.rel.limit_choices_to.items %}{% if not forloop.first %}{{"&"|escape}}{% endif %}{{ limit_choice|join:"=" }}{% endfor %}" class="related-lookup" id="lookup_{{ bound_field.element_id }}" onclick="return showRelatedObjectLookupPopup(this);"> <img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a>
  6
+{% else %}
4 7
     <a href="../../../{{ bound_field.field.rel.to.app_label }}/{{ bound_field.field.rel.to.module_name }}/" class="related-lookup" id="lookup_{{ bound_field.element_id }}" onclick="return showRelatedObjectLookupPopup(this);"> <img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a>
  8
+{% endif %}
5 9
 {% else %}
6 10
 {% if bound_field.needs_add_label %}
7 11
     <a href="../../../{{ bound_field.field.rel.to.app_label }}/{{ bound_field.field.rel.to.module_name }}/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>

0 notes on commit 0df9fb8

Please sign in to comment.
Something went wrong with that request. Please try again.