Attachment 'django_r7568_yongspatch.diff'
Download 1 Index: django/newforms/forms.py
2 ===================================================================
3 --- django/newforms/forms.py (revision 7568)
4 +++ django/newforms/forms.py (working copy)
5 @@ -148,7 +148,7 @@
6 help_text = help_text_html % force_unicode(field.help_text)
7 else:
8 help_text = u''
9 - output.append(normal_row % {'errors': force_unicode(bf_errors), 'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text})
10 + output.append(normal_row % {'errors': force_unicode(bf_errors), 'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text, 'required': field.required and '<span class="required"> * </span>' or ''})
11 if top_errors:
12 output.insert(0, error_row % force_unicode(top_errors))
13 if hidden_fields: # Insert any hidden fields in the last row.
14 @@ -166,15 +166,15 @@
15
16 def as_table(self):
17 "Returns this form rendered as HTML <tr>s -- excluding the <table></table>."
18 - return self._html_output(u'<tr><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>', u'<tr><td colspan="2">%s</td></tr>', '</td></tr>', u'<br />%s', False)
19 + return self._html_output(u'<tr><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s%(required)s</td></tr>', u'<tr><td colspan="2">%s</td></tr>', '</td></tr>', u'<br />%s', False)
20
21 def as_ul(self):
22 "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>."
23 - return self._html_output(u'<li>%(errors)s%(label)s %(field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', u' %s', False)
24 + return self._html_output(u'<li>%(errors)s%(label)s %(field)s%(help_text)s%(required)s</li>', u'<li>%s</li>', '</li>', u' %s', False)
25
26 def as_p(self):
27 "Returns this form rendered as HTML <p>s."
28 - return self._html_output(u'<p>%(label)s %(field)s%(help_text)s</p>', u'%s', '</p>', u' %s', True)
29 + return self._html_output(u'<p>%(label)s %(field)s%(help_text)s%(required)s</p>', u'%s', '</p>', u' %s', True)
30
31 def non_field_errors(self):
32 """
33 Index: django/contrib/admin/media/js/admin/RelatedObjectLookups.js
34 ===================================================================
35 --- django/contrib/admin/media/js/admin/RelatedObjectLookups.js (revision 7568)
36 +++ django/contrib/admin/media/js/admin/RelatedObjectLookups.js (working copy)
37 @@ -75,3 +75,29 @@
38 }
39 win.close();
40 }
41 +
42 +function showEditPopup(triggeringLink) {
43 + var name = triggeringLink.id.replace(/^edit_/,'');
44 + name = name.replace(/\./g,'___');
45 + var elem = document.getElementById(name);
46 + if (elem) {
47 + if (elem.nodeName == 'SELECT') {
48 + var id = elem.options[elem.selectedIndex].value
49 + var win = window.open(triggeringLink.href + id + '?_popup=1',name, 'height=500,width=800,resizable=yes,scrollbars=yes');
50 + }
51 + }
52 + return false;
53 +}
54 +
55 +function dismissEditPopup(win, newId, newRepr) {
56 + var name = win.name.replace(/___/g, '.');
57 + var elem = document.getElementById(name);
58 + if(elem) {
59 + if( elem.nodeName == 'SELECT') {
60 + var o = new Option(newRepr, newId);
61 + elem.options[elem.selectedIndex] = o;
62 + o.selected = true;
63 + }
64 + }
65 + win.close();
66 +}
67 Index: django/contrib/admin/templates/widget/one_to_one.html
68 ===================================================================
69 --- django/contrib/admin/templates/widget/one_to_one.html (revision 7568)
70 +++ django/contrib/admin/templates/widget/one_to_one.html (working copy)
71 @@ -1,2 +1,4 @@
72 +{% load admin_modify adminmedia %}
73 {% if add %}{% include "widget/foreign.html" %}{% endif %}
74 -{% if change %}{% if bound_field.existing_display %} <strong>{{ bound_field.existing_display|truncatewords:"14" }}</strong>{% endif %}{% endif %}
75 +{% if change %}
76 +{% 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 %}
77 Index: django/contrib/admin/templates/widget/foreign.html
78 ===================================================================
79 --- django/contrib/admin/templates/widget/foreign.html (revision 7568)
80 +++ django/contrib/admin/templates/widget/foreign.html (working copy)
81 @@ -8,8 +8,11 @@
82 {% endif %}
83 {% else %}
84 {% if bound_field.needs_add_label %}
85 - <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>
86 -{% endif %}{% endif %}
87 + <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>
88 + <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>
89 +
90 +{% endif %}
91 +{% endif %}
92 {% if change %}
93 {% if bound_field.field.primary_key %}
94 {{ bound_field.original_value }}
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.