mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[2.1.x] Fixed #29487 -- Accounted for object level permissions when calculating change view's read-only fields.
Thanks Matthew Frazier for the report and fix.
Backport of 553617e613 from master
			
			
This commit is contained in:
		| @@ -1852,6 +1852,18 @@ class AdminViewPermissionsTest(TestCase): | ||||
|             self.assertContains(response, 'login-form') | ||||
|             self.client.get(reverse('admin:logout')) | ||||
|  | ||||
|     def test_change_view_without_object_change_permission(self): | ||||
|         """ | ||||
|         The object should be read-only if the user has permission to view it | ||||
|         and change objects of that type but not to change the current object. | ||||
|         """ | ||||
|         change_url = reverse('admin9:admin_views_article_change', args=(self.a1.pk,)) | ||||
|         self.client.force_login(self.viewuser) | ||||
|         response = self.client.get(change_url) | ||||
|         self.assertEqual(response.status_code, 200) | ||||
|         self.assertEqual(response.context['title'], 'View article') | ||||
|         self.assertContains(response, '<a href="/test_admin/admin9/admin_views/article/" class="closelink">Close</a>') | ||||
|  | ||||
|     def test_change_view_save_as_new(self): | ||||
|         """ | ||||
|         'Save as new' should raise PermissionDenied for users without the 'add' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user