@@ -1103,6 +1103,46 @@ def testChangeView(self):
1103
1103
self .assertContains (response , 'login-form' )
1104
1104
self .client .get ('/test_admin/admin/logout/' )
1105
1105
1106
+ def testHistoryView (self ):
1107
+ """History view should restrict access."""
1108
+
1109
+ # add user shoud not be able to view the list of article or change any of them
1110
+ self .client .get ('/test_admin/admin/' )
1111
+ self .client .post ('/test_admin/admin/' , self .adduser_login )
1112
+ response = self .client .get ('/test_admin/admin/admin_views/article/1/history/' )
1113
+ self .assertEqual (response .status_code , 403 )
1114
+ self .client .get ('/test_admin/admin/logout/' )
1115
+
1116
+ # change user can view all items and edit them
1117
+ self .client .get ('/test_admin/admin/' )
1118
+ self .client .post ('/test_admin/admin/' , self .changeuser_login )
1119
+ response = self .client .get ('/test_admin/admin/admin_views/article/1/history/' )
1120
+ self .assertEqual (response .status_code , 200 )
1121
+
1122
+ # Test redirection when using row-level change permissions. Refs #11513.
1123
+ RowLevelChangePermissionModel .objects .create (id = 1 , name = "odd id" )
1124
+ RowLevelChangePermissionModel .objects .create (id = 2 , name = "even id" )
1125
+ for login_dict in [self .super_login , self .changeuser_login , self .adduser_login , self .deleteuser_login ]:
1126
+ self .client .post ('/test_admin/admin/' , login_dict )
1127
+ response = self .client .get ('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/history/' )
1128
+ self .assertEqual (response .status_code , 403 )
1129
+
1130
+ response = self .client .get ('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/history/' )
1131
+ self .assertEqual (response .status_code , 200 )
1132
+
1133
+ self .client .get ('/test_admin/admin/logout/' )
1134
+
1135
+ for login_dict in [self .joepublic_login , self .no_username_login ]:
1136
+ self .client .post ('/test_admin/admin/' , login_dict )
1137
+ response = self .client .get ('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/history/' )
1138
+ self .assertEqual (response .status_code , 200 )
1139
+ self .assertContains (response , 'login-form' )
1140
+ response = self .client .get ('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/history/' )
1141
+ self .assertEqual (response .status_code , 200 )
1142
+ self .assertContains (response , 'login-form' )
1143
+
1144
+ self .client .get ('/test_admin/admin/logout/' )
1145
+
1106
1146
def testConditionallyShowAddSectionLink (self ):
1107
1147
"""
1108
1148
The foreign key widget should only show the "add related" button if the
0 commit comments