Skip to content

Commit

Permalink
Fix: #54 Data disclosure agreement issues
Browse files Browse the repository at this point in the history
  • Loading branch information
albinpa authored and georgepadayatti committed Apr 6, 2024
1 parent 711a56c commit de20f42
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
52 changes: 28 additions & 24 deletions data_disclosure_agreement/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,37 +107,41 @@ def get(self, request):
if status_param:
temp_dda = {}
for dda_template_id in data_disclosure_agreements_template_ids:
ddas_for_template_id = DataDisclosureAgreement.list_by_data_source_id(
templateId=dda_template_id,
data_source_id=datasource.id,
status=status_param,
latest_dda_for_template_id = (
DataDisclosureAgreement.objects.filter(
templateId=dda_template_id,
dataSourceId=datasource,
status=status_param,
)
.order_by("-createdAt")
.first()
)
revisions = []
serializer = self.serializer_class(ddas_for_template_id, many=True)

for index, dda in enumerate(serializer.data):
if index == 0:
temp_dda = dda["dataDisclosureAgreementRecord"]
else:
revisions.append(dda["dataDisclosureAgreementRecord"])

serializer = self.serializer_class(latest_dda_for_template_id)
temp_dda = serializer.data["dataDisclosureAgreementRecord"]

if temp_dda:
temp_dda["revisions"] = revisions
temp_dda['status'] = serializer.data['status']
temp_dda['isLatestVersion'] = serializer.data['isLatestVersion']
ddas.append(temp_dda)
else:
temp_dda = {}
for dda_template_id in data_disclosure_agreements_template_ids:
ddas_for_template_id = DataDisclosureAgreement.list_by_data_source_id(
templateId=dda_template_id, data_source_id=datasource.id
latest_dda_for_template_id = (
DataDisclosureAgreement.objects.filter(
templateId=dda_template_id,
dataSourceId=datasource,
isLatestVersion=True,
)
.order_by("-createdAt")
.first()
)
revisions = []
serializer = self.serializer_class(ddas_for_template_id, many=True)
for dda in serializer.data:
if dda["isLatestVersion"]:
temp_dda = dda["dataDisclosureAgreementRecord"]
else:
revisions.append(dda["dataDisclosureAgreementRecord"])
temp_dda["revisions"] = revisions
ddas.append(temp_dda)
serializer = self.serializer_class(latest_dda_for_template_id)
temp_dda = serializer.data["dataDisclosureAgreementRecord"]
if temp_dda:
temp_dda['status'] = serializer.data['status']
temp_dda['isLatestVersion'] = serializer.data['isLatestVersion']
ddas.append(temp_dda)

ddas, pagination_data = paginate_queryset(ddas, request)

Expand Down
1 change: 0 additions & 1 deletion webhook/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def receive_data_disclosure_agreement(request):
"personalData": response["dda"]["personalData"],
"codeOfConduct": response["dda"]["codeOfConduct"],
"connection": dda_connection,
"status": "unlisted",
}
post_save.connect(
query_ddas_and_update_is_latest_flag_to_false_for_previous_versions,
Expand Down

0 comments on commit de20f42

Please sign in to comment.