mirror of
https://github.com/inventree/InvenTree.git
synced 2026-08-30 16:58:06 +00:00
Enhance search and autocomplete fields across all InvenTree admin models (#12722)
* Fix PurchaseOrderExtraLine admin search and add search fields across admin classes * Add search fields and autocomplete fields across common admin models * Add search and autocomplete fields to importer admin models * Add search fields to MachineConfigAdmin * Add search fields to LocationTypeAdmin * Remove search_fields from DataImportRowAdmin per review feedback
This commit is contained in:
@@ -74,7 +74,9 @@ class AttachmentAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
readonly_fields = ['file_size', 'upload_date', 'upload_user']
|
readonly_fields = ['file_size', 'upload_date', 'upload_user']
|
||||||
|
|
||||||
search_fields = ('content_type', 'comment')
|
search_fields = ('comment', 'link', 'upload_user__username')
|
||||||
|
|
||||||
|
autocomplete_fields = ('upload_user',)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(common.models.DataOutput)
|
@admin.register(common.models.DataOutput)
|
||||||
@@ -85,6 +87,16 @@ class DataOutputAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_filter = ('user', 'output_type')
|
list_filter = ('user', 'output_type')
|
||||||
|
|
||||||
|
search_fields = (
|
||||||
|
'output_type',
|
||||||
|
'output',
|
||||||
|
'user__username',
|
||||||
|
'user__first_name',
|
||||||
|
'user__last_name',
|
||||||
|
)
|
||||||
|
|
||||||
|
autocomplete_fields = ('user',)
|
||||||
|
|
||||||
def has_add_permission(self, request):
|
def has_add_permission(self, request):
|
||||||
"""Prevent addition of new DataOutput objects via the admin interface."""
|
"""Prevent addition of new DataOutput objects via the admin interface."""
|
||||||
return False
|
return False
|
||||||
@@ -102,6 +114,10 @@ class BarcodeScanResultAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_filter = ('user', 'endpoint', 'result')
|
list_filter = ('user', 'endpoint', 'result')
|
||||||
|
|
||||||
|
search_fields = ('data', 'endpoint', 'result', 'user__username')
|
||||||
|
|
||||||
|
autocomplete_fields = ('user',)
|
||||||
|
|
||||||
def has_add_permission(self, request):
|
def has_add_permission(self, request):
|
||||||
"""Prevent addition of new BarcodeScanResult objects via the admin interface."""
|
"""Prevent addition of new BarcodeScanResult objects via the admin interface."""
|
||||||
return False
|
return False
|
||||||
@@ -127,6 +143,8 @@ class SettingsAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_display = ('key', 'value')
|
list_display = ('key', 'value')
|
||||||
|
|
||||||
|
search_fields = ('key', 'value')
|
||||||
|
|
||||||
def get_readonly_fields(self, request, obj=None): # pragma: no cover
|
def get_readonly_fields(self, request, obj=None): # pragma: no cover
|
||||||
"""Prevent the 'key' field being edited once the setting is created."""
|
"""Prevent the 'key' field being edited once the setting is created."""
|
||||||
if obj:
|
if obj:
|
||||||
@@ -140,6 +158,16 @@ class UserSettingsAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_display = ('key', 'value', 'user')
|
list_display = ('key', 'value', 'user')
|
||||||
|
|
||||||
|
search_fields = (
|
||||||
|
'key',
|
||||||
|
'value',
|
||||||
|
'user__username',
|
||||||
|
'user__first_name',
|
||||||
|
'user__last_name',
|
||||||
|
)
|
||||||
|
|
||||||
|
autocomplete_fields = ('user',)
|
||||||
|
|
||||||
def get_readonly_fields(self, request, obj=None): # pragma: no cover
|
def get_readonly_fields(self, request, obj=None): # pragma: no cover
|
||||||
"""Prevent the 'key' field being edited once the setting is created."""
|
"""Prevent the 'key' field being edited once the setting is created."""
|
||||||
if obj:
|
if obj:
|
||||||
@@ -153,6 +181,10 @@ class WebhookAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_display = ('endpoint_id', 'name', 'active', 'user')
|
list_display = ('endpoint_id', 'name', 'active', 'user')
|
||||||
|
|
||||||
|
search_fields = ('endpoint_id', 'name', 'user__username')
|
||||||
|
|
||||||
|
autocomplete_fields = ('user',)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(common.models.NotificationEntry)
|
@admin.register(common.models.NotificationEntry)
|
||||||
class NotificationEntryAdmin(admin.ModelAdmin):
|
class NotificationEntryAdmin(admin.ModelAdmin):
|
||||||
@@ -160,6 +192,8 @@ class NotificationEntryAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_display = ('key', 'uid', 'updated')
|
list_display = ('key', 'uid', 'updated')
|
||||||
|
|
||||||
|
search_fields = ('key', 'uid')
|
||||||
|
|
||||||
def has_add_permission(self, request):
|
def has_add_permission(self, request):
|
||||||
"""Prevent addition of new NotificationEntry objects via the admin interface."""
|
"""Prevent addition of new NotificationEntry objects via the admin interface."""
|
||||||
return False
|
return False
|
||||||
@@ -185,7 +219,9 @@ class NotificationMessageAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_filter = ('category', 'read', 'user')
|
list_filter = ('category', 'read', 'user')
|
||||||
|
|
||||||
search_fields = ('name', 'category', 'message')
|
search_fields = ('name', 'category', 'message', 'user__username')
|
||||||
|
|
||||||
|
autocomplete_fields = ('user',)
|
||||||
|
|
||||||
def has_add_permission(self, request):
|
def has_add_permission(self, request):
|
||||||
"""Prevent addition of new NotificationMessage objects via the admin interface."""
|
"""Prevent addition of new NotificationMessage objects via the admin interface."""
|
||||||
@@ -202,6 +238,8 @@ class NewsFeedEntryAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_display = ('title', 'author', 'published', 'summary')
|
list_display = ('title', 'author', 'published', 'summary')
|
||||||
|
|
||||||
|
search_fields = ('title', 'author', 'summary')
|
||||||
|
|
||||||
def has_add_permission(self, request):
|
def has_add_permission(self, request):
|
||||||
"""Prevent addition of new NewsFeedEntry objects via the admin interface."""
|
"""Prevent addition of new NewsFeedEntry objects via the admin interface."""
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -38,6 +38,15 @@ class DataImportSessionAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_filter = ['status']
|
list_filter = ['status']
|
||||||
|
|
||||||
|
search_fields = [
|
||||||
|
'user__username',
|
||||||
|
'user__first_name',
|
||||||
|
'user__last_name',
|
||||||
|
'model_type',
|
||||||
|
]
|
||||||
|
|
||||||
|
autocomplete_fields = ['user']
|
||||||
|
|
||||||
inlines = [DataImportColumnMapAdmin]
|
inlines = [DataImportColumnMapAdmin]
|
||||||
|
|
||||||
def get_readonly_fields(self, request, obj=None):
|
def get_readonly_fields(self, request, obj=None):
|
||||||
@@ -66,6 +75,8 @@ class DataImportRowAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_display = ['id', 'session', 'row_index']
|
list_display = ['id', 'session', 'row_index']
|
||||||
|
|
||||||
|
autocomplete_fields = ['session']
|
||||||
|
|
||||||
def get_readonly_fields(self, request, obj=None):
|
def get_readonly_fields(self, request, obj=None):
|
||||||
"""Return the readonly fields for the admin interface."""
|
"""Return the readonly fields for the admin interface."""
|
||||||
return ['session', 'row_index', 'row_data', 'errors', 'valid']
|
return ['session', 'row_index', 'row_data', 'errors', 'valid']
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class MachineConfigAdmin(admin.ModelAdmin):
|
|||||||
"""Custom admin with restricted id fields."""
|
"""Custom admin with restricted id fields."""
|
||||||
|
|
||||||
list_filter = ['active']
|
list_filter = ['active']
|
||||||
|
search_fields = ['name', 'machine_type', 'driver']
|
||||||
list_display = [
|
list_display = [
|
||||||
'name',
|
'name',
|
||||||
'machine_type',
|
'machine_type',
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class LocationTypeAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_display = ('name', 'description', 'icon', 'location_count')
|
list_display = ('name', 'description', 'icon', 'location_count')
|
||||||
readonly_fields = ('location_count',)
|
readonly_fields = ('location_count',)
|
||||||
|
search_fields = ('name', 'description')
|
||||||
|
|
||||||
def get_queryset(self, request):
|
def get_queryset(self, request):
|
||||||
"""Annotate queryset to fetch location count."""
|
"""Annotate queryset to fetch location count."""
|
||||||
|
|||||||
Reference in New Issue
Block a user