Skip to content

Commit

Permalink
Fix search fields in admin.
Browse files Browse the repository at this point in the history
  • Loading branch information
SalahAdDin committed Feb 10, 2018
1 parent 6b9fc2d commit deba472
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions oscar_support/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
from oscar.core.loading import get_model

Attachment = get_model('oscar_support', 'Attachment')
Basket = get_model('basket', 'Basket')
Line = get_model('order', 'Line')
Message = get_model('oscar_support', 'Message')
Order = get_model('order', 'Order')
Priority = get_model("oscar_support", "Priority")
Product = get_model('catalogue', 'Product')
RelatedOrder = get_model("oscar_support", "RelatedOrder")
Expand Down Expand Up @@ -54,8 +52,8 @@ class TicketStatusAdmin(admin.ModelAdmin):


class PriorityAdmin(admin.ModelAdmin):
list_display = ['name', 'slug']
fields = ['name', 'slug']
list_display = ['name', 'slug', 'comment']
fields = ['name', 'slug', 'comment']
readonly_fields = ['slug']


Expand All @@ -72,47 +70,54 @@ class TicketAdmin(admin.ModelAdmin):
list_filter = ['is_internal', 'requester', 'type', 'assignee', 'priority', 'status']
raw_id_fields = ['related_lines', 'related_orders', 'related_products']
readonly_fields = ['date_created', 'date_updated']
search_fields = ['is_internal', 'requester', 'type', 'assignee', 'priority', 'status']
search_fields = [
'is_internal',
'requester__username',
'type__name',
'assignee__username',
'priority__name',
'status__name'
]


class MessageAdmin(admin.ModelAdmin):
date_hierarchy = 'date_updated'
list_display = ['user', 'type', 'ticket', 'text']
list_filter = ['user', 'type', 'ticket']
readonly_fields = ['date_created', 'date_updated']
search_fields = ['user', 'type', 'ticket']
search_fields = ['user__username', 'type', 'ticket__number']


class RelatedOrderAdmin(admin.ModelAdmin):
date_hierarchy = 'date_updated'
list_display = ['user', 'ticket', 'order']
list_filter = ['user', 'ticket', ]
readonly_fields = ['date_created', 'date_updated']
search_fields = ['user', 'ticket', ]
search_fields = ['user__username', 'ticket__number', ]


class RelatedOrderLineAdmin(admin.ModelAdmin):
date_hierarchy = 'date_updated'
list_display = ['user', 'ticket', 'line']
list_filter = ['user', 'ticket', ]
readonly_fields = ['date_created', 'date_updated']
search_fields = ['user', 'ticket', ]
search_fields = ['user__username', 'ticket__number', ]


class RelatedProductAdmin(admin.ModelAdmin):
date_hierarchy = 'date_updated'
list_display = ['user', 'ticket', 'product']
list_filter = ['user', 'ticket', ]
readonly_fields = ['date_created', 'date_updated']
search_fields = ['user', 'ticket', ]
search_fields = ['user__username', 'ticket__number', ]


class AttachmentAdmin(admin.ModelAdmin):
date_hierarchy = 'date_updated'
list_display = ['user', 'ticket', 'file']
list_filter = ['user', 'ticket', ]
readonly_fields = ['date_created', 'date_updated']
search_fields = ['user', 'ticket', ]
search_fields = ['user__username', 'ticket__number', ]


admin.site.register(TicketType, TicketTypeAdmin)
Expand Down

0 comments on commit deba472

Please sign in to comment.