diff --git a/mayan/apps/tags/apps.py b/mayan/apps/tags/apps.py index 71a1e51592..c334ae25e3 100644 --- a/mayan/apps/tags/apps.py +++ b/mayan/apps/tags/apps.py @@ -23,7 +23,7 @@ from .permissions import ( PERMISSION_TAG_ATTACH, PERMISSION_TAG_DELETE, PERMISSION_TAG_EDIT, PERMISSION_TAG_REMOVE, PERMISSION_TAG_VIEW ) -from .widgets import get_tags_inline_widget_simple, single_tag_widget +from .widgets import widget_inline_tags, widget_single_tag class TagsApp(MayanAppConfig): @@ -35,9 +35,9 @@ class TagsApp(MayanAppConfig): APIEndPoint('tags') - SourceColumn(source=Document, label=_('Tags'), attribute=encapsulate(lambda document: get_tags_inline_widget_simple(document))) + SourceColumn(source=Document, label=_('Tags'), attribute=encapsulate(lambda document: widget_inline_tags(document))) - SourceColumn(source=Tag, label=_('Preview'), attribute=encapsulate(lambda tag: single_tag_widget(tag))) + SourceColumn(source=Tag, label=_('Preview'), attribute=encapsulate(lambda tag: widget_single_tag(tag))) SourceColumn(source=Tag, label=_('Tagged items'), attribute=encapsulate(lambda tag: tag.documents.count())) class_permissions(Document, [ diff --git a/mayan/apps/tags/widgets.py b/mayan/apps/tags/widgets.py index 8c3232f845..fb22fd5c83 100644 --- a/mayan/apps/tags/widgets.py +++ b/mayan/apps/tags/widgets.py @@ -4,7 +4,7 @@ from django.utils.html import escape from django.utils.safestring import mark_safe -def get_tags_inline_widget_simple(document): +def widget_inline_tags(document): """ A tag widget that displays the tags for the given document """ @@ -13,16 +13,14 @@ def get_tags_inline_widget_simple(document): tag_count = document.tags.count() if tag_count: for tag in document.tags.all(): - tags_template.append(get_single_tag_template(tag)) + tags_template.append(widget_single_tag(tag)) return mark_safe(''.join(tags_template)) -def single_tag_widget(tag): - tags_template = [] - tags_template.append(get_single_tag_template(tag)) - return mark_safe(''.join(tags_template)) - - -def get_single_tag_template(tag): - return '%s' % (tag.get_color_code(), escape(tag.label).replace(' ', ' ')) +def widget_single_tag(tag): + return mark_safe( + ''' + {} + '''.format(tag.get_color_code(), escape(tag.label).replace(' ', ' ')) + )