Ticket #19226: ticket_19226.4.diff

File ticket_19226.4.diff, 2.2 KB (added by thiderman, 12 years ago)

Patch with tests for br tags

  • django/contrib/admin/templates/admin/includes/fieldset.html

    diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html b/django/contrib/admin/templates/admin/includes/fieldset.html
    index c8d08c8..09bc971 100644
    a b  
    1414                    {% else %}
    1515                        {{ field.label_tag }}
    1616                        {% if field.is_readonly %}
    17                             <p>{{ field.contents }}</p>
     17                            <p>{{ field.contents|linebreaksbr }}</p>
    1818                        {% else %}
    1919                            {{ field.field }}
    2020                        {% endif %}
  • tests/regressiontests/admin_views/admin.py

    diff --git a/tests/regressiontests/admin_views/admin.py b/tests/regressiontests/admin_views/admin.py
    index a5476e9..6f6f1d1 100644
    a b class PrePopulatedPostAdmin(admin.ModelAdmin):  
    388388
    389389class PostAdmin(admin.ModelAdmin):
    390390    list_display = ['title', 'public']
    391     readonly_fields = ('posted', 'awesomeness_level', 'coolness', 'value', lambda obj: "foo")
     391    readonly_fields = ('posted', 'awesomeness_level', 'coolness', 'value', 'multiline', lambda obj: "foo")
    392392
    393393    inlines = [
    394394        LinkInline
    class PostAdmin(admin.ModelAdmin):  
    402402
    403403    def value(self, instance):
    404404        return 1000
     405
     406    def multiline(self, instance):
     407        return "Multiline\ntest\nstring"
     408
    405409    value.short_description = 'Value in $US'
    406410
    407411
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index 72dc6a3..b5e0f40 100644
    a b class ReadonlyTest(TestCase):  
    31493149        self.assertContains(response, "Very awesome.")
    31503150        self.assertContains(response, "Unkown coolness.")
    31513151        self.assertContains(response, "foo")
     3152
     3153        # Checks that multiline text in a readonly field gets <br /> tags
     3154        self.assertContains(response, "Multiline<br />test<br />string")
     3155
    31523156        self.assertContains(response,
    31533157            formats.localize(datetime.date.today() - datetime.timedelta(days=7))
    31543158        )
Back to Top