Skip to content

Commit

Permalink
fix: Do not double-check permissions (#124)
Browse files Browse the repository at this point in the history
* fix: Do not double-check permissions

---------

Co-authored-by: Leonardo Cavallucci <[email protected]>
  • Loading branch information
fsbraun and protoroto authored Jan 15, 2025
1 parent b7ee703 commit 3bf3244
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
1 change: 1 addition & 0 deletions changes/123.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not double-check permissions
13 changes: 2 additions & 11 deletions djangocms_page_sitemap/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from cms.toolbar.items import Break
from cms.toolbar_base import CMSToolbar
from cms.toolbar_pool import toolbar_pool
from cms.utils.conf import get_cms_setting
from cms.utils.permissions import has_page_permission
from django.urls import NoReverseMatch, reverse
from django.utils.translation import gettext_lazy as _

Expand All @@ -24,16 +22,9 @@ def populate(self):
# we don't need this on page types
return

# check global permissions if CMS_PERMISSIONS is active
if get_cms_setting("PERMISSION"):
has_global_current_page_change_permission = has_page_permission(
self.request.user, self.request.current_page, "change"
)
else:
has_global_current_page_change_permission = False
# check if user has page edit permission
# check if user has page change permission (respects CMS_PERMISSION)
can_change = self.request.current_page and self.request.current_page.has_change_permission(self.request.user)
if has_global_current_page_change_permission or can_change:
if can_change:
not_edit_mode = not self.toolbar.edit_mode_active
current_page_menu = self.toolbar.get_or_create_menu("page")
position = current_page_menu.find_first(Break, identifier=PAGE_MENU_THIRD_BREAK) - 1
Expand Down

0 comments on commit 3bf3244

Please sign in to comment.