Skip to content

Commit 0483a5f

Browse files
author
Ross Mechanic
authored
Merge branch 'master' into remove-support-for-django-1.8
2 parents 3f4507a + afae6df commit 0483a5f

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Authors
5151
- Kevin Foster
5252
- Shane Engelman
5353
- Ray Logel
54+
- Nathan Villagaray-Carski
5455

5556
Background
5657
==========

CHANGES.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Changes
22
=======
33

4-
Latest
5-
------
4+
Unreleased
5+
----------
6+
- Fix bug where history_view ignored user permissions
67
- Dropped support for Django<=1.8
78

89
1.9.1 (2018-03-30)

simple_history/admin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ def history_view(self, request, object_id, extra_context=None):
5757
obj = action_list.latest('history_date').instance
5858
except action_list.model.DoesNotExist:
5959
raise http.Http404
60+
61+
if not self.has_change_permission(request, obj):
62+
raise PermissionDenied
63+
6064
content_type = ContentType.objects.get_by_natural_key(
6165
*USER_NATURAL_KEY)
6266
admin_user_view = 'admin:%s_%s_change' % (content_type.app_label,

simple_history/tests/tests/test_admin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ def test_history_list_custom_fields(self):
8888
self.assertIn("12", response.unicode_normal_body)
8989
self.assertIn("15", response.unicode_normal_body)
9090

91+
def test_history_view_permission(self):
92+
self.login()
93+
person = Person.objects.create(name='Sandra Hale')
94+
self.app.get(get_history_url(person), status=403)
95+
9196
def test_history_form_permission(self):
9297
self.login(self.user)
9398
person = Person.objects.create(name='Sandra Hale')

0 commit comments

Comments
 (0)