diff --git a/data_disclosure_agreement/serializers.py b/data_disclosure_agreement/serializers.py index 1420f67..e4118bf 100644 --- a/data_disclosure_agreement/serializers.py +++ b/data_disclosure_agreement/serializers.py @@ -11,4 +11,4 @@ class Meta: class DataDisclosureAgreementSerializer(serializers.ModelSerializer): class Meta: model = DataDisclosureAgreement - fields = ['dataDisclosureAgreementRecord'] + fields = ['dataDisclosureAgreementRecord','status','isLatestVersion'] diff --git a/data_disclosure_agreement/views.py b/data_disclosure_agreement/views.py index d617bbb..90d05a7 100644 --- a/data_disclosure_agreement/views.py +++ b/data_disclosure_agreement/views.py @@ -46,9 +46,13 @@ def get(self, request, dataDisclosureAgreementId): serializer = self.serializer_class( data_disclosure_agreement, context={"request": request} ) + dda = serializer.data["dataDisclosureAgreementRecord"] + dda['status'] = serializer.data['status'] + dda['isLatestVersion'] = serializer.data['isLatestVersion'] response_data = { - "dataDisclosureAgreement": serializer.data["dataDisclosureAgreementRecord"], + "dataDisclosureAgreement": dda, } + return JsonResponse(response_data) def delete(self, request, dataDisclosureAgreementId): @@ -116,8 +120,9 @@ def get(self, request): temp_dda = dda["dataDisclosureAgreementRecord"] else: revisions.append(dda["dataDisclosureAgreementRecord"]) - temp_dda["revisions"] = revisions - ddas.append(temp_dda) + if temp_dda: + temp_dda["revisions"] = revisions + ddas.append(temp_dda) else: temp_dda = {} for dda_template_id in data_disclosure_agreements_template_ids: diff --git a/service/views.py b/service/views.py index 654fbff..43f3375 100644 --- a/service/views.py +++ b/service/views.py @@ -64,7 +64,7 @@ def get(self, request): data_sources = DataSource.objects.filter(pk=dataSourceId_param) else: data_sources = DataSource.objects.all() - + data_sources, pagination_data = paginate_queryset(data_sources, request) serialized_data_sources = [] for data_source in data_sources: @@ -84,11 +84,16 @@ def get(self, request): data_disclosure_agreement_serializer = ( DataDisclosureAgreementsSerializer(dda_for_template_id) ) - ddas.append( - data_disclosure_agreement_serializer.data[ - "dataDisclosureAgreementRecord" + dda = data_disclosure_agreement_serializer.data[ + "dataDisclosureAgreementRecord" + ] + + if dda: + dda["status"] = data_disclosure_agreement_serializer.data["status"] + dda["isLatestVersion"] = data_disclosure_agreement_serializer.data[ + "isLatestVersion" ] - ) + ddas.append(dda) try: verification = Verification.objects.get(dataSourceId=data_source)