forked from ungleich-public/dynamicweb
fix migration history
This commit is contained in:
parent
bb17a89507
commit
8bb2d372c2
59 changed files with 4326 additions and 234 deletions
|
|
@ -508,3 +508,49 @@ def has_plugin_permission(user, plugin_type, permission_type):
|
|||
# Grant all permissions for uninstalled plugins, so they do not block
|
||||
# emptying placeholders.
|
||||
return True
|
||||
|
||||
|
||||
def has_page_permission(user, page, permission, site=None):
|
||||
"""
|
||||
Backwards-compatible wrapper for the legacy django-cms
|
||||
has_page_permission() API.
|
||||
|
||||
Legacy callers pass short permission names such as:
|
||||
add
|
||||
change
|
||||
delete
|
||||
publish
|
||||
|
||||
Modern django-cms uses action names such as:
|
||||
add_page
|
||||
change_page
|
||||
delete_page
|
||||
publish_page
|
||||
"""
|
||||
if not user or not user.is_authenticated:
|
||||
return False
|
||||
|
||||
if user.is_superuser or not get_cms_setting('PERMISSION'):
|
||||
return True
|
||||
|
||||
action_map = {
|
||||
'add': 'add_page',
|
||||
'change': 'change_page',
|
||||
'delete': 'delete_page',
|
||||
'publish': 'publish_page',
|
||||
'move': 'move_page',
|
||||
'view': 'view_page',
|
||||
'change_advanced_settings': 'change_page_advanced_settings',
|
||||
'change_permissions': 'change_page_permissions',
|
||||
}
|
||||
|
||||
action = action_map.get(permission, permission)
|
||||
|
||||
from .page_permissions import has_generic_permission
|
||||
|
||||
return has_generic_permission(
|
||||
page=page,
|
||||
user=user,
|
||||
action=action,
|
||||
site=site,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue