@@ -154,7 +154,8 @@ def test_history_form_permission(self):
154
154
def test_invalid_history_form (self ):
155
155
self .login ()
156
156
poll = Poll .objects .create (question = "why?" , pub_date = today )
157
- response = self .client .post (get_history_url (poll , 0 ), data = {"question" : "" })
157
+ with patch ("simple_history.admin.SIMPLE_HISTORY_EDIT" , True ):
158
+ response = self .client .post (get_history_url (poll , 0 ), data = {"question" : "" })
158
159
self .assertEqual (response .status_code , 200 )
159
160
self .assertContains (response , "This field is required" )
160
161
@@ -200,6 +201,25 @@ def test_history_form(self):
200
201
[p .history_user for p in Poll .history .all ()], [self .user , None , None ]
201
202
)
202
203
204
+ def test_readonly_history_form_without_setting_simple_history_edit (self ):
205
+ self .login ()
206
+ poll = Poll .objects .create (question = "why?" , pub_date = today )
207
+ poll .question = "how?"
208
+ poll .save ()
209
+ response = self .client .get (get_history_url (poll , 0 ))
210
+ readonly_fields = response .context ["adminform" ].readonly_fields
211
+ self .assertCountEqual (["question" , "pub_date" ], readonly_fields )
212
+
213
+ def test_readonly_history_form_with_enabled_simple_history_edit (self ):
214
+ self .login ()
215
+ poll = Poll .objects .create (question = "why?" , pub_date = today )
216
+ poll .question = "how?"
217
+ poll .save ()
218
+ with patch ("simple_history.admin.SIMPLE_HISTORY_EDIT" , True ):
219
+ response = self .client .get (get_history_url (poll , 0 ))
220
+ readonly_fields = response .context ["adminform" ].readonly_fields
221
+ self .assertEqual (0 , len (readonly_fields ))
222
+
203
223
def test_history_user_on_save_in_admin (self ):
204
224
self .login ()
205
225
0 commit comments