Skip to content

Commit

Permalink
Merge db94da5 into 04888fe
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven committed Dec 27, 2014
2 parents 04888fe + db94da5 commit 11abc02
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Authors
- Micah Denbraver
- Rajesh Pappula
- Ross Lote
- Steven Klass
- Trey Hunner
- Ulysses Vilela
- vnagendra
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changes
=======

1.5.x (YYYY-MM-DD)
------------------
- Do NOT delete the history elements when a user is deleted.

1.5.3 (2014-11-18)
------------------
- Fix migrations while using ``order_with_respsect_to`` (gh-140)
Expand Down
3 changes: 2 additions & 1 deletion simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ def get_instance(self):
'history_id': models.AutoField(primary_key=True),
'history_date': models.DateTimeField(),
'history_user': models.ForeignKey(
user_model, null=True, related_name=self.user_related_name),
user_model, null=True, related_name=self.user_related_name,
on_delete=models.SET_NULL),
'history_type': models.CharField(max_length=1, choices=(
('+', 'Created'),
('~', 'Changed'),
Expand Down
16 changes: 16 additions & 0 deletions simple_history/tests/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,19 @@ def test_other_admin(self):
self.app.get(history_url)
change_url = get_history_url(state, 0, site="other_admin")
self.app.get(change_url)

def test_deleteting_user(self):
"""Test deletes of a user does not cascade delete the history"""
self.login()
poll = Poll(question="why?", pub_date=today)
poll._history_user = self.user
poll.save()

historical_poll = poll.history.all()[0]
self.assertEqual(historical_poll.history_user, self.user)

self.user.delete()

historical_poll = poll.history.all()[0]
self.assertEqual(historical_poll.history_user, None)

0 comments on commit 11abc02

Please sign in to comment.