Author: jezdez
Date: 2011-08-17 07:12:25 -0700 (Wed, 17 Aug 2011)
New Revision: 16622

Modified:
   django/trunk/django/contrib/admin/templates/admin/edit_inline/tabular.html
   django/trunk/tests/regressiontests/admin_inlines/models.py
   django/trunk/tests/regressiontests/admin_inlines/tests.py
Log:
Fixed #8190 -- Added support for a field's help text to the tabular admin 
inline. Thanks, Julien Phalip and Idan Gazit.

Modified: 
django/trunk/django/contrib/admin/templates/admin/edit_inline/tabular.html
===================================================================
--- django/trunk/django/contrib/admin/templates/admin/edit_inline/tabular.html  
2011-08-17 04:06:42 UTC (rev 16621)
+++ django/trunk/django/contrib/admin/templates/admin/edit_inline/tabular.html  
2011-08-17 14:12:25 UTC (rev 16622)
@@ -9,7 +9,9 @@
      <thead><tr>
      {% for field in inline_admin_formset.fields %}
        {% if not field.widget.is_hidden %}
-         <th{% if forloop.first %} colspan="2"{% endif %}{% if field.required 
%} class="required"{% endif %}>{{ field.label|capfirst }}</th>
+         <th{% if forloop.first %} colspan="2"{% endif %}{% if field.required 
%} class="required"{% endif %}>{{ field.label|capfirst }}
+         {% if field.help_text %}&nbsp;<img src="{% static 
"admin/img/icon-unknown.gif" %}" alt="({{ field.help_text|striptags }})" 
title="{{ field.help_text|striptags }}" />{% endif %}
+         </th>
        {% endif %}
      {% endfor %}
      {% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" 
%}</th>{% endif %}

Modified: django/trunk/tests/regressiontests/admin_inlines/models.py
===================================================================
--- django/trunk/tests/regressiontests/admin_inlines/models.py  2011-08-17 
04:06:42 UTC (rev 16621)
+++ django/trunk/tests/regressiontests/admin_inlines/models.py  2011-08-17 
14:12:25 UTC (rev 16622)
@@ -103,6 +103,32 @@
 # only Inline media
 admin.site.register(Holder3, inlines=[InnerInline3])
 
+
+# Models for ticket #8190
+
+class Holder4(models.Model):
+    dummy = models.IntegerField()
+
+class Inner4Stacked(models.Model):
+    dummy = models.IntegerField(help_text="Awesome stacked help text is 
awesome.")
+    holder = models.ForeignKey(Holder4)
+
+class Inner4Tabular(models.Model):
+    dummy = models.IntegerField(help_text="Awesome tabular help text is 
awesome.")
+    holder = models.ForeignKey(Holder4)
+
+class Inner4StackedInline(admin.StackedInline):
+    model = Inner4Stacked
+
+class Inner4TabularInline(admin.TabularInline):
+    model = Inner4Tabular
+
+class Holder4Admin(admin.ModelAdmin):
+    inlines = [Inner4StackedInline, Inner4TabularInline]
+
+admin.site.register(Holder4, Holder4Admin)
+
+
 # Models for #12749
 
 class Person(models.Model):

Modified: django/trunk/tests/regressiontests/admin_inlines/tests.py
===================================================================
--- django/trunk/tests/regressiontests/admin_inlines/tests.py   2011-08-17 
04:06:42 UTC (rev 16621)
+++ django/trunk/tests/regressiontests/admin_inlines/tests.py   2011-08-17 
14:12:25 UTC (rev 16622)
@@ -103,6 +103,16 @@
         # column cells
         self.assertContains(response, '<p>Callable in QuestionInline</p>')
 
+    def test_help_text(self):
+        """
+        Ensure that the inlines' model field help texts are displayed when
+        using both the stacked and tabular layouts.
+        Ref #8190.
+        """
+        response = 
self.client.get('/test_admin/admin/admin_inlines/holder4/add/')
+        self.assertContains(response, '<p class="help">Awesome stacked help 
text is awesome.</p>', 4)
+        self.assertContains(response, '<img 
src="/static/admin/img/icon-unknown.gif" alt="(Awesome tabular help text is 
awesome.)" title="Awesome tabular help text is awesome." />', 1)
+
 class TestInlineMedia(TestCase):
     fixtures = ['admin-views-users.xml']
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to