Skip to content

Commit

Permalink
fix: get_absolute_url method not found while creating new alias and…
Browse files Browse the repository at this point in the history
… category from wizard button.
  • Loading branch information
joshyu committed Aug 20, 2024
1 parent 3dfa143 commit 7fa065c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

Unreleased
==========
* fix: `get_absolute_url` method not found while creating new alias and category from wizard button.


2.0.1 (2024-03-27)
==================

Expand Down
6 changes: 6 additions & 0 deletions djangocms_alias/cms_wizards.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@
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):
return user.has_perm(
get_model_permission_codename(Category, "add"),
)

def get_success_url(self, obj, **kwargs):
return obj.get_admin_change_url()


create_alias_wizard = CreateAliasWizard(
Expand Down
5 changes: 4 additions & 1 deletion djangocms_alias/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = [
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7fa065c

Please sign in to comment.