diff --git a/tests/admin_inlines/admin.py b/tests/admin_inlines/admin.py
index 7ac13ed..b5f343a 100644
a
|
b
|
class InnerInline2(admin.StackedInline):
|
74 | 74 | js = ('my_awesome_inline_scripts.js',) |
75 | 75 | |
76 | 76 | |
| 77 | class InnerInline2Tabular(admin.TabularInline): |
| 78 | model = Inner2 |
| 79 | |
| 80 | |
77 | 81 | class CustomNumberWidget(forms.NumberInput): |
78 | 82 | class Media: |
79 | 83 | js = ('custom_number.js',) |
… |
… |
site.register(TitleCollection, inlines=[TitleInline])
|
236 | 240 | # only ModelAdmin media |
237 | 241 | site.register(Holder, HolderAdmin, inlines=[InnerInline]) |
238 | 242 | # ModelAdmin and Inline media |
239 | | site.register(Holder2, HolderAdmin, inlines=[InnerInline2]) |
| 243 | site.register(Holder2, HolderAdmin, inlines=[InnerInline2, InnerInline2Tabular]) |
240 | 244 | # only Inline media |
241 | 245 | site.register(Holder3, inlines=[InnerInline3]) |
242 | 246 | |
diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py
index 4ce744f..d09b48f 100644
a
|
b
|
class TestInlinePermissions(TestCase):
|
588 | 588 | self.author_book_auto_m2m_intermediate_id = author_book_auto_m2m_intermediate.pk |
589 | 589 | |
590 | 590 | holder = Holder2.objects.create(dummy=13) |
591 | | inner2 = Inner2.objects.create(dummy=42, holder=holder) |
| 591 | self.inner2 = Inner2.objects.create(dummy=42, holder=holder) |
592 | 592 | self.holder_change_url = reverse('admin:admin_inlines_holder2_change', args=(holder.id,)) |
593 | | self.inner2_id = inner2.id |
594 | 593 | |
595 | 594 | self.client.force_login(self.user) |
596 | 595 | |
… |
… |
class TestInlinePermissions(TestCase):
|
684 | 683 | ) |
685 | 684 | self.assertNotContains( |
686 | 685 | response, |
687 | | '<input type="hidden" id="id_inner2_set-0-id" value="%i" name="inner2_set-0-id">' % self.inner2_id, |
| 686 | '<input type="hidden" id="id_inner2_set-0-id" value="%i" name="inner2_set-0-id">' % self.inner2.id, |
688 | 687 | html=True |
689 | 688 | ) |
690 | 689 | |
… |
… |
class TestInlinePermissions(TestCase):
|
693 | 692 | self.user.user_permissions.add(permission) |
694 | 693 | response = self.client.get(self.holder_change_url) |
695 | 694 | # Change permission on inner2s, so we can change existing but not add new |
696 | | self.assertContains(response, '<h2>Inner2s</h2>') |
| 695 | self.assertContains(response, '<h2>Inner2s</h2>', count=2) |
697 | 696 | # Just the one form for existing instances |
698 | 697 | self.assertContains( |
699 | 698 | response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" value="1" name="inner2_set-TOTAL_FORMS">', |
… |
… |
class TestInlinePermissions(TestCase):
|
701 | 700 | ) |
702 | 701 | self.assertContains( |
703 | 702 | response, |
704 | | '<input type="hidden" id="id_inner2_set-0-id" value="%i" name="inner2_set-0-id">' % self.inner2_id, |
| 703 | '<input type="hidden" id="id_inner2_set-0-id" value="%i" name="inner2_set-0-id">' % self.inner2.id, |
705 | 704 | html=True |
706 | 705 | ) |
707 | 706 | # max-num 0 means we can't add new ones |
… |
… |
class TestInlinePermissions(TestCase):
|
710 | 709 | '<input type="hidden" id="id_inner2_set-MAX_NUM_FORMS" value="0" name="inner2_set-MAX_NUM_FORMS">', |
711 | 710 | html=True |
712 | 711 | ) |
| 712 | # Tabular form |
| 713 | self.assertContains(response, '<th class="required">Dummy</th>', html=True) |
| 714 | self.assertContains( |
| 715 | response, |
| 716 | '<input type="number" name="inner2_set-2-0-dummy" value="%s" ' |
| 717 | 'class="vIntegerField" id="id_inner2_set-2-0-dummy">' % self.inner2.dummy, |
| 718 | ) |
713 | 719 | |
714 | 720 | def test_inline_change_fk_add_change_perm(self): |
715 | 721 | permission = Permission.objects.get(codename='add_inner2', content_type=self.inner_ct) |
… |
… |
class TestInlinePermissions(TestCase):
|
726 | 732 | ) |
727 | 733 | self.assertContains( |
728 | 734 | response, |
729 | | '<input type="hidden" id="id_inner2_set-0-id" value="%i" name="inner2_set-0-id">' % self.inner2_id, |
| 735 | '<input type="hidden" id="id_inner2_set-0-id" value="%i" name="inner2_set-0-id">' % self.inner2.id, |
730 | 736 | html=True |
731 | 737 | ) |
732 | 738 | |
… |
… |
class TestInlinePermissions(TestCase):
|
746 | 752 | ) |
747 | 753 | self.assertContains( |
748 | 754 | response, |
749 | | '<input type="hidden" id="id_inner2_set-0-id" value="%i" name="inner2_set-0-id">' % self.inner2_id, |
| 755 | '<input type="hidden" id="id_inner2_set-0-id" value="%i" name="inner2_set-0-id">' % self.inner2.id, |
750 | 756 | html=True |
751 | 757 | ) |
752 | 758 | self.assertContains(response, 'id="id_inner2_set-0-DELETE"') |
… |
… |
class TestInlinePermissions(TestCase):
|
760 | 766 | self.user.user_permissions.add(permission) |
761 | 767 | response = self.client.get(self.holder_change_url) |
762 | 768 | # All perms on inner2s, so we can add/change/delete |
763 | | self.assertContains(response, '<h2>Inner2s</h2>') |
| 769 | self.assertContains(response, '<h2>Inner2s</h2>', count=2) |
764 | 770 | # One form for existing instance only, three for new |
765 | 771 | self.assertContains( |
766 | 772 | response, |
… |
… |
class TestInlinePermissions(TestCase):
|
769 | 775 | ) |
770 | 776 | self.assertContains( |
771 | 777 | response, |
772 | | '<input type="hidden" id="id_inner2_set-0-id" value="%i" name="inner2_set-0-id">' % self.inner2_id, |
| 778 | '<input type="hidden" id="id_inner2_set-0-id" value="%i" name="inner2_set-0-id">' % self.inner2.id, |
773 | 779 | html=True |
774 | 780 | ) |
775 | 781 | self.assertContains(response, 'id="id_inner2_set-0-DELETE"') |
| 782 | # Tabular form |
| 783 | self.assertContains(response, '<th class="required">Dummy</th>', html=True) |
| 784 | self.assertContains( |
| 785 | response, |
| 786 | '<input type="number" name="inner2_set-2-0-dummy" value="%s" ' |
| 787 | 'class="vIntegerField" id="id_inner2_set-2-0-dummy">' % self.inner2.dummy, |
| 788 | ) |
776 | 789 | |
777 | 790 | |
778 | 791 | @override_settings(ROOT_URLCONF='admin_inlines.urls') |