mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-24 15:48:49 +01:00
Markdown for Knowledge base, ticket and comments.
Removed markdown-deux
This commit is contained in:
parent
4fb6c40c4e
commit
d4f1f85b29
@ -37,7 +37,6 @@ INSTALLED_APPS = [
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.humanize',
|
||||
'markdown_deux',
|
||||
'bootstrap4form',
|
||||
'helpdesk'
|
||||
]
|
||||
|
@ -57,7 +57,6 @@ errors with trying to create User settings.
|
||||
'django.contrib.sites', # Required for determining domain url for use in emails
|
||||
'django.contrib.admin', # Required for helpdesk admin/maintenance
|
||||
'django.contrib.humanize', # Required for elapsed time formatting
|
||||
'markdown_deux', # Required for Knowledgebase item formatting
|
||||
'bootstrap4form', # Required for nicer formatting of forms with the default templates
|
||||
'helpdesk', # This is us!
|
||||
)
|
||||
@ -114,21 +113,17 @@ errors with trying to create User settings.
|
||||
|
||||
Ideally, accessing http://MEDIA_URL/helpdesk/attachments/ will give you a 403 access denied error.
|
||||
|
||||
7. If it's not already installed, install ``markdown_deux`` and ensure it's in your ``INSTALLED_APPS``::
|
||||
|
||||
pip install django-markdown-deux
|
||||
|
||||
8. If you already have a view handling your logins, then great! If not, add the following to ``settings.py`` to get your Django installation to use the login view included in ``django-helpdesk``::
|
||||
7. If you already have a view handling your logins, then great! If not, add the following to ``settings.py`` to get your Django installation to use the login view included in ``django-helpdesk``::
|
||||
|
||||
LOGIN_URL = '/helpdesk/login/'
|
||||
|
||||
Alter the URL to suit your installation path.
|
||||
|
||||
9. Load initial e-mail templates, otherwise you will not be able to send e-mail::
|
||||
8. Load initial e-mail templates, otherwise you will not be able to send e-mail::
|
||||
|
||||
python manage.py loaddata emailtemplate.json
|
||||
|
||||
10. If you intend on using local mail directories for processing email into tickets, be sure to create the mail directory before adding it to the queue in the Django administrator interface. The default mail directory is ``/var/lib/mail/helpdesk/``. Ensure that the directory has appropriate permissions so that your Django/web server instance may read and write files from this directory.
|
||||
9. If you intend on using local mail directories for processing email into tickets, be sure to create the mail directory before adding it to the queue in the Django administrator interface. The default mail directory is ``/var/lib/mail/helpdesk/``. Ensure that the directory has appropriate permissions so that your Django/web server instance may read and write files from this directory.
|
||||
|
||||
Note that by default, any mail files placed in your local directory will be permanently deleted after being successfully processed. It is strongly recommended that you take further steps to save emails if you wish to retain backups.
|
||||
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -77,3 +77,9 @@ Add your custom styles here
|
||||
}
|
||||
#helpdesk-body {padding-top: 100px;}
|
||||
img.brand {padding-right: 30px;}
|
||||
|
||||
pre {
|
||||
background: #eee;
|
||||
padding: 1em;
|
||||
border: 1pt solid white;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends "helpdesk/public_base.html" %}{% load i18n %}{% load markdown_deux_tags %}
|
||||
{% extends "helpdesk/public_base.html" %}{% load i18n %}
|
||||
|
||||
{% block helpdesk_breadcrumb %}
|
||||
<li class="breadcrumb-item">
|
||||
@ -19,7 +19,7 @@
|
||||
{{ item.question }}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>{{ item.answer|markdown }}</p>
|
||||
<p>{{ item.get_markdown }}</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
|
@ -2,6 +2,8 @@
|
||||
{% load i18n bootstrap4form humanize %}
|
||||
{% load static from staticfiles %}
|
||||
|
||||
|
||||
|
||||
{% block helpdesk_title %}{{ ticket.queue.slug }}-{{ ticket.id }} : {% trans "View Ticket Details" %}{% endblock %}
|
||||
|
||||
{% block helpdesk_head %}
|
||||
@ -44,7 +46,7 @@
|
||||
</div>
|
||||
<p class="mb-1">
|
||||
{% if followup.comment %}
|
||||
<p>{{ followup.comment|force_escape|urlizetrunc:50|num_to_link|linebreaksbr }}</p>
|
||||
<p>{{ followup.get_markdown|urlizetrunc:50|num_to_link|linebreaksbr }}</p>
|
||||
{% endif %}
|
||||
{% if followup.time_spent %}
|
||||
<small>{% trans "Time spent" %}: {{ followup.time_spent }}</small></p>
|
||||
|
@ -26,7 +26,7 @@
|
||||
<th colspan='2'>{% trans "Description" %}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td id="ticket-description" colspan='2'>{{ ticket.description|force_escape|urlizetrunc:50|num_to_link|linebreaksbr }}</td>
|
||||
<td id="ticket-description" colspan='2'>{{ ticket.get_markdown|urlizetrunc:50|num_to_link|linebreaksbr }}</td>
|
||||
</tr>
|
||||
|
||||
{% if ticket.resolution %}<tr>
|
||||
|
@ -27,7 +27,6 @@ class QuickDjangoTest(object):
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.staticfiles',
|
||||
'markdown_deux',
|
||||
'bootstrap4form'
|
||||
)
|
||||
MIDDLEWARE = [
|
||||
|
@ -4,7 +4,7 @@ celery
|
||||
django-celery-beat
|
||||
email-reply-parser
|
||||
akismet
|
||||
django-markdown-deux
|
||||
markdown
|
||||
beautifulsoup4
|
||||
lxml
|
||||
simplejson
|
||||
|
Loading…
Reference in New Issue
Block a user