-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from openimis/feature/CM-710
CM-710: Backend Development for Program Selection and Filter Application
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
social_protection/signals/on_confirm_enrollment_of_individual.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
|
||
from django.core.exceptions import ValidationError | ||
from social_protection.models import Beneficiary | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def on_confirm_enrollment_of_individual(**kwargs): | ||
result = kwargs.get('result', None) | ||
benefit_plan_id = result['benefit_plan_id'] | ||
status = result['status'] | ||
user = result['user'] | ||
individuals_to_upload = result['individuals_not_assigned_to_selected_programme'] | ||
for individual in individuals_to_upload: | ||
# Create a new Beneficiary instance | ||
beneficiary = Beneficiary( | ||
individual=individual, | ||
benefit_plan_id=benefit_plan_id, | ||
status=status, | ||
json_ext=individual.json_ext | ||
) | ||
try: | ||
beneficiary.save(username=user.username) | ||
except ValidationError as e: | ||
logger.error(f"Validation error occurred: {e}") |