fix(kb): no db

This commit is contained in:
Daniele Scasciafratte 2022-03-18 19:21:17 +01:00
parent 909b7a5533
commit 347a70e497
5 changed files with 171 additions and 154 deletions

View File

@ -1,10 +1,13 @@
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from helpdesk.models import Queue, Ticket, FollowUp, PreSetReply, KBCategory
from helpdesk.models import EscalationExclusion, EmailTemplate, KBItem
from helpdesk.models import Queue, Ticket, FollowUp, PreSetReply
from helpdesk.models import EscalationExclusion, EmailTemplate
from helpdesk.models import TicketChange, KBIAttachment, FollowUpAttachment, IgnoreEmail
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)
class QueueAdmin(admin.ModelAdmin):
@ -68,6 +71,7 @@ class FollowUpAdmin(admin.ModelAdmin):
ticket_get_ticket_for_url.short_description = _('Slug')
if helpdesk_settings.HELPDESK_KB_ENABLED:
@admin.register(KBItem)
class KBItemAdmin(admin.ModelAdmin):
list_display = ('category', 'title', 'last_updated', 'team', 'order', 'enabled')
@ -76,6 +80,10 @@ class KBItemAdmin(admin.ModelAdmin):
list_display_links = ('title',)
@admin.register(KBCategory)
class KBCategoryAdmin(admin.ModelAdmin):
list_display = ('name', 'title', 'slug', 'public')
@admin.register(CustomField)
class CustomFieldAdmin(admin.ModelAdmin):
@ -93,10 +101,5 @@ class IgnoreEmailAdmin(admin.ModelAdmin):
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(EscalationExclusion)

View File

@ -18,9 +18,13 @@ from django.utils import timezone
from helpdesk.lib import safe_template_context, process_attachments
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
if helpdesk_settings.HELPDESK_KB_ENABLED:
from helpdesk.models import (KBItem)
logger = logging.getLogger(__name__)
User = get_user_model()
@ -231,6 +235,7 @@ class AbstractTicketForm(CustomFieldMixin, forms.Form):
def __init__(self, kbcategory=None, *args, **kwargs):
super().__init__(*args, **kwargs)
if helpdesk_settings.HELPDESK_KB_ENABLED:
if kbcategory:
self.fields['kbitem'] = forms.ChoiceField(
widget=forms.Select(attrs={'class': 'form-control'}),

View File

@ -1275,7 +1275,7 @@ class EmailTemplate(models.Model):
verbose_name = _('e-mail template')
verbose_name_plural = _('e-mail templates')
if helpdesk_settings.HELPDESK_KB_ENABLED:
class KBCategory(models.Model):
"""
Lets help users help themselves: the Knowledge Base is a categorised

View File

@ -14,7 +14,13 @@ from django.views.generic import TemplateView
from helpdesk.decorators import helpdesk_staff_member_required, protect_view
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:
# TODO: why is it imported? due to some side-effect or by mistake?
import helpdesk.tasks # NOQA

View File

@ -50,9 +50,12 @@ from helpdesk.lib import (
)
from helpdesk.models import (
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
if helpdesk_settings.HELPDESK_KB_ENABLED:
from helpdesk.models import (KBItem)
import helpdesk.views.abstract_views as abstract_views
from helpdesk.views.permissions import MustBeStaffMixin
from ..lib import format_time_spent