Skip to content

Commit

Permalink
fix empty date issue if the alias has legacy empty date.
Browse files Browse the repository at this point in the history
  • Loading branch information
FreemanPancake committed Nov 4, 2024
1 parent c448c9a commit 09e62ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions djangocms_version_locking/cms_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@


def add_alias_version_lock(obj, field):
version = obj.versions.all()[0]
# add None obj check, if the legacy data has empty value.
lock_icon = ""
if version.state == DRAFT and version_is_locked(version):
lock_icon = mark_safe('<span class="cms-icon cms-icon-lock"></span>')
if obj:
version = obj.versions.all()[0]
if version.state == DRAFT and version_is_locked(version):
lock_icon = mark_safe('<span class="cms-icon cms-icon-lock"></span>')
return format_html(
"{is_locked}{field_value}",
is_locked=lock_icon,
field_value=getattr(obj, field),
field_value=getattr(obj, field, '-'),
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ 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):
# 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))

if version.state not in (DRAFT, PUBLISHED):
Expand Down Expand Up @@ -70,6 +73,9 @@ 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):
# 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))
return self.admin_action_button(
url,
Expand Down

0 comments on commit 09e62ad

Please sign in to comment.