mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-10 06:37:17 +00:00
Enhance search fields across InvenTree REST API endpoints (#12723)
* Enhance search fields across REST API endpoints * Revert search_fields on SettingsList to key only for security * Bump API version to 537 for REST API search fields * Clean TokenListView search fields and revert common/api.py
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
"""InvenTree API version information."""
|
||||
|
||||
# InvenTree API version
|
||||
INVENTREE_API_VERSION = 538
|
||||
INVENTREE_API_VERSION = 539
|
||||
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||
|
||||
INVENTREE_API_TEXT = """
|
||||
|
||||
v539 -> 2026-09-02 : https://github.com/inventree/InvenTree/pull/12723
|
||||
- Adds search fields to AddressList, ContactList, UserList, GroupList, RuleSetList, and TokenListView API endpoints
|
||||
|
||||
v538 -> 2026-09-02 : https://github.com/inventree/InvenTree/pull/12763
|
||||
- Fix API permissions for the SelectionList endpoints
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ class ContactList(DataExportViewMixin, ListCreateDestroyAPIView):
|
||||
|
||||
filterset_fields = ['company']
|
||||
|
||||
search_fields = ['company__name', 'name']
|
||||
search_fields = ['company__name', 'name', 'email', 'phone', 'role']
|
||||
|
||||
ordering_fields = ['name']
|
||||
|
||||
@@ -122,6 +122,16 @@ class AddressList(DataExportViewMixin, ListCreateDestroyAPIView):
|
||||
|
||||
filterset_fields = ['company']
|
||||
|
||||
search_fields = [
|
||||
'company__name',
|
||||
'title',
|
||||
'line1',
|
||||
'line2',
|
||||
'postal_city',
|
||||
'postal_code',
|
||||
'country',
|
||||
]
|
||||
|
||||
ordering_fields = ['title']
|
||||
|
||||
ordering = 'title'
|
||||
@@ -491,7 +501,12 @@ class SupplierPriceBreakList(
|
||||
filter_backends = SEARCH_ORDER_FILTER
|
||||
ordering_fields = ['quantity', 'supplier', 'SKU', 'price']
|
||||
|
||||
search_fields = ['part__SKU', 'part__supplier__name']
|
||||
search_fields = [
|
||||
'part__SKU',
|
||||
'part__supplier__name',
|
||||
'part__part__name',
|
||||
'part__part__IPN',
|
||||
]
|
||||
|
||||
ordering_field_aliases = {'supplier': 'part__supplier__name', 'SKU': 'part__SKU'}
|
||||
|
||||
|
||||
@@ -1479,12 +1479,14 @@ class SalesOrderAllocationList(
|
||||
'shipment_date': 'shipment__shipment_date',
|
||||
}
|
||||
|
||||
search_fields = {
|
||||
search_fields = [
|
||||
'item__part__name',
|
||||
'item__part__IPN',
|
||||
'item__serial',
|
||||
'item__batch',
|
||||
}
|
||||
'line__order__reference',
|
||||
'line__order__customer__name',
|
||||
]
|
||||
|
||||
|
||||
class SalesOrderAllocationDetail(SalesOrderAllocationMixin, RetrieveUpdateDestroyAPI):
|
||||
@@ -2295,12 +2297,13 @@ class TransferOrderAllocationList(
|
||||
'order': 'line__order__reference',
|
||||
}
|
||||
|
||||
search_fields = {
|
||||
search_fields = [
|
||||
'item__part__name',
|
||||
'item__part__IPN',
|
||||
'item__serial',
|
||||
'item__batch',
|
||||
}
|
||||
'line__order__reference',
|
||||
]
|
||||
|
||||
|
||||
class TransferOrderAllocationDetail(
|
||||
|
||||
@@ -283,7 +283,7 @@ class UserList(ListCreateAPI):
|
||||
|
||||
filter_backends = SEARCH_ORDER_FILTER
|
||||
|
||||
search_fields = ['first_name', 'last_name', 'username']
|
||||
search_fields = ['first_name', 'last_name', 'username', 'email']
|
||||
|
||||
ordering_fields = [
|
||||
'email',
|
||||
@@ -459,16 +459,14 @@ class TokenListView(TokenMixin, ListCreateAPI):
|
||||
"""List of user tokens for current user."""
|
||||
|
||||
filter_backends = SEARCH_ORDER_FILTER
|
||||
search_fields = ['name', 'key']
|
||||
ordering_fields = [
|
||||
'created',
|
||||
'expiry',
|
||||
'last_seen',
|
||||
'user',
|
||||
search_fields = [
|
||||
'name',
|
||||
'revoked',
|
||||
'revoked',
|
||||
'user__username',
|
||||
'user__first_name',
|
||||
'user__last_name',
|
||||
'user__email',
|
||||
]
|
||||
ordering_fields = ['created', 'expiry', 'last_seen', 'user', 'name', 'revoked']
|
||||
filterset_fields = ['revoked', 'user']
|
||||
queryset = ApiToken.objects.none()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user