mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
PartParameter API improvements (#5094)
* PartParameter: Include template_detail by default * PartParameter API updates - Allow sorting by template name - Refactor with mixin class * Bug fixes * Bump API version
This commit is contained in:
parent
fab738cd75
commit
24b554a8d2
@ -2,11 +2,14 @@
|
||||
|
||||
|
||||
# InvenTree API version
|
||||
INVENTREE_API_VERSION = 126
|
||||
INVENTREE_API_VERSION = 127
|
||||
|
||||
"""
|
||||
Increment this API version number whenever there is a significant change to the API that any clients need to know about
|
||||
|
||||
v127 -> 2023-06-24 : https://github.com/inventree/InvenTree/pull/5094
|
||||
- Enhancements for the PartParameter API endpoints
|
||||
|
||||
v126 -> 2023-06-19 : https://github.com/inventree/InvenTree/pull/5075
|
||||
- Adds API endpoint for setting the "category" for multiple parts simultaneously
|
||||
|
||||
|
@ -1461,13 +1461,8 @@ class PartParameterTemplateDetail(RetrieveUpdateDestroyAPI):
|
||||
serializer_class = part_serializers.PartParameterTemplateSerializer
|
||||
|
||||
|
||||
class PartParameterList(ListCreateAPI):
|
||||
"""API endpoint for accessing a list of PartParameter objects.
|
||||
|
||||
- GET: Return list of PartParameter objects
|
||||
- POST: Create a new PartParameter object
|
||||
"""
|
||||
|
||||
class PartParameterAPIMixin:
|
||||
"""Mixin class for PartParameter API endpoints."""
|
||||
queryset = PartParameter.objects.all()
|
||||
serializer_class = part_serializers.PartParameterSerializer
|
||||
|
||||
@ -1485,21 +1480,35 @@ class PartParameterList(ListCreateAPI):
|
||||
|
||||
return self.serializer_class(*args, **kwargs)
|
||||
|
||||
filter_backends = [
|
||||
DjangoFilterBackend
|
||||
|
||||
class PartParameterList(PartParameterAPIMixin, ListCreateAPI):
|
||||
"""API endpoint for accessing a list of PartParameter objects.
|
||||
|
||||
- GET: Return list of PartParameter objects
|
||||
- POST: Create a new PartParameter object
|
||||
"""
|
||||
|
||||
filter_backends = SEARCH_ORDER_FILTER_ALIAS
|
||||
|
||||
ordering_fields = [
|
||||
'name',
|
||||
'data',
|
||||
]
|
||||
|
||||
ordering_field_aliases = {
|
||||
'name': 'template__name',
|
||||
'data': ['data_numeric', 'data'],
|
||||
}
|
||||
|
||||
filterset_fields = [
|
||||
'part',
|
||||
'template',
|
||||
]
|
||||
|
||||
|
||||
class PartParameterDetail(RetrieveUpdateDestroyAPI):
|
||||
class PartParameterDetail(PartParameterAPIMixin, RetrieveUpdateDestroyAPI):
|
||||
"""API endpoint for detail view of a single PartParameter object."""
|
||||
|
||||
queryset = PartParameter.objects.all()
|
||||
serializer_class = part_serializers.PartParameterSerializer
|
||||
pass
|
||||
|
||||
|
||||
class PartStocktakeFilter(rest_filters.FilterSet):
|
||||
|
@ -242,7 +242,7 @@ class PartParameterSerializer(InvenTree.serializers.InvenTreeModelSerializer):
|
||||
Allows us to optionally include or exclude particular information
|
||||
"""
|
||||
|
||||
template_detail = kwargs.pop('template_detail', False)
|
||||
template_detail = kwargs.pop('template_detail', True)
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user