Skip to content

Commit

Permalink
Merge branch '14.0' into T1658-public-holiday-automatic-message
Browse files Browse the repository at this point in the history
  • Loading branch information
clementcharmillot authored Aug 13, 2024
2 parents aa711a5 + 9706f9b commit eb3bf31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
15 changes: 0 additions & 15 deletions child_compassion/models/child_compassion.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,6 @@ def unlink(self):
holds.release_hold()
return res

def unlink_job(self):
"""Small wrapper to unlink only released children."""
return self.filtered(lambda c: c.state == "R").unlink()

##########################################################################
# PUBLIC METHODS #
##########################################################################
Expand Down Expand Up @@ -701,17 +697,6 @@ def child_released(self, state="R"):
to_release.write({"sponsor_id": False, "state": state, "hold_id": False})
# Check if it was a depart and retrieve lifecycle event
to_release.get_lifecycle_event()

# the children will be deleted when we reach their expiration date
postpone = 60 * 60 * 24 * 7 # One week by default
today = datetime.today()
for child in to_release.filtered(lambda c: not c.has_been_sponsored):
if child.hold_expiration:
expire = child.hold_expiration
postpone = (expire - today).total_seconds() + 60

child.with_delay(eta=postpone).unlink_job()

return True

def child_departed(self):
Expand Down
4 changes: 3 additions & 1 deletion child_compassion/models/child_lifecycle_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ class ChildLifecycleEvent(models.Model):
[
("Abuse", "Abuse"),
("Fatal Accident or Suicide", "Fatal Accident or Suicide"),
("Fatal Accident", "Fatal Accident"),
("Suicide", "Suicide"),
("Gastro-Intestinal", "Gastro-Intestinal"),
("Infection", "Infection"),
("Maternal", "Maternal"),
Expand All @@ -299,7 +301,7 @@ class ChildLifecycleEvent(models.Model):
("Chicken Pox", "Chicken Pox"),
("Chikungunya", "Chikungunya"),
("Cholera", "Cholera"),
("Congenital Abnormalities", "Congenital Abnormalities"),
("Congenital Abnormalitie s", "Congenital Abnormalities"),
("Dengue", "Dengue"),
("Diabetes", "Diabetes"),
("Diarrhea", "Diarrhea"),
Expand Down

0 comments on commit eb3bf31

Please sign in to comment.