Ticket #13038: bug13038.patch
File bug13038.patch, 3.3 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/helpers.py
128 128 129 129 class AdminReadonlyField(object): 130 130 def __init__(self, form, field, is_first, model_admin=None): 131 self.field = field131 self.field_name = field 132 132 self.form = form 133 133 self.model_admin = model_admin 134 134 self.is_first = is_first … … 140 140 if not self.is_first: 141 141 attrs["class"] = "inline" 142 142 name = forms.forms.pretty_name( 143 label_for_field(self.field , self.model_admin.model, self.model_admin)143 label_for_field(self.field_name, self.model_admin.model, self.model_admin) 144 144 ) 145 145 contents = force_unicode(escape(name)) + u":" 146 146 return mark_safe('<label%(attrs)s>%(contents)s</label>' % { … … 151 151 def contents(self): 152 152 from django.contrib.admin.templatetags.admin_list import _boolean_icon 153 153 from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE 154 field, obj, model_admin = self.field , self.form.instance, self.model_admin154 field, obj, model_admin = self.field_name, self.form.instance, self.model_admin 155 155 try: 156 156 f, attr, value = lookup_field(field, obj, model_admin) 157 157 except (AttributeError, ObjectDoesNotExist): … … 323 323 del data_dict[key] 324 324 data_dict[str(key)] = value 325 325 return data_dict 326 -
django/contrib/admin/templates/admin/includes/fieldset.html
4 4 <div class="description">{{ fieldset.description|safe }}</div> 5 5 {% endif %} 6 6 {% for line in fieldset %} 7 <div class="form-row{% if line.errors %} errors{% endif %} {% for field in line %}{{ field.field.name }} {% endfor %}">7 <div class="form-row{% if line.errors %} errors{% endif %}{% for field in line %} {% if field.is_readonly %}{{ field.field_name }}{% else %}{{ field.field.name }}{% endif %}{% endfor %}"> 8 8 {{ line.errors }} 9 9 {% for field in line %} 10 10 <div{% if not line.fields|length_is:"1" %} class="field-box"{% endif %}> -
tests/regressiontests/admin_views/tests.py
1944 1944 formats.localize(datetime.date.today() - datetime.timedelta(days=7)) 1945 1945 ) 1946 1946 1947 self.assertContains(response, '<div class="form-row coolness">') 1948 self.assertContains(response, '<div class="form-row awesomeness_level">') 1949 self.assertContains(response, '<div class="form-row posted">') 1950 self.assertContains(response, '<div class="form-row ">') 1951 1947 1952 p = Post.objects.create(title="I worked on readonly_fields", content="Its good stuff") 1948 1953 response = self.client.get('/test_admin/admin/admin_views/post/%d/' % p.pk) 1949 1954 self.assertContains(response, "%d amount of cool" % p.pk)