From f47eb3fd21217eb37c8645ef38d2d9fcfa8a8ed7 Mon Sep 17 00:00:00 2001 From: Ross Mechanic Date: Thu, 23 Apr 2020 14:10:30 -0400 Subject: [PATCH] Revert GH-641 (#648) --- AUTHORS.rst | 1 - CHANGES.rst | 2 -- simple_history/admin.py | 4 +--- simple_history/tests/tests/test_admin.py | 22 +--------------------- 4 files changed, 2 insertions(+), 27 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index bd59dc908..b6946161e 100755 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -82,7 +82,6 @@ Authors - Prakash Venkatraman (`dopatraman `_) - Rajesh Pappula - Ray Logel -- Reza Pourmeshki (`partizaans `_) - Roberto Aguilar - Rod Xavier Bondoc - Ross Lote diff --git a/CHANGES.rst b/CHANGES.rst index 07bdcbcf8..eae196a9c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,8 +10,6 @@ Changes to avoid possible `AppRegistryNotReady` exception (gh-630) - Fix `utils.update_change_reason` when user specifies excluded_fields (gh-637) - Changed how `now` is imported from `timezone` (`timezone` module is imported now) (gh-643) -- Render fields as readonly in history detail view if `SIMPLE_HISTORY_EDIT` is not set - `True` (gh-641) - settings.SIMPLE_HISTORY_REVERT_DISABLED if True removes the Revert button from the history form for all historical models (gh-632)) diff --git a/simple_history/admin.py b/simple_history/admin.py index bf678e527..99e61287c 100644 --- a/simple_history/admin.py +++ b/simple_history/admin.py @@ -175,9 +175,7 @@ def history_form_view(self, request, object_id, version_id, extra_context=None): form, self.get_fieldsets(request, obj), self.prepopulated_fields, - self.get_readonly_fields(request, obj) - if change_history - else self.get_fields(request, obj), + self.get_readonly_fields(request, obj), model_admin=self, ) diff --git a/simple_history/tests/tests/test_admin.py b/simple_history/tests/tests/test_admin.py index 5d0ec7e8d..7c3e58c50 100644 --- a/simple_history/tests/tests/test_admin.py +++ b/simple_history/tests/tests/test_admin.py @@ -154,8 +154,7 @@ def test_history_form_permission(self): def test_invalid_history_form(self): self.login() poll = Poll.objects.create(question="why?", pub_date=today) - with patch("simple_history.admin.SIMPLE_HISTORY_EDIT", True): - response = self.client.post(get_history_url(poll, 0), data={"question": ""}) + response = self.client.post(get_history_url(poll, 0), data={"question": ""}) self.assertEqual(response.status_code, 200) self.assertContains(response, "This field is required") @@ -201,25 +200,6 @@ def test_history_form(self): [p.history_user for p in Poll.history.all()], [self.user, None, None] ) - def test_readonly_history_form_without_setting_simple_history_edit(self): - self.login() - poll = Poll.objects.create(question="why?", pub_date=today) - poll.question = "how?" - poll.save() - response = self.client.get(get_history_url(poll, 0)) - readonly_fields = response.context["adminform"].readonly_fields - self.assertCountEqual(["question", "pub_date"], readonly_fields) - - def test_readonly_history_form_with_enabled_simple_history_edit(self): - self.login() - poll = Poll.objects.create(question="why?", pub_date=today) - poll.question = "how?" - poll.save() - with patch("simple_history.admin.SIMPLE_HISTORY_EDIT", True): - response = self.client.get(get_history_url(poll, 0)) - readonly_fields = response.context["adminform"].readonly_fields - self.assertEqual(0, len(readonly_fields)) - def test_history_user_on_save_in_admin(self): self.login()