summaryrefslogtreecommitdiff
path: root/tests/admin_views
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2022-05-04 11:38:12 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-05-06 08:36:04 +0200
commitdddc8bc47d20083c63aea4a7acf1777ce197ec8d (patch)
tree37d0f053e73586d69c20d4037273145a152e381c /tests/admin_views
parentfaab9e6769b01c18d9e3a31504601452eede6150 (diff)
downloaddjango-dddc8bc47d20083c63aea4a7acf1777ce197ec8d.tar.gz
Fixed #33679 -- Fixed the last inline's id in admin for users without add permissions.
Diffstat (limited to 'tests/admin_views')
-rw-r--r--tests/admin_views/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index 145add114c..11b8aff346 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -2694,6 +2694,20 @@ class AdminViewPermissionsTest(TestCase):
formset = response.context["inline_admin_formsets"][0]
self.assertEqual(len(formset.forms), 3)
+ def test_change_view_with_view_only_last_inline(self):
+ self.viewuser.user_permissions.add(
+ get_perm(Section, get_permission_codename("view", Section._meta))
+ )
+ self.client.force_login(self.viewuser)
+ response = self.client.get(
+ reverse("admin:admin_views_section_change", args=(self.s1.pk,))
+ )
+ self.assertEqual(len(response.context["inline_admin_formsets"]), 1)
+ formset = response.context["inline_admin_formsets"][0]
+ self.assertEqual(len(formset.forms), 3)
+ # The last inline is not marked as empty.
+ self.assertContains(response, 'id="article_set-2"')
+
def test_change_view_with_view_and_add_inlines(self):
"""User has view and add permissions on the inline model."""
self.viewuser.user_permissions.add(