diff --git a/api/product/views.py b/api/product/views.py index a250bae88..9f58749a8 100644 --- a/api/product/views.py +++ b/api/product/views.py @@ -26,6 +26,8 @@ from .tasks import product_save_as from .tasks import import_target_list +from .association import Association + logger = logging.getLogger(__name__) @@ -430,6 +432,17 @@ class ProductAssociationViewSet(viewsets.ModelViewSet): ordering_fields = ('id',) + @list_route() + def get_ucds_by_product(self, request): + + product_id = request.query_params.get('product_id', None) + if product_id is None: + raise Exception('product_id is required.') + + associations = Association().get_associations_by_product_id(product_id) + + return Response(associations) + class MapFilter(django_filters.FilterSet): release_id = django_filters.MethodFilter(action='filter_release_id')