diff --git a/poetry.lock b/poetry.lock index 38235fc..3258a2a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. [[package]] name = "amqp" @@ -281,6 +281,20 @@ sqlparse = ">=0.2.2" argon2 = ["argon2-cffi (>=19.1.0)"] bcrypt = ["bcrypt"] +[[package]] +name = "django-more-admin-filters" +version = "1.7" +description = "Additional filters for django-admin." +optional = false +python-versions = "*" +files = [ + {file = "django-more-admin-filters-1.7.tar.gz", hash = "sha256:67fad47ea63d8ac1f0f1c3a25850004197656cb573b2d1584077d6765b9354ef"}, + {file = "django_more_admin_filters-1.7-py3-none-any.whl", hash = "sha256:b2162a084d7233c4d892cf6a0d0ae8a0b9bc0213815fbb8840df8e0b970c8c07"}, +] + +[package.dependencies] +Django = ">=2.2,<5.0" + [[package]] name = "django-polymorphic" version = "3.1.0" @@ -862,4 +876,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = ">=3.7.2,<4.0" -content-hash = "8a364b040a969b4a84509b41f353b30b37c71567846dd5f2def48717e6f01ed6" +content-hash = "7627d2bdf91924d65b57d4ad7a73585fd74b84990c56ec42bc56677a9148c4ef" diff --git a/pyproject.toml b/pyproject.toml index de2283e..d67f29e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ python = ">=3.7.2,<4.0" Django = ">=3" django-polymorphic = "^3" celery = ">=4.4" +django-more-admin-filters = "^1.7" [tool.poetry.group.dev.dependencies] flake8 = "^5.0.4" diff --git a/tests/app/settings.py b/tests/app/settings.py index 7db1149..37ad187 100644 --- a/tests/app/settings.py +++ b/tests/app/settings.py @@ -38,6 +38,7 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'more_admin_filters', 'polymorphic', 'triggers', 'tests.app', diff --git a/triggers/admin.py b/triggers/admin.py index c95c5a8..47353e5 100644 --- a/triggers/admin.py +++ b/triggers/admin.py @@ -3,6 +3,7 @@ from django.contrib import admin from django.utils.html import format_html_join from django.utils.translation import gettext_lazy as _ +from more_admin_filters import MultiSelectRelatedOnlyFilter from polymorphic.admin import PolymorphicInlineSupportMixin, StackedPolymorphicInline from polymorphic.models import PolymorphicModel @@ -52,7 +53,7 @@ class EventInline(StackedPolymorphicInline): child_inlines = generate_child_inlines(Event) -class RelatedOnlyFieldListFilter(admin.RelatedOnlyFieldListFilter): +class RelatedOnlyFieldMultiListFilter(MultiSelectRelatedOnlyFilter): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.title = self.__class__.__dict__['title'] @@ -64,7 +65,8 @@ def field_choices(self, field, request, model_admin) -> List[Tuple[str, str]]: def create_related_filter(title): - return type('_RelatedFilter', (RelatedOnlyFieldListFilter,), {'title': title}) + return type('_RelatedFilter', (RelatedOnlyFieldMultiListFilter,), {'title': title}) + @admin.register(Trigger)