Code

Ticket #6396: better_patch-6396.diff

File better_patch-6396.diff, 2.3 KB (added by Martin Diers <martin@…>, 6 years ago)

Much less intrusive patch to address this problem.

Line 
1Index: /Users/mwdiers/Documents/workspace/django-trunk/django/contrib/admin/templates/admin/change_list_results.html
2===================================================================
3--- /Users/mwdiers/Documents/workspace/django-trunk/django/contrib/admin/templates/admin/change_list_results.html       (revision 7997)
4+++ /Users/mwdiers/Documents/workspace/django-trunk/django/contrib/admin/templates/admin/change_list_results.html       (working copy)
5@@ -10,7 +10,9 @@
6 </thead>
7 <tbody>
8 {% for result in results %}
9-<tr class="{% cycle 'row1' 'row2' %}">{% for item in result %}{{ item }}{% endfor %}</tr>
10+<tr class="{% cycle 'row1' 'row2' %}">
11+{% for item in result %}<{{ item.table_tag }} {{ item.row_class }}>{% if item.url %}<a href="{{ item.url }}" {{ item.event }}>{{ item.result }}</a>{% else %}{{ item.result }}{% endif %}</{{ item.table_tag }}>{% endfor %}
12+</tr>
13 {% endfor %}
14 </tbody>
15 </table>
16Index: /Users/mwdiers/Documents/workspace/django-trunk/django/contrib/admin/templatetags/admin_list.py
17===================================================================
18--- /Users/mwdiers/Documents/workspace/django-trunk/django/contrib/admin/templatetags/admin_list.py     (revision 7997)
19+++ /Users/mwdiers/Documents/workspace/django-trunk/django/contrib/admin/templatetags/admin_list.py     (working copy)
20@@ -196,10 +196,9 @@
21             # Convert the pk to something that can be used in Javascript.
22             # Problem cases are long ints (23L) and non-ASCII strings.
23             result_id = repr(force_unicode(getattr(result, pk)))[1:]
24-            yield mark_safe(u'<%s%s><a href="%s"%s>%s</a></%s>' % \
25-                (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s); return false;"' % result_id or ''), conditional_escape(result_repr), table_tag))
26+            yield {'row_class': row_class, 'url': url, 'event': (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s); return false;"' % result_id or ''), 'result': conditional_escape(result_repr), 'table_tag': table_tag}               
27         else:
28-            yield mark_safe(u'<td%s>%s</td>' % (row_class, conditional_escape(result_repr)))
29+            yield {'row_class': row_class, 'url': '', 'event': '', 'result': conditional_escape(result_repr), 'table_tag': 'td'}               
30 
31 def results(cl):
32     for res in cl.result_list: