diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 00d4da5..fee4f11 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,12 @@ Changelog ========= +Unreleased +========== +* fix: `get_absolute_url` method not found while creating new alias and category from wizard button. +* feat: Added search capability in AliasContent admin (migrate the 4.0.x feature from PR #236) + + 2.0.1 (2024-03-27) ================== diff --git a/djangocms_alias/admin.py b/djangocms_alias/admin.py index f2c13c4..9519a97 100644 --- a/djangocms_alias/admin.py +++ b/djangocms_alias/admin.py @@ -80,6 +80,7 @@ class AliasAdmin(*alias_admin_classes): ) fields = ("content__name", "category", "site", "content__language") readonly_fields = ("static_code",) + search_fields = ["content__name"] form = AliasGrouperAdminForm extra_grouping_fields = ("language",) EMPTY_CONTENT_VALUE = mark_safe(_("Missing language")) diff --git a/djangocms_alias/cms_wizards.py b/djangocms_alias/cms_wizards.py index bf75516..a8feccc 100644 --- a/djangocms_alias/cms_wizards.py +++ b/djangocms_alias/cms_wizards.py @@ -13,6 +13,9 @@ class CreateAliasWizard(Wizard): def user_has_add_permission(self, user, **kwargs): return Alias.can_create_alias(user) + def get_success_url(self, obj, **kwargs): + return obj.get_admin_change_url() + class CreateAliasCategoryWizard(Wizard): def user_has_add_permission(self, user, **kwargs): @@ -20,6 +23,9 @@ def user_has_add_permission(self, user, **kwargs): get_model_permission_codename(Category, "add"), ) + def get_success_url(self, obj, **kwargs): + return obj.get_admin_change_url() + create_alias_wizard = CreateAliasWizard( title=_("New alias"), diff --git a/djangocms_alias/models.py b/djangocms_alias/models.py index d7f4148..f56b477 100644 --- a/djangocms_alias/models.py +++ b/djangocms_alias/models.py @@ -17,7 +17,7 @@ from django.utils.translation import gettext_lazy as _ from parler.models import TranslatableModel, TranslatedFields -from .constants import CHANGE_CATEGORY_URL_NAME +from .constants import CHANGE_ALIAS_URL_NAME, CHANGE_CATEGORY_URL_NAME from .utils import is_versioning_enabled __all__ = [ @@ -123,6 +123,9 @@ def name(self): def is_in_use(self): return self.cms_plugins.exists() + def get_admin_change_url(self): + return admin_reverse(CHANGE_ALIAS_URL_NAME, args=[self.pk]) + @cached_property def objects_using(self): objects = set() diff --git a/tests/requirements/py311-djmain-cms41-default.txt b/tests/requirements/py311-djmain-cms41-default.txt index 0c6caf5..f8fed47 100644 --- a/tests/requirements/py311-djmain-cms41-default.txt +++ b/tests/requirements/py311-djmain-cms41-default.txt @@ -4,7 +4,7 @@ # # requirements/compile.py # -asgiref==3.7.2 +asgiref==3.8.1 # via django beautifulsoup4==4.12.2 # via bs4 diff --git a/tests/requirements/py311-djmain-cms41-versioning.txt b/tests/requirements/py311-djmain-cms41-versioning.txt index 0c6caf5..f8fed47 100644 --- a/tests/requirements/py311-djmain-cms41-versioning.txt +++ b/tests/requirements/py311-djmain-cms41-versioning.txt @@ -4,7 +4,7 @@ # # requirements/compile.py # -asgiref==3.7.2 +asgiref==3.8.1 # via django beautifulsoup4==4.12.2 # via bs4 diff --git a/tests/requirements/py311-djmain-cms4dev-default.txt b/tests/requirements/py311-djmain-cms4dev-default.txt index 34020ee..94a6a2a 100644 --- a/tests/requirements/py311-djmain-cms4dev-default.txt +++ b/tests/requirements/py311-djmain-cms4dev-default.txt @@ -4,7 +4,7 @@ # # requirements/compile.py # -asgiref==3.7.2 +asgiref==3.8.1 # via django beautifulsoup4==4.12.2 # via bs4 diff --git a/tests/requirements/py311-djmain-cms4dev-versioning.txt b/tests/requirements/py311-djmain-cms4dev-versioning.txt index 34020ee..94a6a2a 100644 --- a/tests/requirements/py311-djmain-cms4dev-versioning.txt +++ b/tests/requirements/py311-djmain-cms4dev-versioning.txt @@ -4,7 +4,7 @@ # # requirements/compile.py # -asgiref==3.7.2 +asgiref==3.8.1 # via django beautifulsoup4==4.12.2 # via bs4 diff --git a/tests/test_admin.py b/tests/test_admin.py index 3125990..c9f616a 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -553,10 +553,8 @@ def test_aliases_admin_entry_is_hidden(self): response = self.client.get(index_url) - unexpected_content = ( - '