Ticket #10640: add_form.patch
File add_form.patch, 3.3 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/options.py
585 585 'save_on_top': self.save_on_top, 586 586 'root_path': self.admin_site.root_path, 587 587 }) 588 if add: 589 admin_form_template = getattr(self, 'add_form_template', None) 590 else: 591 admin_form_template = getattr(self, 'change_form_template', None) 588 592 context_instance = template.RequestContext(request, current_app=self.admin_site.name) 589 return render_to_response( self.change_form_template or [593 return render_to_response(admin_form_template or [ 590 594 "admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()), 591 595 "admin/%s/change_form.html" % app_label, 592 596 "admin/change_form.html" -
tests/regressiontests/admin_views/tests.py
541 541 self.failUnlessEqual(request.status_code, 200) 542 542 self.assert_("var hello = 'Hello!';" in request.content) 543 543 self.assertTemplateUsed(request, 'custom_admin/change_list.html') 544 545 # Test custom changeform template544 545 # Test custom add form template 546 546 request = self.client.get('/test_admin/admin/admin_views/customarticle/add/') 547 self.assertTemplateUsed(request, 'custom_admin/ change_form.html')548 549 # Add an article so we can test delete and history views547 self.assertTemplateUsed(request, 'custom_admin/add_form.html') 548 549 # Add an article so we can test delete, change, and history views 550 550 post = self.client.post('/test_admin/admin/admin_views/customarticle/add/', { 551 551 'content': '<p>great article</p>', 552 552 'date_0': '2008-03-18', … … 555 555 self.assertRedirects(post, '/test_admin/admin/admin_views/customarticle/') 556 556 self.failUnlessEqual(CustomArticle.objects.all().count(), 1) 557 557 558 # Test custom delete and object history templates 558 # Test custom delete, change, and object history templates 559 # Test custom change form template 560 request = self.client.get('/test_admin/admin/admin_views/customarticle/1/') 561 self.assertTemplateUsed(request, 'custom_admin/change_form.html') 559 562 request = self.client.get('/test_admin/admin/admin_views/customarticle/1/delete/') 560 563 self.assertTemplateUsed(request, 'custom_admin/delete_confirmation.html') 561 564 request = self.client.get('/test_admin/admin/admin_views/customarticle/1/history/') -
tests/regressiontests/admin_views/models.py
106 106 """ 107 107 change_list_template = 'custom_admin/change_list.html' 108 108 change_form_template = 'custom_admin/change_form.html' 109 add_form_template = 'custom_admin/add_form.html' 109 110 object_history_template = 'custom_admin/object_history.html' 110 111 delete_confirmation_template = 'custom_admin/delete_confirmation.html' 111 112