Skip to content

Commit

Permalink
fix empty date issue if the alias has legacy empty data, code refact.
Browse files Browse the repository at this point in the history
  • Loading branch information
FreemanPancake committed Nov 4, 2024
1 parent 09e62ad commit 80e68fe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions djangocms_version_locking/monkeypatch/djangocms_alias/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ def _get_content_obj(self, obj: Alias):
return content_obj

def _get_edit_link(self, obj: Alias, request: HttpRequest, disabled: bool = False):
if self._get_content_obj(obj):
obj_content = self._get_content_obj(obj)
if not obj_content:
# Don't display the link if it can't be edited, as the content is empty.
return ""
version = proxy_model(self._get_content_obj(obj).versions.all()[0], self._get_content_obj(obj))
version = proxy_model(obj_content.versions.all()[0], obj_content)

if version.state not in (DRAFT, PUBLISHED):
# Don't display the link if it can't be edited
Expand Down Expand Up @@ -73,10 +74,11 @@ def _get_edit_link(self, obj: Alias, request: HttpRequest, disabled: bool = Fals
)

def _get_manage_versions_link(self, obj: Alias, request: HttpRequest, disabled: bool = False):
if self._get_content_obj(obj):
obj_content = self._get_content_obj(obj)
if not obj_content:
# Don't display the link if it can't find version list urls, as the content is empty.
return ""
url = version_list_url(self._get_content_obj(obj))
url = version_list_url(obj_content)
return self.admin_action_button(
url,
icon="list-ol",
Expand Down

0 comments on commit 80e68fe

Please sign in to comment.