Ticket #19226: ticket_19226.3.diff

File ticket_19226.3.diff, 2.7 KB (added by Lebedev Ilya, 12 years ago)
  • 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..e13385f 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_capatible', 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_capatible:
     407        return "Positive\n multiline\n capatible"
     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..da88f79 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 correct multiline text for readonly field
     3154        self.assertContains(response, "Positive\n multiline\n capatible")
     3155       
    31523156        self.assertContains(response,
    31533157            formats.localize(datetime.date.today() - datetime.timedelta(days=7))
    31543158        )
    class ReadonlyTest(TestCase):  
    31663170        p = Post.objects.create(title="I worked on readonly_fields", content="Its good stuff")
    31673171        response = self.client.get('/test_admin/admin/admin_views/post/%d/' % p.pk)
    31683172        self.assertContains(response, "%d amount of cool" % p.pk)
    3169 
     3173        self.assertContains(response, new_post_title)
     3174       
    31703175    def test_readonly_post(self):
    31713176        data = {
    31723177            "title": "Django Got Readonly Fields",
Back to Top