mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +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
|
||||||
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
|
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
|
v126 -> 2023-06-19 : https://github.com/inventree/InvenTree/pull/5075
|
||||||
- Adds API endpoint for setting the "category" for multiple parts simultaneously
|
- Adds API endpoint for setting the "category" for multiple parts simultaneously
|
||||||
|
|
||||||
|
@ -1461,13 +1461,8 @@ class PartParameterTemplateDetail(RetrieveUpdateDestroyAPI):
|
|||||||
serializer_class = part_serializers.PartParameterTemplateSerializer
|
serializer_class = part_serializers.PartParameterTemplateSerializer
|
||||||
|
|
||||||
|
|
||||||
class PartParameterList(ListCreateAPI):
|
class PartParameterAPIMixin:
|
||||||
"""API endpoint for accessing a list of PartParameter objects.
|
"""Mixin class for PartParameter API endpoints."""
|
||||||
|
|
||||||
- GET: Return list of PartParameter objects
|
|
||||||
- POST: Create a new PartParameter object
|
|
||||||
"""
|
|
||||||
|
|
||||||
queryset = PartParameter.objects.all()
|
queryset = PartParameter.objects.all()
|
||||||
serializer_class = part_serializers.PartParameterSerializer
|
serializer_class = part_serializers.PartParameterSerializer
|
||||||
|
|
||||||
@ -1485,21 +1480,35 @@ class PartParameterList(ListCreateAPI):
|
|||||||
|
|
||||||
return self.serializer_class(*args, **kwargs)
|
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 = [
|
filterset_fields = [
|
||||||
'part',
|
'part',
|
||||||
'template',
|
'template',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class PartParameterDetail(RetrieveUpdateDestroyAPI):
|
class PartParameterDetail(PartParameterAPIMixin, RetrieveUpdateDestroyAPI):
|
||||||
"""API endpoint for detail view of a single PartParameter object."""
|
"""API endpoint for detail view of a single PartParameter object."""
|
||||||
|
pass
|
||||||
queryset = PartParameter.objects.all()
|
|
||||||
serializer_class = part_serializers.PartParameterSerializer
|
|
||||||
|
|
||||||
|
|
||||||
class PartStocktakeFilter(rest_filters.FilterSet):
|
class PartStocktakeFilter(rest_filters.FilterSet):
|
||||||
|
@ -242,7 +242,7 @@ class PartParameterSerializer(InvenTree.serializers.InvenTreeModelSerializer):
|
|||||||
Allows us to optionally include or exclude particular information
|
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)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user