mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-08-14 01:58:28 +02:00
Markdown for Knowledge base, ticket and comments.
Removed markdown-deux
This commit is contained in:
committed by
Jachym Cepicky
parent
4fb6c40c4e
commit
d4f1f85b29
@ -19,11 +19,37 @@ from io import StringIO
|
||||
import re
|
||||
import datetime
|
||||
|
||||
from django.utils.safestring import mark_safe
|
||||
from markdown import markdown
|
||||
from markdown.extensions import Extension
|
||||
|
||||
|
||||
import uuid
|
||||
|
||||
from .templated_email import send_templated_mail
|
||||
|
||||
|
||||
class EscapeHtml(Extension):
|
||||
def extendMarkdown(self, md, md_globals):
|
||||
del md.preprocessors['html_block']
|
||||
del md.inlinePatterns['html']
|
||||
|
||||
|
||||
def get_markdown(text):
|
||||
if not text:
|
||||
return ""
|
||||
|
||||
return mark_safe(
|
||||
markdown(
|
||||
text,
|
||||
extensions=[
|
||||
EscapeHtml(), 'markdown.extensions.nl2br',
|
||||
'markdown.extensions.fenced_code'
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class Queue(models.Model):
|
||||
"""
|
||||
A queue is a collection of tickets into what would generally be business
|
||||
@ -717,6 +743,9 @@ class Ticket(models.Model):
|
||||
queue = '-'.join(parts[0:-1])
|
||||
return queue, parts[-1]
|
||||
|
||||
def get_markdown(self):
|
||||
return get_markdown(self.description)
|
||||
|
||||
|
||||
class FollowUpManager(models.Manager):
|
||||
|
||||
@ -768,8 +797,10 @@ class FollowUp(models.Model):
|
||||
_('Public'),
|
||||
blank=True,
|
||||
default=False,
|
||||
help_text=_('Public tickets are viewable by the submitter and all '
|
||||
'staff, but non-public tickets can only be seen by staff.'),
|
||||
help_text=_(
|
||||
'Public tickets are viewable by the submitter and all '
|
||||
'staff, but non-public tickets can only be seen by staff.'
|
||||
),
|
||||
)
|
||||
|
||||
user = models.ForeignKey(
|
||||
@ -821,6 +852,9 @@ class FollowUp(models.Model):
|
||||
t.save()
|
||||
super(FollowUp, self).save(*args, **kwargs)
|
||||
|
||||
def get_markdown(self):
|
||||
return get_markdown(self.comment)
|
||||
|
||||
|
||||
class TicketChange(models.Model):
|
||||
"""
|
||||
@ -1161,6 +1195,9 @@ class KBItem(models.Model):
|
||||
from django.urls import reverse
|
||||
return reverse('helpdesk:kb_item', args=(self.id,))
|
||||
|
||||
def get_markdown(self):
|
||||
return get_markdown(self.answer)
|
||||
|
||||
|
||||
class SavedSearch(models.Model):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user