From 1cb66a7c6b6eedb71e0673132b065737cd2dfa0c Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 21 Jul 2017 17:22:20 -0400 Subject: [PATCH] Improve tag widget by moving the markup to its own template. Signed-off-by: Roberto Rosario --- mayan/apps/tags/templates/tags/tag_widget.html | 1 + mayan/apps/tags/widgets.py | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 mayan/apps/tags/templates/tags/tag_widget.html diff --git a/mayan/apps/tags/templates/tags/tag_widget.html b/mayan/apps/tags/templates/tags/tag_widget.html new file mode 100644 index 0000000000..6f903cb7cd --- /dev/null +++ b/mayan/apps/tags/templates/tags/tag_widget.html @@ -0,0 +1 @@ +{{ tag.label }} diff --git a/mayan/apps/tags/widgets.py b/mayan/apps/tags/widgets.py index ebe8926938..1256993ec7 100644 --- a/mayan/apps/tags/widgets.py +++ b/mayan/apps/tags/widgets.py @@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals from django import forms from django.apps import apps +from django.template.loader import render_to_string from django.utils.html import escape from django.utils.encoding import force_text from django.utils.html import format_html @@ -58,8 +59,4 @@ def widget_document_tags(document, user): def widget_single_tag(tag): - return mark_safe( - ''' - {} - '''.format(tag.color, escape(tag.label).replace(' ', ' ')) - ) + return render_to_string('tags/tag_widget.html', {'tag': tag})