mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Metadata API refactor (#4545)
* Add generic metadata API endpoint (cherry picked from commit 7bbd53fc7647e2bb18d36c8c351e3fc080037ab1) * Refactor metadata endpoints for build models (cherry picked from commit 722b44e1259f1c5b046c7bc4328995b8238fc342) * Update metadata views for company models * labels * orders * part * report * stock
This commit is contained in:
		| @@ -13,13 +13,12 @@ from rest_framework.exceptions import NotFound | ||||
|  | ||||
| import common.models | ||||
| import InvenTree.helpers | ||||
| from InvenTree.mixins import (ListAPI, RetrieveAPI, RetrieveUpdateAPI, | ||||
|                               RetrieveUpdateDestroyAPI) | ||||
| from InvenTree.api import MetadataView | ||||
| from InvenTree.mixins import ListAPI, RetrieveAPI, RetrieveUpdateDestroyAPI | ||||
| from InvenTree.tasks import offload_task | ||||
| from part.models import Part | ||||
| from plugin.base.label import label as plugin_label | ||||
| from plugin.registry import registry | ||||
| from plugin.serializers import MetadataSerializer | ||||
| from stock.models import StockItem, StockLocation | ||||
|  | ||||
| from .models import PartLabel, StockItemLabel, StockLocationLabel | ||||
| @@ -307,16 +306,6 @@ class StockItemLabelDetail(StockItemLabelMixin, RetrieveUpdateDestroyAPI): | ||||
|     pass | ||||
|  | ||||
|  | ||||
| class StockItemLabelMetadata(RetrieveUpdateAPI): | ||||
|     """API endpoint for viewing / updating StockItemLabel metadata.""" | ||||
|  | ||||
|     def get_serializer(self, *args, **kwargs): | ||||
|         """Return MetadataSerializer instance for a Company""" | ||||
|         return MetadataSerializer(StockItemLabel, *args, **kwargs) | ||||
|  | ||||
|     queryset = StockItemLabel.objects.all() | ||||
|  | ||||
|  | ||||
| class StockItemLabelPrint(StockItemLabelMixin, LabelPrintMixin, RetrieveAPI): | ||||
|     """API endpoint for printing a StockItemLabel object.""" | ||||
|     pass | ||||
| @@ -349,16 +338,6 @@ class StockLocationLabelDetail(StockLocationLabelMixin, RetrieveUpdateDestroyAPI | ||||
|     pass | ||||
|  | ||||
|  | ||||
| class StockLocationLabelMetadata(RetrieveUpdateAPI): | ||||
|     """API endpoint for viewing / updating StockLocationLabel metadata.""" | ||||
|  | ||||
|     def get_serializer(self, *args, **kwargs): | ||||
|         """Return MetadataSerializer instance for a Company""" | ||||
|         return MetadataSerializer(StockLocationLabel, *args, **kwargs) | ||||
|  | ||||
|     queryset = StockLocationLabel.objects.all() | ||||
|  | ||||
|  | ||||
| class StockLocationLabelPrint(StockLocationLabelMixin, LabelPrintMixin, RetrieveAPI): | ||||
|     """API endpoint for printing a StockLocationLabel object.""" | ||||
|     pass | ||||
| @@ -378,16 +357,6 @@ class PartLabelList(PartLabelMixin, LabelListView): | ||||
|     pass | ||||
|  | ||||
|  | ||||
| class PartLabelMetadata(RetrieveUpdateAPI): | ||||
|     """API endpoint for viewing / updating PartLabel metadata.""" | ||||
|  | ||||
|     def get_serializer(self, *args, **kwargs): | ||||
|         """Return MetadataSerializer instance for a Company""" | ||||
|         return MetadataSerializer(PartLabel, *args, **kwargs) | ||||
|  | ||||
|     queryset = PartLabel.objects.all() | ||||
|  | ||||
|  | ||||
| class PartLabelDetail(PartLabelMixin, RetrieveUpdateDestroyAPI): | ||||
|     """API endpoint for a single PartLabel object.""" | ||||
|     pass | ||||
| @@ -405,7 +374,7 @@ label_api_urls = [ | ||||
|         # Detail views | ||||
|         path(r'<int:pk>/', include([ | ||||
|             re_path(r'print/?', StockItemLabelPrint.as_view(), name='api-stockitem-label-print'), | ||||
|             re_path(r'metadata/', StockItemLabelMetadata.as_view(), name='api-stockitem-label-metadata'), | ||||
|             re_path(r'metadata/', MetadataView.as_view(), {'model': StockItemLabel}, name='api-stockitem-label-metadata'), | ||||
|             re_path(r'^.*$', StockItemLabelDetail.as_view(), name='api-stockitem-label-detail'), | ||||
|         ])), | ||||
|  | ||||
| @@ -418,7 +387,7 @@ label_api_urls = [ | ||||
|         # Detail views | ||||
|         path(r'<int:pk>/', include([ | ||||
|             re_path(r'print/?', StockLocationLabelPrint.as_view(), name='api-stocklocation-label-print'), | ||||
|             re_path(r'metadata/', StockLocationLabelMetadata.as_view(), name='api-stocklocation-label-metadata'), | ||||
|             re_path(r'metadata/', MetadataView.as_view(), {'model': StockLocationLabel}, name='api-stocklocation-label-metadata'), | ||||
|             re_path(r'^.*$', StockLocationLabelDetail.as_view(), name='api-stocklocation-label-detail'), | ||||
|         ])), | ||||
|  | ||||
| @@ -431,7 +400,7 @@ label_api_urls = [ | ||||
|         # Detail views | ||||
|         path(r'<int:pk>/', include([ | ||||
|             re_path(r'^print/', PartLabelPrint.as_view(), name='api-part-label-print'), | ||||
|             re_path(r'^metadata/', PartLabelMetadata.as_view(), name='api-part-label-metadata'), | ||||
|             re_path(r'^metadata/', MetadataView.as_view(), {'model': PartLabel}, name='api-part-label-metadata'), | ||||
|             re_path(r'^.*$', PartLabelDetail.as_view(), name='api-part-label-detail'), | ||||
|         ])), | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user