Code

Ticket #8190: 8190.tabular-inline-help-text.diff

File 8190.tabular-inline-help-text.diff, 5.4 KB (added by julien, 3 years ago)
Line 
1diff --git a/django/contrib/admin/static/admin/css/base.css b/django/contrib/admin/static/admin/css/base.css
2index 23fddaf..210e969 100644
3--- a/django/contrib/admin/static/admin/css/base.css
4+++ b/django/contrib/admin/static/admin/css/base.css
5@@ -303,6 +303,10 @@ tr.alt {
6     background: white;
7 }
8 
9+th img.help-text-tooltip {
10+    cursor: help;
11+}
12+
13 /* SORTABLE TABLES */
14 
15 thead th a:link, thead th a:visited {
16diff --git a/django/contrib/admin/static/admin/img/icon_help.gif b/django/contrib/admin/static/admin/img/icon_help.gif
17new file mode 100644
18index 0000000000000000000000000000000000000000..d7f013c99329f4e8af52025ab182baf0e0259fc6
19GIT binary patch
20literal 13286
21zcmeI3d3e)g9LF=*K*vOmiQ<_C#A9od^jO!}cAK4LsKv>K94anL(=N76Vv^Zz9#la^
22znF1cbR2W|96wi4f=uqZV1O@S`7Yc&cbcpA?>YKH+b3PCH{=t85+UIGSe15<8eLwH_
23z-*@s9Z>fVVzzVP~3`-`HyL<K}cJ(B7_H0S)*|2p-M|WcN`t7Y9o8zlG=eBjKOV<Wk
24zI%dsVQ!claNo|%uD=5MK_hm?qnCYv=D_M;Nzs|Cl%yJ=K!|VB=Ai9X&b)5t*_+7*d
25zn~(Cz9=<`SYF7A~=Bc$@bBJ^Ji86P-GseUsa)j4dJQfLyDid=NtY50<8E~&ZCJDSB
26z(LyewLVtnlV|pZo$89Fc$WbK}UP7B_i`8zo7vpA%rbx<6(q<!VXDnuhqVV)ZxbwlC
27zQ}G9wX_emeaNwVdXwWp7A<1YoYKmG+k`g3ohr^+_F`JEmFse<W#>R}IIw93$f1gTT
28z<rG2I1WCm8zHGhJsJRG2A1HIB*A<a71Bt4se~l(iijXl@CTSBzW;%mHCvd`e6rR;2
29zrB;%{?$pY?g2G27C8Xk>8XHc7D)6zET5%uC38E&c4Nh`!Wp*mrraag(-VIdIMyk|E
30zm(<cUW3_?r>;d&DXi&LN@(Y2cf0bJp+QLxgbol@%UG5}xI|FR>Z-u_lLC^ooqMyr1
31zlpB?B|6chyk`MC{Uer_|lK!ViKgR?lCBkZMA;JcEGAIO`WcJ|!=a-r_$O?!lnaSz?
32zsb}{0pxk7=AC&f~rf3i-xkwk%1!VvVM(IMjpbS94C|yVwlmRFhr3>kTG5`gmbRk_(
33z2B2V+E~E>}02GYUg>*p~fPzuFkS-_#P%ugt(gkGz3P$Ndx}Xd|!6;ow7nA`g7^Ms8
34zf-(RFqjVu%PzIo2lrE$T$^aCM(uH(E8GwROx{xj?15hwZ7t#e~018IwLb{*~K*1<o
35zNEeg=DENTs%Fmws;6-rUBMQ!S<Rt(4^N-(u>-+VWpMU!Chkf7g?fvfCo^QVX>dP<o
36z?EZY$&d)yG@yW*@efUA*{rBE|=k4upZQJ_h8(TKNzUj4BU+I3iYvW5VZs>gB`St6b
37zTl?%YPe1i!#}kh~_UI!IuX*Uf_6P1?ec!$J+<n)owv{XHyyN!P<;#}dcIz!SFIl|k
38zrW;!p-f;bb>#n_K{=BQNiqF0Bipwu+Zi+=OZPZld5?K->;n2lGLomSmxq7zlqB$2{
39zaQ^IBGiRJPy|!lBxz*=P^__jznNzAJd(Wu!oL*60=5{$T#!+f7u~{u<aHhm$EG|0r
40zl#@@IbmGJbgaJR{_~VW}=IHT99XalZ!m(pUk2-whVFe@d4?Se~u)N%%Lvk?8(3hJt
41z92<=l>&I#I136fpx2`a6)6j}VV-{?yTe;WL(rduF`xaB!_;^=)Zm4_|Hh<(W2Nf@v
42l)KZNXFDI)u8hk6p#fxhAAqyLemKEB@E}7FlePS+l+TT)>fy4j+
43
44literal 0
45HcmV?d00001
46
47diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html
48index 29db95a..b2970c6 100644
49--- a/django/contrib/admin/templates/admin/edit_inline/tabular.html
50+++ b/django/contrib/admin/templates/admin/edit_inline/tabular.html
51@@ -9,7 +9,10 @@
52      <thead><tr>
53      {% for field in inline_admin_formset.fields %}
54        {% if not field.widget.is_hidden %}
55-         <th{% if forloop.first %} colspan="2"{% endif %}{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}</th>
56+         <th{% if forloop.first %} colspan="2"{% endif %}{% if field.required %} class="required"{% endif %}>
57+            {{ field.label|capfirst }}
58+            {% if field.help_text %}&nbsp;<img class="help-text-tooltip" src="{% static "admin/img/icon_help.gif" %}" alt="({{ field.help_text|striptags }})" title="{{ field.help_text|striptags }}" />{% endif %}
59+         </th>
60        {% endif %}
61      {% endfor %}
62      {% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
63diff --git a/tests/regressiontests/admin_inlines/models.py b/tests/regressiontests/admin_inlines/models.py
64index ee0abd1..8d9ca7c 100644
65--- a/tests/regressiontests/admin_inlines/models.py
66+++ b/tests/regressiontests/admin_inlines/models.py
67@@ -103,6 +103,32 @@ admin.site.register(Holder2, HolderAdmin, inlines=[InnerInline2])
68 # only Inline media
69 admin.site.register(Holder3, inlines=[InnerInline3])
70 
71+
72+# Models for ticket #8190
73+
74+class Holder4(models.Model):
75+    dummy = models.IntegerField()
76+
77+class Inner4Stacked(models.Model):
78+    dummy = models.IntegerField(help_text="Awesome stacked help text is awesome.")
79+    holder = models.ForeignKey(Holder4)
80+
81+class Inner4Tabular(models.Model):
82+    dummy = models.IntegerField(help_text="Awesome tabular help text is awesome.")
83+    holder = models.ForeignKey(Holder4)
84+
85+class Inner4StackedInline(admin.StackedInline):
86+    model = Inner4Stacked
87+
88+class Inner4TabularInline(admin.TabularInline):
89+    model = Inner4Tabular
90+
91+class Holder4Admin(admin.ModelAdmin):
92+    inlines = [Inner4StackedInline, Inner4TabularInline]
93+
94+admin.site.register(Holder4, Holder4Admin)
95+
96+
97 # Models for #12749
98 
99 class Person(models.Model):
100diff --git a/tests/regressiontests/admin_inlines/tests.py b/tests/regressiontests/admin_inlines/tests.py
101index 067b3c5..a3223f1 100644
102--- a/tests/regressiontests/admin_inlines/tests.py
103+++ b/tests/regressiontests/admin_inlines/tests.py
104@@ -103,6 +103,16 @@ class TestInline(TestCase):
105         # column cells
106         self.assertContains(response, '<p>Callable in QuestionInline</p>')
107 
108+    def test_help_text(self):
109+        """
110+        Ensure that the inlines' model field help texts are displayed when
111+        using both the stacked and tabular layouts.
112+        Ref #8190.
113+        """
114+        response = self.client.get('/test_admin/admin/admin_inlines/holder4/add/')
115+        self.assertContains(response, '<p class="help">Awesome stacked help text is awesome.</p>', 4)
116+        self.assertContains(response, '<img class="help-text-tooltip" src="/static/admin/img/icon_help.gif" alt="(Awesome tabular help text is awesome.)" title="Awesome tabular help text is awesome." />', 1)
117+
118 class TestInlineMedia(TestCase):
119     fixtures = ['admin-views-users.xml']
120