Skip to content

Commit

Permalink
Add good document streaming endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincarrogan committed Feb 9, 2024
1 parent a5ce86b commit 76ccb5b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Empty file added api/goods/filters.py
Empty file.
5 changes: 5 additions & 0 deletions api/goods/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
views.GoodDocumentDetail.as_view(),
name="document",
),
path(
"<uuid:pk>/documents/<uuid:doc_pk>/stream/",
views.GoodDocumentStream.as_view(),
name="document_stream",
),
path(
"document_internal_good_on_application/<str:goods_on_application_pk>/",
views.DocumentGoodOnApplicationInternalView.as_view(),
Expand Down
12 changes: 12 additions & 0 deletions api/goods/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
from api.core.authentication import ExporterAuthentication, SharedAuthentication, GovAuthentication
from api.core.exceptions import BadRequestError
from api.core.helpers import str_to_bool
from api.core.views import DocumentStreamAPIView
from api.documents.libraries.delete_documents_on_bad_request import delete_documents_on_bad_request
from api.documents.models import Document
from api.goods.enums import GoodStatus, GoodPvGraded, ItemCategory
from api.goods.filters import GoodFilter
from api.goods.goods_paginator import GoodListPaginator
from api.goods.helpers import (
FIREARMS_CORE_TYPES,
Expand Down Expand Up @@ -539,6 +541,16 @@ def delete(self, request, pk, doc_pk):
return JsonResponse({"document": "deleted success"})


class GoodDocumentStream(DocumentStreamAPIView):
authentication_classes = (ExporterAuthentication,)
filter_backends = (GoodFilter,)
queryset = GoodDocument.objects.all()
permission_classes = (IsDocumentInOrganisation,)

def get_document(self, instance):
return instance


class DocumentGoodOnApplicationInternalView(APIView):
authentication_classes = (GovAuthentication,)
serializer_class = GoodOnApplicationInternalDocumentCreateSerializer
Expand Down

0 comments on commit 76ccb5b

Please sign in to comment.