Skip to content

Commit

Permalink
Merge pull request #825 from linea-it/api_associations
Browse files Browse the repository at this point in the history
Created new method to return ucds for a product_id
  • Loading branch information
glaubervila authored Oct 19, 2017
2 parents 32afce0 + 2bd9f42 commit 4e380d3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions api/product/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from .tasks import product_save_as
from .tasks import import_target_list

from .association import Association

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 4e380d3

Please sign in to comment.