Skip to content

Commit

Permalink
fix menuitem changelist layout issue
Browse files Browse the repository at this point in the history
  • Loading branch information
FreemanPancake committed Oct 29, 2024
1 parent b7b9074 commit f02ed8b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
44 changes: 35 additions & 9 deletions djangocms_navigation/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from django.template.response import TemplateResponse
from django.urls import path, re_path, reverse, reverse_lazy
from django.utils.html import format_html, format_html_join
from django.utils.safestring import mark_safe
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from django.views.i18n import JavaScriptCatalog
Expand All @@ -26,6 +27,8 @@
from djangocms_versioning.models import Version
from treebeard.admin import TreeAdmin

from cms.admin.utils import ChangeListActionsMixin

from .compat import TREEBEARD_4_5
from .conf import TREE_MAX_RESULT_PER_PAGE_COUNT
from .filters import LanguageFilter
Expand All @@ -39,10 +42,16 @@


try:
from djangocms_version_locking.helpers import (
content_is_unlocked_for_user,
version_is_locked,
)
if CMS_41:
from djangocms_versioning.helpers import (
content_is_unlocked_for_user,
version_is_locked,
)
else:
from djangocms_version_locking.helpers import (
content_is_unlocked_for_user,
version_is_locked,
)

using_version_lock = True
LOCK_MESSAGE = _(
Expand Down Expand Up @@ -140,7 +149,10 @@ def get_list_display(self, request):
def is_locked(self, obj):
version = self.get_version(obj)
if version.state == DRAFT and version_is_locked(version):
return render_to_string("djangocms_version_locking/admin/locked_icon.html")
if CMS_41:
return mark_safe('<span class="cms-icon cms-icon-lock"></span>')
else:
return render_to_string("djangocms_version_locking/admin/locked_icon.html")
return ""

def _get_references_link(self, obj, request):
Expand Down Expand Up @@ -264,7 +276,7 @@ def get_menuitem_link(self, obj):


@admin.register(MenuItem)
class MenuItemAdmin(TreeAdmin):
class MenuItemAdmin(ChangeListActionsMixin, TreeAdmin):
form = MenuItemForm
menu_content_model = MenuContent
menu_model = Menu
Expand Down Expand Up @@ -391,6 +403,17 @@ def _get_edit_link(self, obj, request, disabled=False):
args=[request.menu_content_id, obj.id]
)

if CMS_41:
return self.admin_action_button(
edit_url,
icon="pencil",
title=_("Edit"),
name="edit",
disabled=disabled,
action="post",
keepsideframe=False,
)

return render_to_string(
"djangocms_versioning/admin/icons/edit_icon.html",
{"url": edit_url, "disabled": disabled, "object_id": obj.id}
Expand All @@ -405,9 +428,12 @@ def _get_delete_link(self, obj, request, disabled=False):
)

if CMS_41:
return render_to_string(
"djangocms_versioning/admin/icons/discard_icon.html",
{"url": delete_url, "disabled": disabled, "object_id": obj.id}
return self.admin_action_button(
delete_url,
icon="bin",
title=_("Discord"),
name="discard",
disabled=disabled,
)
else:
return render_to_string(
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements/dj42_cms41.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ https://github.com/FreemanPancake/djangocms-version-locking/tarball/feature/djan
https://github.com/django-cms/djangocms-moderation/tarball/master#egg=djangocms-moderation
https://github.com/FidelityInternational/djangocms-references/tarball/feat/cms41-compat#egg=djangocms-references
https://github.com/django-cms/djangocms-alias/tarball/master#egg=djangocms-alias
https://github.com/django-cms/djangocms-snippet/tarball/master#egg=djangocms-snippet==5.0.0.a1
https://github.com/django-cms/djangocms-snippet/tarball/master#egg=djangocms-snippet

0 comments on commit f02ed8b

Please sign in to comment.