mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2025-01-13 09:28:14 +01:00
Merge pull request #1003 from Mte90/no-kb
Disable KB without Django errors
This commit is contained in:
commit
5920c0f8a0
@ -1,10 +1,13 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from helpdesk.models import Queue, Ticket, FollowUp, PreSetReply, KBCategory
|
from helpdesk.models import Queue, Ticket, FollowUp, PreSetReply
|
||||||
from helpdesk.models import EscalationExclusion, EmailTemplate, KBItem
|
from helpdesk.models import EscalationExclusion, EmailTemplate
|
||||||
from helpdesk.models import TicketChange, KBIAttachment, FollowUpAttachment, IgnoreEmail
|
from helpdesk.models import TicketChange, KBIAttachment, FollowUpAttachment, IgnoreEmail
|
||||||
from helpdesk.models import CustomField
|
from helpdesk.models import CustomField
|
||||||
|
from helpdesk import settings as helpdesk_settings
|
||||||
|
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||||
|
from helpdesk.models import KBCategory
|
||||||
|
from helpdesk.models import KBItem
|
||||||
|
|
||||||
@admin.register(Queue)
|
@admin.register(Queue)
|
||||||
class QueueAdmin(admin.ModelAdmin):
|
class QueueAdmin(admin.ModelAdmin):
|
||||||
@ -68,14 +71,19 @@ class FollowUpAdmin(admin.ModelAdmin):
|
|||||||
ticket_get_ticket_for_url.short_description = _('Slug')
|
ticket_get_ticket_for_url.short_description = _('Slug')
|
||||||
|
|
||||||
|
|
||||||
@admin.register(KBItem)
|
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||||
class KBItemAdmin(admin.ModelAdmin):
|
@admin.register(KBItem)
|
||||||
|
class KBItemAdmin(admin.ModelAdmin):
|
||||||
list_display = ('category', 'title', 'last_updated', 'team', 'order', 'enabled')
|
list_display = ('category', 'title', 'last_updated', 'team', 'order', 'enabled')
|
||||||
inlines = [KBIAttachmentInline]
|
inlines = [KBIAttachmentInline]
|
||||||
readonly_fields = ('voted_by', 'downvoted_by')
|
readonly_fields = ('voted_by', 'downvoted_by')
|
||||||
|
|
||||||
list_display_links = ('title',)
|
list_display_links = ('title',)
|
||||||
|
|
||||||
|
@admin.register(KBCategory)
|
||||||
|
class KBCategoryAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('name', 'title', 'slug', 'public')
|
||||||
|
|
||||||
|
|
||||||
@admin.register(CustomField)
|
@admin.register(CustomField)
|
||||||
class CustomFieldAdmin(admin.ModelAdmin):
|
class CustomFieldAdmin(admin.ModelAdmin):
|
||||||
@ -93,10 +101,5 @@ class IgnoreEmailAdmin(admin.ModelAdmin):
|
|||||||
list_display = ('name', 'queue_list', 'email_address', 'keep_in_mailbox')
|
list_display = ('name', 'queue_list', 'email_address', 'keep_in_mailbox')
|
||||||
|
|
||||||
|
|
||||||
@admin.register(KBCategory)
|
|
||||||
class KBCategoryAdmin(admin.ModelAdmin):
|
|
||||||
list_display = ('name', 'title', 'slug', 'public')
|
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(PreSetReply)
|
admin.site.register(PreSetReply)
|
||||||
admin.site.register(EscalationExclusion)
|
admin.site.register(EscalationExclusion)
|
||||||
|
@ -18,9 +18,13 @@ from django.utils import timezone
|
|||||||
|
|
||||||
from helpdesk.lib import safe_template_context, process_attachments
|
from helpdesk.lib import safe_template_context, process_attachments
|
||||||
from helpdesk.models import (Ticket, Queue, FollowUp, IgnoreEmail, TicketCC,
|
from helpdesk.models import (Ticket, Queue, FollowUp, IgnoreEmail, TicketCC,
|
||||||
CustomField, TicketCustomFieldValue, TicketDependency, UserSettings, KBItem)
|
CustomField, TicketCustomFieldValue, TicketDependency, UserSettings)
|
||||||
from helpdesk import settings as helpdesk_settings
|
from helpdesk import settings as helpdesk_settings
|
||||||
|
|
||||||
|
|
||||||
|
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||||
|
from helpdesk.models import (KBItem)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
@ -231,6 +235,7 @@ class AbstractTicketForm(CustomFieldMixin, forms.Form):
|
|||||||
|
|
||||||
def __init__(self, kbcategory=None, *args, **kwargs):
|
def __init__(self, kbcategory=None, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||||
if kbcategory:
|
if kbcategory:
|
||||||
self.fields['kbitem'] = forms.ChoiceField(
|
self.fields['kbitem'] = forms.ChoiceField(
|
||||||
widget=forms.Select(attrs={'class': 'form-control'}),
|
widget=forms.Select(attrs={'class': 'form-control'}),
|
||||||
|
@ -20,8 +20,10 @@
|
|||||||
<li><a href='{% url 'helpdesk:email_ignore' %}'>{% trans "E-Mail Ignore list" %}</a></li>
|
<li><a href='{% url 'helpdesk:email_ignore' %}'>{% trans "E-Mail Ignore list" %}</a></li>
|
||||||
<li><a href='{% url 'admin:helpdesk_queue_changelist' %}'>{% trans "Maintain Queues" %}</a></li>
|
<li><a href='{% url 'admin:helpdesk_queue_changelist' %}'>{% trans "Maintain Queues" %}</a></li>
|
||||||
<li><a href='{% url 'admin:helpdesk_presetreply_changelist' %}'>{% trans "Maintain Pre-Set Replies" %}</a></li>
|
<li><a href='{% url 'admin:helpdesk_presetreply_changelist' %}'>{% trans "Maintain Pre-Set Replies" %}</a></li>
|
||||||
|
{% if helpdesk_settings.HELPDESK_KB_ENABLED %}
|
||||||
<li><a href='{% url 'admin:helpdesk_kbcategory_changelist' %}'>{% trans "Maintain Knowledgebase Categories" %}</a></li>
|
<li><a href='{% url 'admin:helpdesk_kbcategory_changelist' %}'>{% trans "Maintain Knowledgebase Categories" %}</a></li>
|
||||||
<li><a href='{% url 'admin:helpdesk_kbitem_changelist' %}'>{% trans "Maintain Knowledgebase Items" %}</a></li>
|
<li><a href='{% url 'admin:helpdesk_kbitem_changelist' %}'>{% trans "Maintain Knowledgebase Items" %}</a></li>
|
||||||
|
{% endif %}
|
||||||
<li><a href='{% url 'admin:helpdesk_emailtemplate_changelist' %}'>{% trans "Maintain E-Mail Templates" %}</a></li>
|
<li><a href='{% url 'admin:helpdesk_emailtemplate_changelist' %}'>{% trans "Maintain E-Mail Templates" %}</a></li>
|
||||||
<li><a href='{% url 'changelist'|user_admin_url %}'>{% trans "Maintain Users" %}</a></li>
|
<li><a href='{% url 'changelist'|user_admin_url %}'>{% trans "Maintain Users" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -14,7 +14,13 @@ from django.views.generic import TemplateView
|
|||||||
|
|
||||||
from helpdesk.decorators import helpdesk_staff_member_required, protect_view
|
from helpdesk.decorators import helpdesk_staff_member_required, protect_view
|
||||||
from helpdesk import settings as helpdesk_settings
|
from helpdesk import settings as helpdesk_settings
|
||||||
from helpdesk.views import feeds, staff, public, kb, login
|
from helpdesk.views import feeds, staff, public, login
|
||||||
|
from helpdesk import settings as helpdesk_settings
|
||||||
|
|
||||||
|
|
||||||
|
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||||
|
from helpdesk.views import kb
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# TODO: why is it imported? due to some side-effect or by mistake?
|
# TODO: why is it imported? due to some side-effect or by mistake?
|
||||||
import helpdesk.tasks # NOQA
|
import helpdesk.tasks # NOQA
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
from helpdesk.models import (
|
from helpdesk.models import (
|
||||||
Ticket,
|
Ticket,
|
||||||
Queue,
|
Queue
|
||||||
KBCategory,
|
|
||||||
KBItem,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from helpdesk import settings as helpdesk_settings
|
from helpdesk import settings as helpdesk_settings
|
||||||
|
|
||||||
|
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||||
|
from helpdesk.models import (
|
||||||
|
KBCategory,
|
||||||
|
KBItem
|
||||||
|
)
|
||||||
|
|
||||||
def huser_from_request(req):
|
def huser_from_request(req):
|
||||||
return HelpdeskUser(req.user)
|
return HelpdeskUser(req.user)
|
||||||
@ -38,6 +41,7 @@ class HelpdeskUser:
|
|||||||
|
|
||||||
def get_allowed_kb_categories(self):
|
def get_allowed_kb_categories(self):
|
||||||
categories = []
|
categories = []
|
||||||
|
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||||
for cat in KBCategory.objects.all():
|
for cat in KBCategory.objects.all():
|
||||||
if self.can_access_kbcategory(cat):
|
if self.can_access_kbcategory(cat):
|
||||||
categories.append(cat)
|
categories.append(cat)
|
||||||
@ -45,6 +49,7 @@ class HelpdeskUser:
|
|||||||
|
|
||||||
def get_assigned_kb_items(self):
|
def get_assigned_kb_items(self):
|
||||||
kbitems = []
|
kbitems = []
|
||||||
|
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||||
for item in KBItem.objects.all():
|
for item in KBItem.objects.all():
|
||||||
if item.get_team() and item.get_team().is_member(self.user):
|
if item.get_team() and item.get_team().is_member(self.user):
|
||||||
kbitems.append(item)
|
kbitems.append(item)
|
||||||
|
@ -50,9 +50,12 @@ from helpdesk.lib import (
|
|||||||
)
|
)
|
||||||
from helpdesk.models import (
|
from helpdesk.models import (
|
||||||
Ticket, Queue, FollowUp, TicketChange, PreSetReply, FollowUpAttachment, SavedSearch,
|
Ticket, Queue, FollowUp, TicketChange, PreSetReply, FollowUpAttachment, SavedSearch,
|
||||||
IgnoreEmail, TicketCC, TicketDependency, UserSettings, KBItem, CustomField, TicketCustomFieldValue,
|
IgnoreEmail, TicketCC, TicketDependency, UserSettings, CustomField, TicketCustomFieldValue,
|
||||||
)
|
)
|
||||||
from helpdesk import settings as helpdesk_settings
|
from helpdesk import settings as helpdesk_settings
|
||||||
|
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||||
|
from helpdesk.models import (KBItem)
|
||||||
|
|
||||||
import helpdesk.views.abstract_views as abstract_views
|
import helpdesk.views.abstract_views as abstract_views
|
||||||
from helpdesk.views.permissions import MustBeStaffMixin
|
from helpdesk.views.permissions import MustBeStaffMixin
|
||||||
from ..lib import format_time_spent
|
from ..lib import format_time_spent
|
||||||
@ -1143,13 +1146,18 @@ def ticket_list(request):
|
|||||||
'<a href="http://docs.djangoproject.com/en/dev/ref/databases/#sqlite-string-matching">'
|
'<a href="http://docs.djangoproject.com/en/dev/ref/databases/#sqlite-string-matching">'
|
||||||
'Django Documentation on string matching in SQLite</a>.')
|
'Django Documentation on string matching in SQLite</a>.')
|
||||||
|
|
||||||
|
kbitem_choices = []
|
||||||
|
kbitem = []
|
||||||
|
|
||||||
|
if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||||
kbitem_choices = [(item.pk, str(item)) for item in KBItem.objects.all()]
|
kbitem_choices = [(item.pk, str(item)) for item in KBItem.objects.all()]
|
||||||
|
kbitem = KBItem.objects.all()
|
||||||
|
|
||||||
return render(request, 'helpdesk/ticket_list.html', dict(
|
return render(request, 'helpdesk/ticket_list.html', dict(
|
||||||
context,
|
context,
|
||||||
default_tickets_per_page=request.user.usersettings_helpdesk.tickets_per_page,
|
default_tickets_per_page=request.user.usersettings_helpdesk.tickets_per_page,
|
||||||
user_choices=User.objects.filter(is_active=True, is_staff=True),
|
user_choices=User.objects.filter(is_active=True, is_staff=True),
|
||||||
kb_items=KBItem.objects.all(),
|
kb_items=kbitem,
|
||||||
queue_choices=huser.get_queues(),
|
queue_choices=huser.get_queues(),
|
||||||
status_choices=Ticket.STATUS_CHOICES,
|
status_choices=Ticket.STATUS_CHOICES,
|
||||||
kbitem_choices=kbitem_choices,
|
kbitem_choices=kbitem_choices,
|
||||||
|
Loading…
Reference in New Issue
Block a user