Skip to content

Commit

Permalink
Add goods on licences endpoint initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hnryjmes committed Nov 26, 2024
1 parent b29bcb4 commit abcc8b1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions api/data_workspace/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
)
from api.cases.enums import LicenceDecisionType
from api.cases.models import LicenceDecision
from api.cases.models import Case
from api.licences.models import GoodOnLicence
from api.staticdata.countries.models import Country
from api.staticdata.report_summaries.models import ReportSummary

Expand Down Expand Up @@ -94,6 +96,10 @@ class Meta:
"description",
"good_id",
)
class GoodOnLicenceSerializer(serializers.ModelSerializer):
class Meta:
model = GoodOnLicence
fields = ("id", "good_id", "licence_id")


class ApplicationSerializer(serializers.ModelSerializer):
Expand Down
4 changes: 4 additions & 0 deletions api/data_workspace/v2/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
router_v2.register(views.CountryViewSet)
router_v2.register(views.DestinationViewSet)
router_v2.register(views.GoodViewSet)
<<<<<<< HEAD
router_v2.register(views.GoodDescriptionViewSet)
=======
router_v2.register(views.GoodOnLicenceViewSet)
>>>>>>> ea66a2a2 (Add goods on licences endpoint initial commit)
router_v2.register(views.ApplicationViewSet)
12 changes: 12 additions & 0 deletions api/data_workspace/v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
GoodDescriptionSerializer,
GoodSerializer,
LicenceDecisionSerializer,
LicenceDecisionType,
GoodOnLicenceSerializer,
)
from api.licences.enums import LicenceStatus
from api.licences.models import GoodOnLicence
from api.staticdata.countries.models import Country
from api.staticdata.report_summaries.models import ReportSummary
from api.staticdata.statuses.enums import CaseStatusEnum
Expand Down Expand Up @@ -117,6 +121,14 @@ def get_closed_statuses():
)


class GoodOnLicenceViewSet(BaseViewSet):
serializer_class = GoodOnLicenceSerializer
queryset = GoodOnLicence.objects.exclude(
licence__case__status__=CaseStatusEnum.DRAFT,
licence__status=LicenceStatus.DRAFT,
)


class ApplicationViewSet(BaseViewSet):
serializer_class = ApplicationSerializer
queryset = (
Expand Down
2 changes: 1 addition & 1 deletion lite_routing

0 comments on commit abcc8b1

Please sign in to comment.