2008-08-12 01:24:18 +02:00
|
|
|
from django.contrib import admin
|
2015-06-11 12:18:45 +02:00
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from django.contrib.auth.admin import UserAdmin
|
2008-08-12 01:24:18 +02:00
|
|
|
from helpdesk.models import Queue, Ticket, FollowUp, PreSetReply, KBCategory
|
|
|
|
from helpdesk.models import EscalationExclusion, EmailTemplate, KBItem
|
2008-12-02 21:47:49 +01:00
|
|
|
from helpdesk.models import TicketChange, Attachment, IgnoreEmail
|
2011-02-02 12:22:46 +01:00
|
|
|
from helpdesk.models import CustomField
|
2015-06-11 12:18:45 +02:00
|
|
|
from helpdesk.models import QueueMembership
|
|
|
|
from helpdesk import settings as helpdesk_settings
|
2008-08-12 01:24:18 +02:00
|
|
|
|
|
|
|
class QueueAdmin(admin.ModelAdmin):
|
2011-03-11 23:30:59 +01:00
|
|
|
list_display = ('title', 'slug', 'email_address', 'locale')
|
2008-08-12 01:24:18 +02:00
|
|
|
|
|
|
|
class TicketAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('title', 'status', 'assigned_to', 'submitter_email',)
|
|
|
|
date_hierarchy = 'created'
|
|
|
|
list_filter = ('assigned_to', 'status', )
|
|
|
|
|
2008-08-13 23:42:57 +02:00
|
|
|
class TicketChangeInline(admin.StackedInline):
|
|
|
|
model = TicketChange
|
|
|
|
|
|
|
|
class AttachmentInline(admin.StackedInline):
|
|
|
|
model = Attachment
|
|
|
|
|
|
|
|
class FollowUpAdmin(admin.ModelAdmin):
|
|
|
|
inlines = [TicketChangeInline, AttachmentInline]
|
2008-08-12 01:24:18 +02:00
|
|
|
|
2008-10-07 08:52:52 +02:00
|
|
|
class KBItemAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('category', 'title', 'last_updated',)
|
2008-10-28 11:24:59 +01:00
|
|
|
list_display_links = ('title',)
|
2015-06-11 12:18:45 +02:00
|
|
|
|
2011-02-02 12:22:46 +01:00
|
|
|
class CustomFieldAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('name', 'label', 'data_type')
|
2008-10-07 08:52:52 +02:00
|
|
|
|
2011-03-11 23:30:59 +01:00
|
|
|
class EmailTemplateAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('template_name', 'heading', 'locale')
|
|
|
|
list_filter = ('locale', )
|
|
|
|
|
2015-06-11 12:18:45 +02:00
|
|
|
class QueueMembershipInline(admin.StackedInline):
|
|
|
|
model = QueueMembership
|
|
|
|
|
|
|
|
class UserAdminWithQueueMemberships(UserAdmin):
|
|
|
|
|
|
|
|
def change_view(self, request, object_id, form_url='', extra_context=None):
|
|
|
|
self.inlines = (QueueMembershipInline,)
|
|
|
|
|
|
|
|
return super(UserAdminWithQueueMemberships, self).change_view(
|
|
|
|
request, object_id, form_url=form_url, extra_context=extra_context)
|
|
|
|
|
|
|
|
|
2008-08-12 01:24:18 +02:00
|
|
|
admin.site.register(Ticket, TicketAdmin)
|
|
|
|
admin.site.register(Queue, QueueAdmin)
|
2008-08-13 23:42:57 +02:00
|
|
|
admin.site.register(FollowUp, FollowUpAdmin)
|
|
|
|
admin.site.register(PreSetReply)
|
|
|
|
admin.site.register(EscalationExclusion)
|
2011-03-11 23:30:59 +01:00
|
|
|
admin.site.register(EmailTemplate, EmailTemplateAdmin)
|
2008-08-13 23:42:57 +02:00
|
|
|
admin.site.register(KBCategory)
|
2008-10-07 08:52:52 +02:00
|
|
|
admin.site.register(KBItem, KBItemAdmin)
|
2008-12-02 21:47:49 +01:00
|
|
|
admin.site.register(IgnoreEmail)
|
2011-02-02 12:22:46 +01:00
|
|
|
admin.site.register(CustomField, CustomFieldAdmin)
|
2015-06-11 12:18:45 +02:00
|
|
|
if helpdesk_settings.HELPDESK_ENABLE_PER_QUEUE_STAFF_MEMBERSHIP:
|
|
|
|
admin.site.unregister(get_user_model())
|
|
|
|
admin.site.register(get_user_model(), UserAdminWithQueueMemberships)
|