Ticket #13223: 13223.templatefix.diff
File 13223.templatefix.diff, 5.0 KB (added by , 14 years ago) |
---|
-
AUTHORS
diff --git a/AUTHORS b/AUTHORS index a32e0d6..5c794c4 100644
a b answer newbie questions, and generally made Django that much better: 342 342 mattycakes@gmail.com 343 343 Glenn Maynard <glenn@zewt.org> 344 344 Jason McBrayer <http://www.carcosa.net/jason/> 345 Kevin McCarthy <me@kevinmccarthy.org> 345 346 Kevin McConnell <kevin.mcconnell@gmail.com> 346 347 mccutchen@gmail.com 347 348 michael.mcewan@gmail.com -
django/contrib/admin/options.py
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index c603210..8c3604f 100644
a b class ModelAdmin(BaseModelAdmin): 942 942 'errors': helpers.AdminErrorList(form, formsets), 943 943 'root_path': self.admin_site.root_path, 944 944 'app_label': opts.app_label, 945 'saveasnew': "_saveasnew" in request.POST, 945 946 } 946 947 context.update(extra_context or {}) 947 948 return self.render_change_form(request, context, form_url=form_url, add=True) -
django/contrib/admin/templates/admin/change_form.html
diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html index b32f76d..088e458 100644
a b 63 63 64 64 {% submit_row %} 65 65 66 {% if saveasnew %}<input type="hidden" value="_saveasnew" name="_saveasnew">{% endif %} 67 66 68 {% if adminform and add %} 67 69 <script type="text/javascript">document.getElementById("{{ adminform.first_field.id_for_label }}").focus();</script> 68 70 {% endif %} -
tests/regressiontests/admin_inlines/models.py
diff --git a/tests/regressiontests/admin_inlines/models.py b/tests/regressiontests/admin_inlines/models.py index ee0abd1..3101029 100644
a b class NovelAdmin(admin.ModelAdmin): 191 191 192 192 admin.site.register(Poll, PollAdmin) 193 193 admin.site.register(Novel, NovelAdmin) 194 195 # Models for #13223 196 class Post(models.Model): 197 title = models.CharField(max_length=200) 198 slug = models.CharField(max_length=200, unique = True) 199 200 class Block(models.Model): 201 post = models.ForeignKey(Post) 202 slug = models.CharField(max_length=200, unique = True) 203 204 class BlockInline(admin.TabularInline): 205 model = Block 206 207 class PostAdmin(admin.ModelAdmin): 208 save_as = True 209 inlines = [BlockInline] 210 211 admin.site.register(Post,PostAdmin) -
tests/regressiontests/admin_inlines/tests.py
diff --git a/tests/regressiontests/admin_inlines/tests.py b/tests/regressiontests/admin_inlines/tests.py index 067b3c5..73b1990 100644
a b from django.test import TestCase 4 4 5 5 # local test models 6 6 from models import (Holder, Inner, InnerInline, Holder2, Inner2, Holder3, 7 Inner3, Person, OutfitItem, Fashionista, Teacher, Parent, Child) 7 Inner3, Person, OutfitItem, Fashionista, Teacher, Parent, Child, 8 Block, Post) 8 9 9 10 10 11 class TestInline(TestCase): … … class TestInline(TestCase): 103 104 # column cells 104 105 self.assertContains(response, '<p>Callable in QuestionInline</p>') 105 106 107 def test_inline_save_as(self): 108 """ 109 #13223 - ValueError with inline and save as new. 110 Verifies that _saveasnew is included in the form when it is 111 rendered due to validation errors. 112 """ 113 114 p = Post.objects.create(title='test', slug='test') 115 b1 = p.block_set.create(slug='test1') 116 b2 = p.block_set.create(slug='test2') 117 b3 = p.block_set.create(slug='test3') 118 119 data = { 120 'block_set-TOTAL_FORMS': 6, 121 'block_set-INITIAL_FORMS': 3, 122 'block_set-MAX_NUM_FORMS': 0, 123 'block_set-0-id': b1.id, 124 'block_set-0-post': p.id, 125 'block_set-0-slug': b1.slug, 126 'block_set-1-id': b2.id, 127 'block_set-1-post': p.id, 128 'block_set-1-slug': b2.slug, 129 'block_set-2-id': b2.id, 130 'block_set-2-post': p.id, 131 'block_set-2-slug': b2.slug, 132 'block_set-3-id': '', 133 'block_set-3-post': p.id, 134 'block_set-3-slug': '', 135 'block_set-4-id': '', 136 'block_set-4-post': p.id, 137 'block_set-4-slug': '', 138 'block_set-5-id': '', 139 'block_set-5-post': p.id, 140 'block_set-5-slug': '', 141 'block_set-__prefix__-id': '', 142 'block_set-__prefix__-post': p.id, 143 'block_set-__prefix__-slug': '', 144 '_saveasnew': u'Save as new', 145 } 146 response = self.client.post('/test_admin/admin/admin_inlines/post/%s/' % p.id, data) 147 self.assertEqual(response.status_code, 200) 148 self.assertEqual(response.context['inline_admin_formset'].formset.errors[0]['slug'], 149 [u'Block with this Slug already exists.']) 150 self.assertContains(response, '<input type="hidden" value="_saveasnew" name="_saveasnew">') 151 152 153 106 154 class TestInlineMedia(TestCase): 107 155 fixtures = ['admin-views-users.xml'] 108 156