<s> """<STR_LIT>""" <EOL> from django import template <EOL> from django . core . urlresolvers import reverse <EOL> from admin_tools . utils import get_admin_site_name <EOL> from admin_tools . menu import items <EOL> from admin_tools . menu . models import Bookmark <EOL> from admin_tools . menu . utils import get_admin_menu <EOL> register = template . Library ( ) <EOL> tag_func = register . inclusion_tag ( <EOL> '<STR_LIT>' , <EOL> takes_context = True <EOL> ) <EOL> def admin_tools_render_menu ( context , menu = None ) : <EOL> """<STR_LIT>""" <EOL> if menu is None : <EOL> menu = get_admin_menu ( context ) <EOL> menu . init_with_context ( context ) <EOL> has_bookmark_item = False <EOL> bookmark = None <EOL> if len ( [ c for c in menu . children if isinstance ( c , items . Bookmarks ) ] ) > <NUM_LIT:0> : <EOL> has_bookmark_item = True <EOL> url = context [ '<STR_LIT>' ] . get_full_path ( ) <EOL> try : <EOL> bookmark = Bookmark . objects . filter ( <EOL> user = context [ '<STR_LIT>' ] . user , url = url <EOL> ) [ <NUM_LIT:0> ] <EOL> except : <EOL> pass <EOL> context . update ( { <EOL> '<STR_LIT>' : menu . template , <EOL> '<STR_LIT>' : menu , <EOL> '<STR_LIT>' : has_bookmark_item , <EOL> '<STR_LIT>' : bookmark , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' % get_admin_site_name ( context ) ) , <EOL> } ) <EOL> return context <EOL> admin_tools_render_menu = tag_func ( admin_tools_render_menu ) <EOL> def admin_tools_render_menu_item ( context , item , index = None ) : <EOL> """<STR_LIT>""" <EOL> item . init_with_context ( context ) <EOL> context . update ( { <EOL> '<STR_LIT>' : item . template , <EOL> '<STR_LIT>' : item , <EOL> '<STR_LIT:index>' : index , <EOL> '<STR_LIT>' : item . is_selected ( context [ '<STR_LIT>' ] ) , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' % get_admin_site_name ( context ) ) , <EOL> } ) <EOL> return context <EOL> admin_tools_render_menu_item = tag_func ( admin_tools_render_menu_item ) <EOL> def admin_tools_render_menu_css ( context , menu = None ) : <EOL> """<STR_LIT>""" <EOL> if menu is None : <EOL> menu = get_admin_menu ( context ) <EOL> context . update ( { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : menu . Media . css , <EOL> } ) <EOL> return context <EOL> admin_tools_render_menu_css = tag_func ( admin_tools_render_menu_css ) </s>
