Skip to content

Commit afae6df

Browse files
author
Ross Mechanic
authored
Merge pull request #361 from ncvc/master
Added has_change_permission check to SimpleHistoryAdmin.history_view
2 parents 63e4bd8 + a7cc371 commit afae6df

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changes
22
=======
33

4+
Unreleased
5+
----------
6+
- Fix bug where history_view ignored user permissions
7+
48
1.9.1 (2018-03-30)
59
------------------
610
- Use get_queryset rather than model.objects in history_view. (gh-303)

simple_history/admin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def history_view(self, request, object_id, extra_context=None):
6363
obj = action_list.latest('history_date').instance
6464
except action_list.model.DoesNotExist:
6565
raise http.Http404
66+
67+
if not self.has_change_permission(request, obj):
68+
raise PermissionDenied
69+
6670
content_type = ContentType.objects.get_by_natural_key(
6771
*USER_NATURAL_KEY)
6872
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
@@ -92,6 +92,11 @@ def test_history_list_custom_fields(self):
9292
self.assertIn("12", response.unicode_normal_body)
9393
self.assertIn("15", response.unicode_normal_body)
9494

95+
def test_history_view_permission(self):
96+
self.login()
97+
person = Person.objects.create(name='Sandra Hale')
98+
self.app.get(get_history_url(person), status=403)
99+
95100
def test_history_form_permission(self):
96101
self.login(self.user)
97102
person = Person.objects.create(name='Sandra Hale')

0 commit comments

Comments
 (0)