perf: ticket markdown (#9325)

Co-authored-by: feng <1304903146@qq.com>
pull/9327/head
fit2bot 2 years ago committed by GitHub
parent 56d533c802
commit 6a9f1978bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
from html import escape import html2text
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.template.loader import render_to_string from django.template.loader import render_to_string
@ -67,7 +67,7 @@ class BaseHandler:
if state != TicketState.approved: if state != TicketState.approved:
return diff_context return diff_context
if self.ticket.type == TicketType.apply_asset: if self.ticket.type != TicketType.apply_asset:
return diff_context return diff_context
# 企业微信钉钉审批不做diff # 企业微信钉钉审批不做diff
@ -112,5 +112,4 @@ class BaseHandler:
@staticmethod @staticmethod
def safe_html_script(unsafe_html): def safe_html_script(unsafe_html):
safe_html = escape(unsafe_html) return html2text.html2text(unsafe_html)
return safe_html

@ -399,6 +399,9 @@ class Ticket(StatusMixin, JMSBaseModel):
elif isinstance(field, related.ForeignKey): elif isinstance(field, related.ForeignKey):
value = self.rel_snapshot[name] value = self.rel_snapshot[name]
elif isinstance(field, related.ManyToManyField): elif isinstance(field, related.ManyToManyField):
if isinstance(self.rel_snapshot[name], str):
value = self.rel_snapshot[name]
elif isinstance(self.rel_snapshot[name], list):
value = ','.join(self.rel_snapshot[name]) value = ','.join(self.rel_snapshot[name])
elif isinstance(value, list): elif isinstance(value, list):
value = ', '.join(value) value = ', '.join(value)

Loading…
Cancel
Save