Skip to content

Commit a3d3a2d

Browse files
authored
fix: clean_old_history's days argument acccepts integer (#722)
* fix clean_old_history command: --days argument ...wasn't accepting value. * fix clean_old_history command: --days type is int * style: make format * doc: AUTHORS and CHANGES updated * style: uses black==19.10b0 for formatting
1 parent ba60b0b commit a3d3a2d

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Authors
3333
- David Grochowski (`ThePumpingLemma <https://github.com/ThePumpingLemma>`_)
3434
- David Hite
3535
- Dmytro Shyshov (`xahgmah <https://github.com/xahgmah>`_)
36+
- Edouard Richard (`vied12 <https://github.com/vied12>` _)
3637
- Eduardo Cuducos
3738
- Erik van Widenfelt (`erikvw <https://github.com/erikvw>`_)
3839
- Filipe Pina (@fopina)

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Unreleased
1212
- Add optional ``manager`` argument to ``bulk_update_with_history`` to use instead of
1313
the default manager (gh-703)
1414
- Add support for Django 3.1 (gh-713)
15+
- Fix a bug with ``clean_old_history`` command's `--days` argument
1516

1617
2.11.0 (2020-06-20)
1718
-------------------

simple_history/admin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ def save_model(self, request, obj, form, change):
241241

242242
@property
243243
def content_type_model_cls(self):
244-
"""Returns the ContentType model class.
245-
"""
244+
"""Returns the ContentType model class."""
246245
return django_apps.get_model("contenttypes.contenttype")
247246

248247
@property

simple_history/management/commands/clean_old_history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def add_arguments(self, parser):
2525
parser.add_argument(
2626
"--days",
2727
help="Only Keep the last X Days of history, default is 30",
28-
action="store_true",
2928
dest="days",
29+
type=int,
3030
default=30,
3131
)
3232

simple_history/tests/tests/test_middleware.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ def test_request_user_is_overwritten_by_default_user_on_bulk_create_view(self,):
190190
self.assertFalse(any(ph.history_user_id == self.user.id for ph in poll_history))
191191
self.assertFalse(any(ph.history_user_id is None for ph in poll_history))
192192

193-
@skipIf(django.VERSION < (2, 2,), reason="bulk_update does not exist before 2.2")
193+
@skipIf(
194+
django.VERSION < (2, 2,), reason="bulk_update does not exist before 2.2",
195+
)
194196
def test_user_is_set_on_bulk_update_view_when_logged_in(self):
195197
self.client.force_login(self.user)
196198
poll_1 = Poll.objects.create(question="Test question 1", pub_date=date.today())
@@ -212,7 +214,9 @@ def test_user_is_set_on_bulk_update_view_when_logged_in(self):
212214
self.user.id, poll_2.history.latest("history_date").history_user_id
213215
)
214216

215-
@skipIf(django.VERSION < (2, 2,), reason="bulk_update does not exist before 2.2")
217+
@skipIf(
218+
django.VERSION < (2, 2,), reason="bulk_update does not exist before 2.2",
219+
)
216220
def test_user_is_not_set_on_bulk_update_view_when_not_logged_in(self):
217221
poll_1 = Poll.objects.create(question="Test question 1", pub_date=date.today())
218222
poll_2 = Poll.objects.create(
@@ -224,7 +228,9 @@ def test_user_is_not_set_on_bulk_update_view_when_not_logged_in(self):
224228
self.assertIsNone(poll_1.history.latest("history_date").history_user_id)
225229
self.assertIsNone(poll_2.history.latest("history_date").history_user_id)
226230

227-
@skipIf(django.VERSION < (2, 2,), reason="bulk_update does not exist before 2.2")
231+
@skipIf(
232+
django.VERSION < (2, 2,), reason="bulk_update does not exist before 2.2",
233+
)
228234
def test_request_user_is_overwritten_by_default_user_on_bulk_update(self):
229235
self.client.force_login(self.user)
230236
poll = Poll.objects.create(pub_date=date(2020, 1, 1), question="123")

simple_history/tests/tests/test_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ def test_bulk_create_with_history(self):
236236
self.assertEqual(BulkCreateManyToManyModel.objects.count(), 5)
237237

238238

239-
@skipIf(django.VERSION < (2, 2,), reason="bulk_update does not exist before 2.2")
239+
@skipIf(
240+
django.VERSION < (2, 2,), reason="bulk_update does not exist before 2.2",
241+
)
240242
class BulkUpdateWithHistoryTestCase(TestCase):
241243
def setUp(self):
242244
self.data = [
@@ -337,7 +339,9 @@ def test_bulk_update_history_with_batch_size(self):
337339
self.assertEqual(Poll.history.filter(history_type="~").count(), 5)
338340

339341

340-
@skipIf(django.VERSION < (2, 2,), reason="bulk_update does not exist before 2.2")
342+
@skipIf(
343+
django.VERSION < (2, 2,), reason="bulk_update does not exist before 2.2",
344+
)
341345
class BulkUpdateWithHistoryAlternativeManagersTestCase(TestCase):
342346
def setUp(self):
343347
self.data = [

0 commit comments

Comments
 (0)