Improve tag appeareance and elimate obsolete tag block color widget
This commit is contained in:
@@ -12,8 +12,7 @@ from acls.permissions import ACLS_VIEW_ACL
|
||||
from taggit.models import Tag
|
||||
from taggit.managers import TaggableManager
|
||||
|
||||
from .widgets import get_tags_inline_widget_simple
|
||||
from .widgets import tag_color_block
|
||||
from .widgets import (get_tags_inline_widget_simple, single_tag_widget)
|
||||
from .permissions import (PERMISSION_TAG_CREATE, PERMISSION_TAG_ATTACH,
|
||||
PERMISSION_TAG_REMOVE, PERMISSION_TAG_DELETE, PERMISSION_TAG_EDIT,
|
||||
PERMISSION_TAG_VIEW)
|
||||
@@ -32,12 +31,8 @@ tag_acl_list = {'text': _(u'ACLs'), 'view': 'tag_acl_list', 'args': 'object.pk',
|
||||
|
||||
register_model_list_columns(Tag, [
|
||||
{
|
||||
'name': _(u'color'),
|
||||
'attribute': encapsulate(lambda x: tag_color_block(x))
|
||||
},
|
||||
{
|
||||
'name': _(u'color name'),
|
||||
'attribute': encapsulate(lambda x: x.tagproperties_set.get().get_color_display()),
|
||||
'name': _(u'preview'),
|
||||
'attribute': encapsulate(lambda x: single_tag_widget(x))
|
||||
},
|
||||
{
|
||||
'name': _(u'tagged items'),
|
||||
|
||||
@@ -98,6 +98,7 @@ def tag_list(request, queryset=None, extra_context=None):
|
||||
'title': _(u'tags'),
|
||||
'hide_link': True,
|
||||
'multi_select_as_buttons': True,
|
||||
'hide_object': True,
|
||||
}
|
||||
if extra_context:
|
||||
context.update(extra_context)
|
||||
|
||||
@@ -6,6 +6,7 @@ def get_tags_inline_widget(document):
|
||||
"""
|
||||
A tag widget that includes the total tag count for a given document
|
||||
"""
|
||||
# TODO: merge widgets
|
||||
tags_template = []
|
||||
tag_count = document.tags.count()
|
||||
if tag_count:
|
||||
@@ -21,8 +22,7 @@ def get_tags_inline_widget(document):
|
||||
|
||||
def get_tags_inline_widget_simple(document):
|
||||
"""
|
||||
A tag widget that only displayes the rectangular colored boxes for a
|
||||
given document
|
||||
A tag widget that displays the tags for the given document
|
||||
"""
|
||||
tags_template = []
|
||||
|
||||
@@ -30,12 +30,20 @@ def get_tags_inline_widget_simple(document):
|
||||
if tag_count:
|
||||
tags_template.append('<ul class="tags">')
|
||||
for tag in document.tags.all():
|
||||
tags_template.append('<li style="background: %s">%s</li>' % (tag.tagproperties_set.get().get_color_code(), tag.name))
|
||||
tags_template.append(get_single_tag_template(tag))
|
||||
|
||||
tags_template.append('</ul>')
|
||||
|
||||
return mark_safe(u''.join(tags_template))
|
||||
|
||||
|
||||
def tag_color_block(tag):
|
||||
return mark_safe(u'<div style="width: 20px; height: 20px; border: 1px solid black; background: %s;"></div>' % tag.tagproperties_set.get().get_color_code())
|
||||
def single_tag_widget(tag):
|
||||
tags_template = []
|
||||
tags_template.append('<ul class="tags">')
|
||||
tags_template.append(get_single_tag_template(tag))
|
||||
tags_template.append('</ul>')
|
||||
return mark_safe(u''.join(tags_template))
|
||||
|
||||
|
||||
def get_single_tag_template(tag):
|
||||
return '<li style="background: %s">%s</li>' % (tag.tagproperties_set.get().get_color_code(), tag.name.replace(u' ', u' '))
|
||||
|
||||
Reference in New Issue
Block a user