2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-11 07:24:15 +00:00

Convert category parameter forms to use the API (#3130)

* Moving PartCategoryParameterTemplate model to the API

- Add detail API endpoint
- Add 'create' action to LIST endpoint

* Update settings page to use the new API forms

* Remove old views / forms

* Update API version

* Fix table buttons

* Add title to deletion form

* Add unit tests for new API views
This commit is contained in:
Oliver
2022-06-06 00:25:08 +10:00
committed by GitHub
parent 80b10c62f3
commit bbbfd003e0
10 changed files with 124 additions and 250 deletions

View File

@ -194,7 +194,7 @@ class CategoryMetadata(generics.RetrieveUpdateAPIView):
queryset = PartCategory.objects.all()
class CategoryParameterList(generics.ListAPIView):
class CategoryParameterList(generics.ListCreateAPIView):
"""API endpoint for accessing a list of PartCategoryParameterTemplate objects.
- GET: Return a list of PartCategoryParameterTemplate objects
@ -235,6 +235,13 @@ class CategoryParameterList(generics.ListAPIView):
return queryset
class CategoryParameterDetail(generics.RetrieveUpdateDestroyAPIView):
"""Detail endpoint fro the PartCategoryParameterTemplate model"""
queryset = PartCategoryParameterTemplate.objects.all()
serializer_class = part_serializers.CategoryParameterTemplateSerializer
class CategoryTree(generics.ListAPIView):
"""API endpoint for accessing a list of PartCategory objects ready for rendering a tree."""
@ -1855,7 +1862,11 @@ part_api_urls = [
# Base URL for PartCategory API endpoints
re_path(r'^category/', include([
re_path(r'^tree/', CategoryTree.as_view(), name='api-part-category-tree'),
re_path(r'^parameters/', CategoryParameterList.as_view(), name='api-part-category-parameter-list'),
re_path(r'^parameters/', include([
re_path('^(?P<pk>\d+)/', CategoryParameterDetail.as_view(), name='api-part-category-parameter-detail'),
re_path('^.*$', CategoryParameterList.as_view(), name='api-part-category-parameter-list'),
])),
# Category detail endpoints
re_path(r'^(?P<pk>\d+)/', include([