Skip to content

Commit 13a15ad

Browse files
committed
add changelog and tests
1 parent 7ca3a8d commit 13a15ad

File tree

8 files changed

+20
-3
lines changed

8 files changed

+20
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,4 @@ __marimo__/
221221

222222
test1.db
223223
test2.db
224+
example/example.db

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
v4.3.0 (202X-XX-XX)
55
-------------------
66

7+
* Implemented `Include get_child_inlines() hook in stacked inline admin forms. <https://github.com/jazzband/django-polymorphic/pull/681>`_
78
* Fixed `"multi-database support in inheritance accessors. <https://github.com/jazzband/django-polymorphic/pull/550>`_
89
* Fixed `Caching in inheritance accessor functions <https://github.com/jazzband/django-polymorphic/pull/510>`_
910
* Fixed `Foreign key resolves to parent class when using abstract models <https://github.com/jazzband/django-polymorphic/issues/437>`_

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ manage *COMMAND:
1515
import sys
1616
from django.core import management
1717
sys.path.append(os.getcwd())
18-
os.environ["DJANGO_SETTINGS_MODULE"] = "polymorphic.tests.settings"
18+
os.environ["DJANGO_SETTINGS_MODULE"] = "polymorphic.tests.debug"
1919
os.environ["SQLITE_DATABASES"] = "test1.db,test2.db"
2020
management.execute_from_command_line(sys.argv + "{{ COMMAND }}".split(" "))
2121

src/polymorphic/admin/inlines.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ def get_child_inlines(self):
8181
"""
8282
Return the derived inline classes which this admin should handle.
8383
84-
This should return a list of tuples, exactly like
85-
:attr:`child_inlines` is.
84+
This should return an iterable of
85+
:class:`~polymorphic.admin.inlines.PolymorphicInlineModelAdmin.Child classes,
86+
to override :attr:`child_inlines.
8687
"""
8788
return self.child_inlines or []
8889

src/polymorphic/tests/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ class InlineModelBChild(StackedPolymorphicInline.Child):
5757
@register(InlineParent)
5858
class InlineParentAdmin(PolymorphicInlineSupportMixin, ModelAdmin):
5959
inlines = (Inline,)
60+
extra = 1

src/polymorphic/tests/debug.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .settings import *
2+
3+
DEBUG = True

src/polymorphic/tests/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
"polymorphic",
102102
"polymorphic.tests",
103103
)
104+
104105
MIDDLEWARE = (
105106
"django.middleware.common.CommonMiddleware",
106107
"django.contrib.sessions.middleware.SessionMiddleware",

src/polymorphic/tests/test_admin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ def tearDown(self):
236236
InlineParent.objects.all().delete()
237237
super().tearDown()
238238

239+
def test_get_child_inlines(self):
240+
from .admin import Inline
241+
242+
inline = Inline(parent_model=InlineParent, admin_site=admin.site)
243+
child_inlines = inline.get_child_inlines()
244+
self.assertEqual(len(child_inlines), 2)
245+
self.assertEqual(child_inlines[0], Inline.InlineModelAChild)
246+
self.assertEqual(child_inlines[1], Inline.InlineModelBChild)
247+
239248
def test_admin_inline_add_autocomplete(self):
240249
# https://github.com/jazzband/django-polymorphic/issues/546
241250
self.page.goto(self.add_url(InlineParent))

0 commit comments

Comments
 (0)