Ticket #18388: ticket_18338.diff

File ticket_18338.diff, 2.8 KB (added by Lebedev Ilya, 12 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 19c212d..7a5e93c 100644
    a b class InlineModelAdmin(BaseModelAdmin):  
    14671467            "fields": fields,
    14681468            "exclude": exclude,
    14691469            "formfield_callback": partial(self.formfield_for_dbfield, request=request),
    1470             "extra": self.extra,
    1471             "max_num": self.max_num,
     1470            "extra": self.get_extra(),
     1471            "max_num": self.get_max_num(),
    14721472            "can_delete": can_delete,
    14731473        }
    14741474        defaults.update(kwargs)
    class InlineModelAdmin(BaseModelAdmin):  
    15191519        return request.user.has_perm(
    15201520            self.opts.app_label + '.' + self.opts.get_delete_permission())
    15211521
     1522    def get_extra(self):
     1523        return self.extra
     1524
     1525    def get_max_num(self):
     1526        return self.max_num
     1527
    15221528
    15231529class StackedInline(InlineModelAdmin):
    15241530    template = 'admin/edit_inline/stacked.html'
  • 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/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index 72dc6a3..1bbf60f 100644
    a b class ReadonlyTest(TestCase):  
    31633163        self.assertContains(response, '<p class="help">Some help text for the content (with unicode ŠĐĆŽćžšđ)</p>', html=True)
    31643164        self.assertContains(response, '<p class="help">Some help text for the date (with unicode ŠĐĆŽćžšđ)</p>', html=True)
    31653165
    3166         p = Post.objects.create(title="I worked on readonly_fields", content="Its good stuff")
     3166        new_post_title = "I worked on\n multiline\n readonly_fields"
     3167        p = Post.objects.create(title=new_post_title, content="Its good stuff")
    31673168        response = self.client.get('/test_admin/admin/admin_views/post/%d/' % p.pk)
    31683169        self.assertContains(response, "%d amount of cool" % p.pk)
    3169 
     3170        self.assertContains(response, new_post_title)
     3171       
    31703172    def test_readonly_post(self):
    31713173        data = {
    31723174            "title": "Django Got Readonly Fields",
Back to Top