2008-08-12 01:24:18 +02:00
|
|
|
from django.contrib import admin
|
2015-12-16 15:02:13 +01:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2008-08-12 01:24:18 +02:00
|
|
|
from helpdesk.models import Queue, Ticket, FollowUp, PreSetReply, KBCategory
|
|
|
|
from helpdesk.models import EscalationExclusion, EmailTemplate, KBItem
|
2019-03-07 21:58:04 +01:00
|
|
|
from helpdesk.models import TicketChange, KBIAttachment, FollowUpAttachment, IgnoreEmail
|
2011-02-02 12:22:46 +01:00
|
|
|
from helpdesk.models import CustomField
|
2008-08-12 01:24:18 +02:00
|
|
|
|
2016-10-21 17:14:12 +02:00
|
|
|
|
|
|
|
@admin.register(Queue)
|
2008-08-12 01:24:18 +02:00
|
|
|
class QueueAdmin(admin.ModelAdmin):
|
2019-02-19 23:01:51 +01:00
|
|
|
list_display = ('title', 'slug', 'email_address', 'locale', 'time_spent')
|
2015-12-18 14:56:53 +01:00
|
|
|
prepopulated_fields = {"slug": ("title",)}
|
2008-08-12 01:24:18 +02:00
|
|
|
|
2019-02-19 23:01:51 +01:00
|
|
|
def time_spent(self, q):
|
|
|
|
if q.dedicated_time:
|
|
|
|
return "{} / {}".format(q.time_spent, q.dedicated_time)
|
|
|
|
elif q.time_spent:
|
|
|
|
return q.time_spent
|
|
|
|
else:
|
|
|
|
return "-"
|
|
|
|
|
2016-10-21 17:14:12 +02:00
|
|
|
|
|
|
|
@admin.register(Ticket)
|
2008-08-12 01:24:18 +02:00
|
|
|
class TicketAdmin(admin.ModelAdmin):
|
2019-02-06 14:24:43 +01:00
|
|
|
list_display = ('title', 'status', 'assigned_to', 'queue',
|
|
|
|
'hidden_submitter_email', 'time_spent')
|
2008-08-12 01:24:18 +02:00
|
|
|
date_hierarchy = 'created'
|
2015-12-16 15:02:13 +01:00
|
|
|
list_filter = ('queue', 'assigned_to', 'status')
|
|
|
|
|
|
|
|
def hidden_submitter_email(self, ticket):
|
|
|
|
if ticket.submitter_email:
|
|
|
|
username, domain = ticket.submitter_email.split("@")
|
|
|
|
username = username[:2] + "*" * (len(username) - 2)
|
|
|
|
domain = domain[:1] + "*" * (len(domain) - 2) + domain[-1:]
|
|
|
|
return "%s@%s" % (username, domain)
|
|
|
|
else:
|
|
|
|
return ticket.submitter_email
|
|
|
|
hidden_submitter_email.short_description = _('Submitter E-Mail')
|
2008-08-12 01:24:18 +02:00
|
|
|
|
2019-02-06 14:24:43 +01:00
|
|
|
def time_spent(self, ticket):
|
|
|
|
return ticket.time_spent
|
|
|
|
|
2016-10-21 17:14:12 +02:00
|
|
|
|
2008-08-13 23:42:57 +02:00
|
|
|
class TicketChangeInline(admin.StackedInline):
|
|
|
|
model = TicketChange
|
2019-03-07 21:58:04 +01:00
|
|
|
extra = 0
|
2008-08-13 23:42:57 +02:00
|
|
|
|
2016-10-21 17:14:12 +02:00
|
|
|
|
2019-03-07 21:58:04 +01:00
|
|
|
class FollowUpAttachmentInline(admin.StackedInline):
|
|
|
|
model = FollowUpAttachment
|
|
|
|
extra = 0
|
|
|
|
|
|
|
|
|
|
|
|
class KBIAttachmentInline(admin.StackedInline):
|
|
|
|
model = KBIAttachment
|
|
|
|
extra = 0
|
2008-08-13 23:42:57 +02:00
|
|
|
|
2016-10-21 17:14:12 +02:00
|
|
|
|
|
|
|
@admin.register(FollowUp)
|
2008-08-13 23:42:57 +02:00
|
|
|
class FollowUpAdmin(admin.ModelAdmin):
|
2019-03-07 21:58:04 +01:00
|
|
|
inlines = [TicketChangeInline, FollowUpAttachmentInline]
|
2019-02-06 14:24:43 +01:00
|
|
|
list_display = ('ticket_get_ticket_for_url', 'title', 'date', 'ticket',
|
|
|
|
'user', 'new_status', 'time_spent')
|
2017-06-14 06:07:05 +02:00
|
|
|
list_filter = ('user', 'date', 'new_status')
|
|
|
|
|
|
|
|
def ticket_get_ticket_for_url(self, obj):
|
|
|
|
return obj.ticket.ticket_for_url
|
|
|
|
ticket_get_ticket_for_url.short_description = _('Slug')
|
2008-08-12 01:24:18 +02:00
|
|
|
|
2016-10-21 17:14:12 +02:00
|
|
|
|
|
|
|
@admin.register(KBItem)
|
2008-10-07 08:52:52 +02:00
|
|
|
class KBItemAdmin(admin.ModelAdmin):
|
2020-02-11 15:35:40 +01:00
|
|
|
list_display = ('category', 'title', 'last_updated', 'team', )
|
2019-03-07 21:58:04 +01:00
|
|
|
inlines = [KBIAttachmentInline]
|
2020-01-08 22:30:12 +01:00
|
|
|
readonly_fields = ('voted_by', 'downvoted_by')
|
2019-01-22 18:29:32 +01:00
|
|
|
|
2008-10-28 11:24:59 +01:00
|
|
|
list_display_links = ('title',)
|
2015-06-11 12:18:45 +02:00
|
|
|
|
2016-10-21 17:14:12 +02:00
|
|
|
|
|
|
|
@admin.register(CustomField)
|
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
|
|
|
|
2016-10-21 17:14:12 +02:00
|
|
|
|
|
|
|
@admin.register(EmailTemplate)
|
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
|
|
|
|
2017-06-19 20:34:36 +02:00
|
|
|
@admin.register(IgnoreEmail)
|
|
|
|
class IgnoreEmailAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('name', 'queue_list', 'email_address', 'keep_in_mailbox')
|
|
|
|
|
|
|
|
|
2008-08-13 23:42:57 +02:00
|
|
|
admin.site.register(PreSetReply)
|
|
|
|
admin.site.register(EscalationExclusion)
|
|
|
|
admin.site.register(KBCategory)
|