Skip to content

Commit 9b6f7da

Browse files
ecinoShayan105
andauthored
T2240 no money hold extension reminders (#2066)
* Restirct notif. to only hold of type SUB_CHILD_HOLD * Run precommit * Correct wrong type of Hold * Fix typo --------- Co-authored-by: Shayan Mouktar <119674649+Shayan105@users.noreply.github.com>
1 parent cf62988 commit 9b6f7da

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

child_compassion/models/compassion_hold.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -486,24 +486,28 @@ def postpone_no_money_hold(self, additional_text=None):
486486
}
487487
hold.write(hold_vals)
488488

489-
body = (
490-
"The no money hold for child {local_id} was expiring on "
491-
"{old_expiration} and was extended to {new_expiration} "
492-
"({extension_description} extension).{additional_text}"
493-
)
494-
hold.message_post(
495-
body=_(body.format(**values)),
496-
subject=_("No money hold extension"),
497-
subtype_xmlid="mail.mt_comment",
498-
)
499-
500-
else:
501-
body = _(
502-
"The no money hold for child {local_id} is expiring on "
503-
"{old_expiration} and will not be extended since "
504-
"no sponsorship exists for this child."
505-
)
506-
hold.message_post(body=body.format(**values))
489+
# ----------------------------------------------------
490+
# NOTIFICATION (Only for NO_MONEY_HOLD)
491+
# ----------------------------------------------------
492+
if hold.type == HoldType.NO_MONEY_HOLD.value:
493+
if hold.child_id.sponsor_id:
494+
body = (
495+
"The no money hold for child {local_id} was expiring on "
496+
"{old_expiration} and was extended to {new_expiration} "
497+
"({extension_description} extension).{additional_text}"
498+
)
499+
hold.message_post(
500+
body=_(body.format(**values)),
501+
subject=_("No money hold extension"),
502+
subtype_xmlid="mail.mt_comment",
503+
)
504+
else:
505+
body = _(
506+
"The no money hold for child {local_id} is expiring on "
507+
"{old_expiration} and will not be extended since "
508+
"no sponsorship exists for this child."
509+
)
510+
hold.message_post(body=body.format(**values))
507511

508512
##########################################################################
509513
# Mapping METHOD #

0 commit comments

Comments
 (0)