def get_menu(context): if not context['request'].user.is_staff: return [None, None, None] # - an instance of the menu menu_cls = getattr(settings, 'CLIENT_ADMIN_MENU', None) if menu_cls: try: mod, inst = menu_cls.rsplit('.', 1) mod = import_module(mod) menu = getattr(mod, inst)() except: menu = Menu() else: menu = Menu() menu.init_with_context(context) has_bookmark_item = False bookmark = None if len([c for c in menu.children if isinstance(c, items.Bookmarks)]) > 0: # - if the user has any bookmarks has_bookmark_item = True url = context['request'].get_full_path() try: # - this user's bookmark of this page bookmark = Bookmark.objects.filter(user=context['request'].user, url=url)[0] except: pass return [menu, has_bookmark_item, bookmark]
def get_menu(context): if not context['request'].user.is_staff: return [None, None, None] # - an instance of the menu menu = Menu() menu.init_with_context(context) has_bookmark_item = False bookmark = None if len([c for c in menu.children if isinstance(c, items.Bookmarks)]) > 0: # - if the user has any bookmarks has_bookmark_item = True url = context['request'].get_full_path() try: # - this user's bookmark of this page bookmark = Bookmark.objects.filter(user=context['request'].user, url=url)[0] except: pass return [menu, has_bookmark_item, bookmark]