From 15e4bc4d50d4d8b6f4031b122f8afa74d8282d47 Mon Sep 17 00:00:00 2001 From: Shayan Mouktar <119674649+Shayan105@users.noreply.github.com> Date: Mon, 6 Oct 2025 11:43:29 +0200 Subject: [PATCH 1/4] Restirct notif. to only hold of type SUB_CHILD_HOLD --- child_compassion/models/compassion_hold.py | 40 +++++++++++++--------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/child_compassion/models/compassion_hold.py b/child_compassion/models/compassion_hold.py index 79b27c82c..653fa3bfd 100644 --- a/child_compassion/models/compassion_hold.py +++ b/child_compassion/models/compassion_hold.py @@ -486,24 +486,30 @@ def postpone_no_money_hold(self, additional_text=None): } hold.write(hold_vals) - body = ( - "The no money hold for child {local_id} was expiring on " - "{old_expiration} and was extended to {new_expiration} " - "({extension_description} extension).{additional_text}" - ) - hold.message_post( - body=_(body.format(**values)), - subject=_("No money hold extension"), - subtype_xmlid="mail.mt_comment", - ) + # ---------------------------------------------------- + # NOTIFICATION (Only for SUB_CHILD_HOLD) + # ---------------------------------------------------- + if hold.type == HoldType.SUB_CHILD_HOLD: + if hold.child_id.sponsor_id: + body = ( + "The no money hold for child {local_id} was expiring on " + "{old_expiration} and was extended to {new_expiration} " + "({extension_description} extension).{additional_text}" + ) + hold.message_post( + body=_(body.format(**values)), + subject=_("No money hold extension"), + subtype_xmlid="mail.mt_comment", + ) + else : + body = _( + "The no money hold for child {local_id} is expiring on " + "{old_expiration} and will not be extended since " + "no sponsorship exists for this child." + ) + hold.message_post(body=body.format(**values)) + - else: - body = _( - "The no money hold for child {local_id} is expiring on " - "{old_expiration} and will not be extended since " - "no sponsorship exists for this child." - ) - hold.message_post(body=body.format(**values)) ########################################################################## # Mapping METHOD # From 17eb3e60264a8e4af38b7e50aa781d525e518666 Mon Sep 17 00:00:00 2001 From: Shayan Mouktar <119674649+Shayan105@users.noreply.github.com> Date: Mon, 6 Oct 2025 11:44:34 +0200 Subject: [PATCH 2/4] Run precommit --- child_compassion/models/compassion_hold.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/child_compassion/models/compassion_hold.py b/child_compassion/models/compassion_hold.py index 653fa3bfd..824d3c047 100644 --- a/child_compassion/models/compassion_hold.py +++ b/child_compassion/models/compassion_hold.py @@ -501,7 +501,7 @@ def postpone_no_money_hold(self, additional_text=None): subject=_("No money hold extension"), subtype_xmlid="mail.mt_comment", ) - else : + else: body = _( "The no money hold for child {local_id} is expiring on " "{old_expiration} and will not be extended since " @@ -509,8 +509,6 @@ def postpone_no_money_hold(self, additional_text=None): ) hold.message_post(body=body.format(**values)) - - ########################################################################## # Mapping METHOD # ########################################################################## From 4194347e218778b2933025020bd721bd1372070c Mon Sep 17 00:00:00 2001 From: Shayan Mouktar <119674649+Shayan105@users.noreply.github.com> Date: Mon, 6 Oct 2025 12:42:21 +0200 Subject: [PATCH 3/4] Correct wrong type of Hold --- child_compassion/models/compassion_hold.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/child_compassion/models/compassion_hold.py b/child_compassion/models/compassion_hold.py index 824d3c047..8c0566911 100644 --- a/child_compassion/models/compassion_hold.py +++ b/child_compassion/models/compassion_hold.py @@ -487,9 +487,9 @@ def postpone_no_money_hold(self, additional_text=None): hold.write(hold_vals) # ---------------------------------------------------- - # NOTIFICATION (Only for SUB_CHILD_HOLD) + # NOTIFICATION (Only for NO_MONEY_HOLD) # ---------------------------------------------------- - if hold.type == HoldType.SUB_CHILD_HOLD: + if hold.type == HoldType.NO_MONEY_HOLD: if hold.child_id.sponsor_id: body = ( "The no money hold for child {local_id} was expiring on " From 093dacd1c6ca97fa4f205704dc142ef339d01ac0 Mon Sep 17 00:00:00 2001 From: Shayan Mouktar <119674649+Shayan105@users.noreply.github.com> Date: Mon, 6 Oct 2025 13:26:56 +0200 Subject: [PATCH 4/4] Fix typo --- child_compassion/models/compassion_hold.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/child_compassion/models/compassion_hold.py b/child_compassion/models/compassion_hold.py index 8c0566911..efbb1d702 100644 --- a/child_compassion/models/compassion_hold.py +++ b/child_compassion/models/compassion_hold.py @@ -489,7 +489,7 @@ def postpone_no_money_hold(self, additional_text=None): # ---------------------------------------------------- # NOTIFICATION (Only for NO_MONEY_HOLD) # ---------------------------------------------------- - if hold.type == HoldType.NO_MONEY_HOLD: + if hold.type == HoldType.NO_MONEY_HOLD.value: if hold.child_id.sponsor_id: body = ( "The no money hold for child {local_id} was expiring on "