Skip to content

Commit

Permalink
Deprecated simple_history_admin_list.display_list
Browse files Browse the repository at this point in the history
  • Loading branch information
ddabble committed Mar 10, 2024
1 parent d054c33 commit 8513231
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Unreleased
``simple_history/_object_history_list.html`` to
``simple_history/object_history_list.html``, and added the field
``SimpleHistoryAdmin.object_history_list_template`` for overriding it (gh-1128)
- Deprecated the undocumented template tag ``simple_history_admin_list.display_list()``;
it will be removed in version 3.8 (gh-1128)
- Added ``SimpleHistoryAdmin.get_history_queryset()`` for overriding which ``QuerySet``
is used to list the historical records (gh-1128)
- Added ``SimpleHistoryAdmin.get_history_list_display()`` which returns
Expand Down
15 changes: 15 additions & 0 deletions simple_history/templatetags/simple_history_admin_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import warnings

from django import template

register = template.Library()


@register.inclusion_tag("simple_history/object_history_list.html", takes_context=True)
def display_list(context):
warnings.warn(
"'include' the context variable 'object_history_list_template' instead."
" This will be removed in version 3.8.",
DeprecationWarning,
)
return context
13 changes: 13 additions & 0 deletions simple_history/tests/tests/test_deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unittest

from simple_history import __version__
from simple_history.templatetags.simple_history_admin_list import display_list


class DeprecationWarningTest(unittest.TestCase):
def test__display_list__warns_deprecation_and_is_yet_to_be_removed(self):
with self.assertWarns(DeprecationWarning):
display_list({})
# DEV: `display_list()` (and the file `simple_history_admin_list.py`) should be
# removed when 3.8 is released
self.assertLess(__version__, "3.8")

0 comments on commit 8513231

Please sign in to comment.