Skip to content

Commit

Permalink
Revert GH-641 (#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Mechanic authored Apr 23, 2020
1 parent 49626c3 commit f47eb3f
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 27 deletions.
1 change: 0 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ Authors
- Prakash Venkatraman (`dopatraman <https://github.com/dopatraman>`_)
- Rajesh Pappula
- Ray Logel
- Reza Pourmeshki (`partizaans <https://github.com/partizaans>`_)
- Roberto Aguilar
- Rod Xavier Bondoc
- Ross Lote
Expand Down
2 changes: 0 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
4 changes: 1 addition & 3 deletions simple_history/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
22 changes: 1 addition & 21 deletions simple_history/tests/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit f47eb3f

Please sign in to comment.