Fix horizontal list link widget rendering
This commit is contained in:
@@ -75,6 +75,9 @@ class Link(object):
|
|||||||
resolved_link = ResolvedLink()
|
resolved_link = ResolvedLink()
|
||||||
resolved_link.text = self.text
|
resolved_link.text = self.text
|
||||||
resolved_link.sprite = self.sprite
|
resolved_link.sprite = self.sprite
|
||||||
|
resolved_link.icon = self.icon
|
||||||
|
resolved_link.permissions = self.permissions
|
||||||
|
|
||||||
try:
|
try:
|
||||||
#args, kwargs = resolve_arguments(context, self.get('args', {}))
|
#args, kwargs = resolve_arguments(context, self.get('args', {}))
|
||||||
args, kwargs = resolve_arguments(context, self.args)
|
args, kwargs = resolve_arguments(context, self.args)
|
||||||
@@ -167,24 +170,7 @@ def bind_links(sources, links, menu_name=None, position=0):
|
|||||||
link_binding[menu_name][source]['links'].extend(links)
|
link_binding[menu_name][source]['links'].extend(links)
|
||||||
|
|
||||||
|
|
||||||
def register_multi_item_links(src, links, menu_name=None):
|
def register_top_menu(name, link, position=None):
|
||||||
"""
|
|
||||||
Register a multiple item action action to be displayed in the
|
|
||||||
generic list template
|
|
||||||
"""
|
|
||||||
# TODO: simplify by removing __iter__ support
|
|
||||||
multi_object_navigation.setdefault(menu_name, {})
|
|
||||||
if hasattr(src, '__iter__'):
|
|
||||||
for one_src in src:
|
|
||||||
multi_object_navigation[menu_name].setdefault(one_src, {'links': []})
|
|
||||||
multi_object_navigation[menu_name][one_src]['links'].extend(links)
|
|
||||||
else:
|
|
||||||
multi_object_navigation[menu_name].setdefault(src, {'links': []})
|
|
||||||
multi_object_navigation[menu_name][src]['links'].extend(links)
|
|
||||||
|
|
||||||
|
|
||||||
#def register_top_menu(name, link, children_views=None, children_path_regex=None, children_view_regex=None, position=None):
|
|
||||||
def register_top_menu(name, link, children_view_regex=None, position=None):
|
|
||||||
"""
|
"""
|
||||||
Register a new menu entry for the main menu displayed at the top
|
Register a new menu entry for the main menu displayed at the top
|
||||||
of the page
|
of the page
|
||||||
@@ -216,6 +202,23 @@ def register_sidebar_template(source_list, template_name):
|
|||||||
sidebar_templates[source].append(template_name)
|
sidebar_templates[source].append(template_name)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
def register_multi_item_links(src, links, menu_name=None):
|
||||||
|
"""
|
||||||
|
Register a multiple item action action to be displayed in the
|
||||||
|
generic list template
|
||||||
|
"""
|
||||||
|
# TODO: simplify by removing __iter__ support
|
||||||
|
multi_object_navigation.setdefault(menu_name, {})
|
||||||
|
if hasattr(src, '__iter__'):
|
||||||
|
for one_src in src:
|
||||||
|
multi_object_navigation[menu_name].setdefault(one_src, {'links': []})
|
||||||
|
multi_object_navigation[menu_name][one_src]['links'].extend(links)
|
||||||
|
else:
|
||||||
|
multi_object_navigation[menu_name].setdefault(src, {'links': []})
|
||||||
|
multi_object_navigation[menu_name][src]['links'].extend(links)
|
||||||
|
|
||||||
|
|
||||||
def get_context_object_navigation_links(context, menu_name=None, links_dict=object_navigation):
|
def get_context_object_navigation_links(context, menu_name=None, links_dict=object_navigation):
|
||||||
request = Variable('request').resolve(context)
|
request = Variable('request').resolve(context)
|
||||||
current_path = request.META['PATH_INFO']
|
current_path = request.META['PATH_INFO']
|
||||||
|
|||||||
@@ -27,24 +27,6 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class TopMenuNavigationNode(Node):
|
class TopMenuNavigationNode(Node):
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
#request = Variable('request').resolve(context)
|
|
||||||
#current_path = request.META['PATH_INFO']
|
|
||||||
#current_view = resolve_to_name(current_path)
|
|
||||||
|
|
||||||
#all_menu_links = []#[entry.get('link', {}) for entry in top_menu_entries]
|
|
||||||
#menu_links = resolve_links(context, all_menu_links, current_view, current_path)
|
|
||||||
|
|
||||||
#for index, link in enumerate(top_menu_entries):
|
|
||||||
# #if current_view in link.get('children_views', []):
|
|
||||||
# # menu_links[index]['active'] = True
|
|
||||||
# #for child_path_regex in link.get('children_path_regex', []):
|
|
||||||
# # if re.compile(child_path_regex).match(current_path.lstrip('/')):
|
|
||||||
# # menu_links[index]['active'] = True
|
|
||||||
# #for children_view_regex in link.get('children_view_regex', []):
|
|
||||||
# # if re.compile(children_view_regex).match(current_view):
|
|
||||||
# # menu_links[index]['active'] = True
|
|
||||||
# pass
|
|
||||||
#context['menu_links'] = []#menu_links
|
|
||||||
context['menu_links'] = [menu.get('link').resolve(context) for menu in main_menu.getchildren()]
|
context['menu_links'] = [menu.get('link').resolve(context) for menu in main_menu.getchildren()]
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@@ -84,10 +66,10 @@ def get_object_navigation_links(parser, token):
|
|||||||
@register.inclusion_tag('generic_navigation.html', takes_context=True)
|
@register.inclusion_tag('generic_navigation.html', takes_context=True)
|
||||||
def object_navigation_template(context):
|
def object_navigation_template(context):
|
||||||
new_context = copy.copy(context)
|
new_context = copy.copy(context)
|
||||||
#new_context.update({
|
new_context.update({
|
||||||
# 'horizontal': True,
|
'horizontal': True,
|
||||||
# 'object_navigation_links': get_object_navigation_links(context)
|
'object_navigation_links': get_context_object_navigation_links(context)
|
||||||
#})
|
})
|
||||||
return new_context
|
return new_context
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +88,7 @@ def get_multi_item_links(parser, token):
|
|||||||
def get_multi_item_links_form(context):
|
def get_multi_item_links_form(context):
|
||||||
new_context = copy.copy(context)
|
new_context = copy.copy(context)
|
||||||
new_context.update({
|
new_context.update({
|
||||||
'form': MultiItemForm(actions=[(link['url'], link['text']) for link in get_context_object_navigation_links(context, links_dict=multi_object_navigation)]),
|
'form': MultiItemForm(actions=[(link.url, link.text) for link in get_context_object_navigation_links(context, links_dict=multi_object_navigation)]),
|
||||||
'title': _(u'Selected item actions:'),
|
'title': _(u'Selected item actions:'),
|
||||||
'form_action': reverse('multi_object_action_view'),
|
'form_action': reverse('multi_object_action_view'),
|
||||||
'submit_method': 'get',
|
'submit_method': 'get',
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ from django.template import RequestContext, Variable
|
|||||||
|
|
||||||
from permissions.models import Permission
|
from permissions.models import Permission
|
||||||
|
|
||||||
#from .templatetags.navigation_tags import resolve_links
|
|
||||||
from .utils import resolve_to_name
|
from .utils import resolve_to_name
|
||||||
|
|
||||||
|
|
||||||
@@ -29,23 +28,11 @@ def button_navigation_widget(request, link):
|
|||||||
|
|
||||||
def render_widget(request, link):
|
def render_widget(request, link):
|
||||||
context = RequestContext(request)
|
context = RequestContext(request)
|
||||||
|
resolved_link = link.resolve(context)
|
||||||
request = Variable('request').resolve(context)
|
|
||||||
current_path = request.META['PATH_INFO']
|
|
||||||
current_view = resolve_to_name(current_path)
|
|
||||||
|
|
||||||
query_string = urlparse.urlparse(request.get_full_path()).query or urlparse.urlparse(request.META.get('HTTP_REFERER', u'/')).query
|
|
||||||
parsed_query_string = urlparse.parse_qs(query_string)
|
|
||||||
|
|
||||||
links = []#resolve_links(context, [link], current_view, current_path, parsed_query_string)
|
|
||||||
if links:
|
|
||||||
link = links[0]
|
|
||||||
return mark_safe(u'<a style="text-decoration:none; margin-right: 10px;" href="%(url)s"><button style="vertical-align: top; padding: 1px; width: 110px; height: 100px; margin: 10px;"><img src="%(static_url)simages/icons/%(icon)s" alt="%(image_alt)s" /><p style="margin: 0px 0px 0px 0px;">%(string)s</p></button></a>' % {
|
return mark_safe(u'<a style="text-decoration:none; margin-right: 10px;" href="%(url)s"><button style="vertical-align: top; padding: 1px; width: 110px; height: 100px; margin: 10px;"><img src="%(static_url)simages/icons/%(icon)s" alt="%(image_alt)s" /><p style="margin: 0px 0px 0px 0px;">%(string)s</p></button></a>' % {
|
||||||
'url': reverse(link['view']) if 'view' in link else link['url'],
|
'url': resolved_link.url,
|
||||||
'icon': link.getattr('icon', 'link_button.png'),
|
'icon': getattr(resolved_link, 'icon', 'link_button.png'),
|
||||||
'static_url': settings.STATIC_URL,
|
'static_url': settings.STATIC_URL,
|
||||||
'string': capfirst(link['text']),
|
'string': capfirst(resolved_link.text),
|
||||||
'image_alt': _(u'icon'),
|
'image_alt': _(u'icon'),
|
||||||
})
|
})
|
||||||
else:
|
|
||||||
return u''
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ register_model_list_columns(Document, [
|
|||||||
bind_links([Tag], [tag_tagged_item_list, tag_edit, tag_delete, tag_acl_list])
|
bind_links([Tag], [tag_tagged_item_list, tag_edit, tag_delete, tag_acl_list])
|
||||||
register_multi_item_links(['tag_list'], [tag_multiple_delete])
|
register_multi_item_links(['tag_list'], [tag_multiple_delete])
|
||||||
bind_links([Tag, 'tag_list', 'tag_create'], [tag_list, tag_create], menu_name='secondary_menu')
|
bind_links([Tag, 'tag_list', 'tag_create'], [tag_list, tag_create], menu_name='secondary_menu')
|
||||||
register_top_menu('tags', link=Link(text=_(u'tags'), view='tag_list', sprite='tag_blue'), children_view_regex=[r'^tag_(list|create|delete|edit|tagged|acl)'])
|
register_top_menu('tags', link=Link(text=_(u'tags'), view='tag_list', sprite='tag_blue', children_view_regex=[r'^tag_(list|create|delete|edit|tagged|acl)']))
|
||||||
|
|
||||||
bind_links([Document], [tag_document_list], menu_name='form_header')
|
bind_links([Document], [tag_document_list], menu_name='form_header')
|
||||||
bind_links(['document_tags', 'tag_remove', 'tag_multiple_remove', 'tag_attach'], [tag_attach], menu_name='sidebar')
|
bind_links(['document_tags', 'tag_remove', 'tag_multiple_remove', 'tag_attach'], [tag_attach], menu_name='sidebar')
|
||||||
|
|||||||
Reference in New Issue
Block a user