diff --git a/opentech/apply/home/wagtail_hooks.py b/opentech/apply/home/wagtail_hooks.py index 9de9cfd7c9d95d1840f9467d8533ea305c787f24..07ad3f9b3001bd54bbdee1ada3dbfd23defad8fc 100644 --- a/opentech/apply/home/wagtail_hooks.py +++ b/opentech/apply/home/wagtail_hooks.py @@ -1,5 +1,7 @@ from wagtail.core import hooks +from opentech.apply.users.groups import STAFF_GROUP_NAME + from .models import ApplyHomePage @@ -7,6 +9,15 @@ from .models import ApplyHomePage def exclude_fund_pages(parent_page, pages, request): # Don't allow editors to access the Apply pages in the explorer unless they know whats up if not request.user.is_superuser: - pages = pages.not_ancestor_of(ApplyHomePage.objects.first(), inclusive=True) + pages = pages.not_descendant_of(ApplyHomePage.objects.first(), inclusive=True) return pages + + +@hooks.register('construct_main_menu') +def hide_explorer_menu_item_from_frank(request, menu_items): + if not request.user.is_superuser: + groups = list(request.user.groups.all()) + # If the user is only in the staff group they should never see the explorer menu item + if len(groups) == 1 and groups[0].name == STAFF_GROUP_NAME: + menu_items[:] = [item for item in menu_items if item.name != 'explorer']