Ticket #13599: separate_hidden_fields.patch
File separate_hidden_fields.patch, 3.1 KB (added by , 14 years ago) |
---|
-
django/contrib/admin/templates/admin/change_list_results.html
1 {% if result_hidden_fields %} 2 <div style="display: none"> {# DIV for HTML validation #} 3 {% for item in result_hidden_fields %}{{ item }}{% endfor %} 4 </div> 5 {% endif %} 1 6 {% if results %} 2 7 <table cellspacing="0" id="result_list"> 3 8 <thead> -
django/contrib/admin/templatetags/admin_list.py
189 189 else: 190 190 result_repr = conditional_escape(result_repr) 191 191 yield mark_safe(u'<td%s>%s</td>' % (row_class, result_repr)) 192 if form :192 if form and not form[cl.model._meta.pk.name].is_hidden: 193 193 yield mark_safe(u'<td>%s</td>' % force_unicode(form[cl.model._meta.pk.name])) 194 194 195 195 def results(cl): … … 200 200 for res in cl.result_list: 201 201 yield list(items_for_result(cl, res, None)) 202 202 203 def result_hidden_fields(cl): 204 if cl.formset: 205 for res, form in zip(cl.result_list, cl.formset.forms): 206 if form[cl.model._meta.pk.name].is_hidden: 207 yield mark_safe(force_unicode(form[cl.model._meta.pk.name])) 208 203 209 def result_list(cl): 204 210 """ 205 211 Displays the headers and data list together 206 212 """ 207 213 return {'cl': cl, 214 'result_hidden_fields': list(result_hidden_fields(cl)), 208 215 'result_headers': list(result_headers(cl)), 209 216 'results': list(results(cl))} 210 217 result_list = register.inclusion_tag("admin/change_list_results.html")(result_list) -
tests/regressiontests/admin_changelist/tests.py
37 37 hidden_input_elem = '<input type="hidden" name="form-0-id" value="1" id="id_form-0-id" />' 38 38 self.failIf(table_output.find(hidden_input_elem) == -1, 39 39 'Failed to find expected hidden input element in: %s' % table_output) 40 self.failIf(table_output.find('<td>%s</td>' % hidden_input_elem) == -1,41 'Hidden input element is not enclosed in <td> element.')42 40 43 41 # Test with list_editable fields 44 42 m.list_display = ['id', 'name', 'parent'] … … 54 52 table_output = template.render(context) 55 53 self.failIf(table_output.find(hidden_input_elem) == -1, 56 54 'Failed to find expected hidden input element in: %s' % table_output) 57 self.failIf(table_output.find('<td>%s</td>' % hidden_input_elem) == -1,58 'Hidden input element is not enclosed in <td> element.')59 55 60 56 class ChildAdmin(admin.ModelAdmin): 61 57 list_display = ['name', 'parent']