kopia lustrzana https://github.com/wagtail/wagtail
user_can_edit_snippets should return False for administrators if no snippet models exist, and thus hide the Snippets menu option - fixes #204
rodzic
dd31552e23
commit
3d23bc2b25
|
@ -27,6 +27,7 @@ Changelog
|
|||
* Fix: Filter objects are cached to avoid a database hit every time an {% image %} tag is compiled
|
||||
* Fix: Moving or changing a site root page no longer causes URLs for subpages to change to 'None'
|
||||
* Fix: Eliminated raw SQL queries from wagtailcore / wagtailadmin, to ensure cross-database compatibility
|
||||
* Fix: Snippets menu item is hidden for administrators if no snippet types are defined
|
||||
|
||||
0.2 (11.03.2014)
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -19,10 +19,12 @@ def user_can_edit_snippet_type(user, content_type):
|
|||
|
||||
def user_can_edit_snippets(user):
|
||||
""" true if user has any permission related to any content type registered as a snippet type """
|
||||
snippet_content_types = get_snippet_content_types()
|
||||
if user.is_active and user.is_superuser:
|
||||
return True
|
||||
# admin can edit snippets iff any snippet types exist
|
||||
return bool(snippet_content_types)
|
||||
|
||||
permissions = Permission.objects.filter(content_type__in=get_snippet_content_types()).select_related('content_type')
|
||||
permissions = Permission.objects.filter(content_type__in=snippet_content_types).select_related('content_type')
|
||||
for perm in permissions:
|
||||
permission_name = "%s.%s" % (perm.content_type.app_label, perm.codename)
|
||||
if user.has_perm(permission_name):
|
||||
|
|
Ładowanie…
Reference in New Issue