add fix for messed up html at reminders, thanks to @brookst

This commit is contained in:
dadosch 2018-08-31 00:04:02 +02:00
parent efc57852d1
commit efb0157337

View File

@ -8,6 +8,8 @@ try:
except ImportError: except ImportError:
from django.urls import reverse from django.urls import reverse
from django.templatetags.static import static from django.templatetags.static import static
from django.utils.safestring import mark_safe
from django.utils.html import format_html, format_html_join
from .models import Correspondent, Tag, Document, Log from .models import Correspondent, Tag, Document, Log
@ -180,7 +182,7 @@ class DocumentAdmin(CommonAdmin):
) )
} }
) )
return r return mark_safe(r)
tags_.allow_tags = True tags_.allow_tags = True
def document(self, obj): def document(self, obj):
@ -201,15 +203,14 @@ class DocumentAdmin(CommonAdmin):
@staticmethod @staticmethod
def _html_tag(kind, inside=None, **kwargs): def _html_tag(kind, inside=None, **kwargs):
attributes = [] attributes = format_html_join(' ', '{}="{}"', kwargs.items())
for lft, rgt in kwargs.items():
attributes.append('{}="{}"'.format(lft, rgt))
if inside is not None: if inside is not None:
return "<{kind} {attributes}>{inside}</{kind}>".format( return format_html("<{kind} {attributes}>{inside}</{kind}>",
kind=kind, attributes=" ".join(attributes), inside=inside) kind=kind, attributes=attributes, inside=inside)
return "<{} {}/>".format(kind, " ".join(attributes))
return format_html("<{} {}/>", kind, attributes)
class LogAdmin(CommonAdmin): class LogAdmin(CommonAdmin):