From da7b304354e0038ce65678b04f50df33bcec45c3 Mon Sep 17 00:00:00 2001 From: joshua160miller Date: Thu, 28 Nov 2024 10:30:28 +0530 Subject: [PATCH] resolved bug for decryption --- g2p_registry_encryption/models/partner.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/g2p_registry_encryption/models/partner.py b/g2p_registry_encryption/models/partner.py index 9702a0fb..2d527caa 100644 --- a/g2p_registry_encryption/models/partner.py +++ b/g2p_registry_encryption/models/partner.py @@ -89,14 +89,15 @@ def _fetch_query(self, query, fields): ) if not is_decrypt_fields: return res - for record in self: - is_encrypted, encrypted_val = record.get_encrypted_val()[0] - if is_encrypted and encrypted_val: - decrypted_vals = json.loads(prov.decrypt_data(encrypted_val).decode()) - - for field_name in enc_fields_set: - if field_name in decrypted_vals and field_name in record and record[field_name]: - self.env.cache.set(record, self._fields[field_name], decrypted_vals[field_name]) + if len(self) == 1 and self.is_registrant: + for record in self: + is_encrypted, encrypted_val = record.get_encrypted_val()[0] + if is_encrypted and encrypted_val: + decrypted_vals = json.loads(prov.decrypt_data(encrypted_val).decode()) + for field_name in enc_fields_set: + if field_name in decrypted_vals and field_name in record and record[field_name]: + self.env.cache.set(record, self._fields[field_name], decrypted_vals[field_name]) + return res def get_encrypted_val(self):