Ticket #19609: 19609.diff

File 19609.diff, 4.6 KB (added by glic3rinu, 2 years ago)
  • AUTHORS

    diff --git a/AUTHORS b/AUTHORS
    index 070ec70..844038c 100644
    a b answer newbie questions, and generally made Django that much better: 
    589589    Gasper Zejn <zejn@kiberpipa.org>
    590590    Jarek Zgoda <jarek.zgoda@gmail.com>
    591591    Cheng Zhang
     592    Marc Aymerich Gubern
    592593
    593594A big THANK YOU goes to:
    594595
  • django/contrib/admin/helpers.py

    diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
    index 4203287..be66b0d 100644
    a b class InlineAdminFormSet(object): 
    225225    def fields(self):
    226226        fk = getattr(self.formset, "fk", None)
    227227        for i, field in enumerate(flatten_fieldsets(self.fieldsets)):
     228            if callable(field):
     229                class_name = field.__name__ != '<lambda>' and field.__name__ or ''
     230            else:
     231                class_name = field
    228232            if fk and fk.name == field:
    229233                continue
    230234            if field in self.readonly_fields:
    class InlineAdminFormSet(object): 
    233237                    'widget': {
    234238                        'is_hidden': False
    235239                    },
    236                     'required': False
     240                    'required': False,
     241                    'help_text': help_text_for_field(class_name, self.opts.model),
    237242                }
    238243            else:
    239244                yield self.formset.form.base_fields[field]
  • tests/regressiontests/admin_inlines/admin.py

    diff --git a/tests/regressiontests/admin_inlines/admin.py b/tests/regressiontests/admin_inlines/admin.py
    index 536c3ec..d252457 100644
    a b class HolderAdmin(admin.ModelAdmin): 
    2828        js = ('my_awesome_admin_scripts.js',)
    2929
    3030
     31class ROnlyInlineInline(admin.TabularInline):
     32    model = ROnlyInline
     33    readonly_fields = ['name']
     34
     35
    3136class InnerInline2(admin.StackedInline):
    3237    model = Inner2
    3338
    site.register(Novel, NovelAdmin) 
    142147site.register(Fashionista, inlines=[InlineWeakness])
    143148site.register(Holder4, Holder4Admin)
    144149site.register(Author, AuthorAdmin)
    145 site.register(CapoFamiglia, inlines=[ConsigliereInline, SottoCapoInline])
     150site.register(CapoFamiglia, inlines=[ConsigliereInline, SottoCapoInline, ROnlyInlineInline])
    146151site.register(ProfileCollection, inlines=[ProfileInline])
    147152site.register(ParentModelWithCustomPk, inlines=[ChildModel1Inline, ChildModel2Inline])
    148153site.register(ExtraTerrestrial, inlines=[SightingInline])
  • tests/regressiontests/admin_inlines/models.py

    diff --git a/tests/regressiontests/admin_inlines/models.py b/tests/regressiontests/admin_inlines/models.py
    index 147873a..ad7230c 100644
    a b class Novel(models.Model): 
    130130class Chapter(models.Model):
    131131    novel = models.ForeignKey(Novel)
    132132
    133 
    134133# Models for #16838
    135134
    136135class CapoFamiglia(models.Model):
    class CapoFamiglia(models.Model): 
    138137
    139138
    140139class Consigliere(models.Model):
    141     name = models.CharField(max_length=100)
     140    name = models.CharField(max_length=100, help_text='Help text for Consigliere')
    142141    capo_famiglia = models.ForeignKey(CapoFamiglia, related_name='+')
    143142
    144143
    class SottoCapo(models.Model): 
    146145    name = models.CharField(max_length=100)
    147146    capo_famiglia = models.ForeignKey(CapoFamiglia, related_name='+')
    148147
     148
     149class ROnlyInline(models.Model):
     150    name = models.CharField(max_length=100, help_text='Help text for ROnlyInline')
     151    capo_famiglia = models.ForeignKey(CapoFamiglia)
     152
     153
    149154# Models for #18433
    150155
    151156class ParentModelWithCustomPk(models.Model):
  • tests/regressiontests/admin_inlines/tests.py

    diff --git a/tests/regressiontests/admin_inlines/tests.py b/tests/regressiontests/admin_inlines/tests.py
    index 54283bf..3e3889c 100644
    a b class TestInline(TestCase): 
    122122        response = self.client.get('/admin/admin_inlines/holder4/add/')
    123123        self.assertContains(response, '<p class="help">Awesome stacked help text is awesome.</p>', 4)
    124124        self.assertContains(response, '<img src="/static/admin/img/icon-unknown.gif" class="help help-tooltip" width="10" height="10" alt="(Awesome tabular help text is awesome.)" title="Awesome tabular help text is awesome." />', 1)
     125        # ronly fields
     126        response = self.client.get('/admin/admin_inlines/capofamiglia/add/')
     127        self.assertContains(response, '<img src="/static/admin/img/icon-unknown.gif" class="help help-tooltip" width="10" height="10" alt="(Help text for ROnlyInline)" title="Help text for ROnlyInline" />', 1)
     128
    125129
    126130    def test_non_related_name_inline(self):
    127131        """
Back to Top