@@ -980,13 +980,13 @@ def change_org_status(self, status_code, suspension_reason_code):
980980 return Org (org_model )
981981
982982 @staticmethod
983- def approve_or_reject (org_id : int , is_approved : bool , task_action : str = None ):
983+ def approve_or_reject (org_id : int , is_approved : bool , client_id : int , task_action : str = None ):
984984 """Mark the affidavit as approved or rejected."""
985985 current_app .logger .debug ("<find_affidavit_by_org_id " )
986986 # Get the org and check what's the current status
987987 org : OrgModel = OrgModel .find_by_org_id (org_id )
988988
989- # Current User
989+ # Current User - usually staff admin
990990 user : UserModel = UserModel .find_by_jwt_token ()
991991
992992 if task_action == TaskAction .AFFIDAVIT_REVIEW .value :
@@ -1007,10 +1007,10 @@ def approve_or_reject(org_id: int, is_approved: bool, task_action: str = None):
10071007 admin_emails = UserService .get_admin_emails_for_org (org_id )
10081008 if admin_emails != "" :
10091009 if org .access_type in (AccessType .EXTRA_PROVINCIAL .value , AccessType .REGULAR_BCEID .value ):
1010- Org .send_approved_rejected_notification (admin_emails , org .name , org .id , org .status_code , user )
1010+ Org .send_approved_rejected_notification (admin_emails , org .name , org .id , org .status_code , client_id )
10111011 elif org .access_type in (AccessType .GOVM .value , AccessType .GOVN .value ):
10121012 Org .send_approved_rejected_govm_govn_notification (
1013- admin_emails , org .name , org .id , org .status_code , user
1013+ admin_emails , org .name , org .id , org .status_code , client_id
10141014 )
10151015 else :
10161016 # continue but log error
@@ -1051,7 +1051,7 @@ def send_staff_review_account_reminder(relationship_id, task_relationship_type=T
10511051 raise BusinessException (Error .FAILED_NOTIFICATION , None ) from e
10521052
10531053 @staticmethod
1054- def send_approved_rejected_notification (receipt_admin_emails , org_name , org_id , org_status : OrgStatus , user : UserModel = None ):
1054+ def send_approved_rejected_notification (receipt_admin_emails , org_name , org_id , org_status : OrgStatus , client_id : int ):
10551055 """Send Approved/Rejected notification to the user."""
10561056 current_app .logger .debug ("<send_approved_rejected_notification" )
10571057
@@ -1062,12 +1062,13 @@ def send_approved_rejected_notification(receipt_admin_emails, org_name, org_id,
10621062 else :
10631063 return # Don't send mail for any other status change
10641064 app_url = current_app .config .get ("WEB_APP_URL" )
1065+ client : UserModel = UserModel .find_by_id (client_id )
10651066 data = {
10661067 "accountId" : org_id ,
10671068 "emailAddresses" : receipt_admin_emails ,
10681069 "contextUrl" : app_url ,
10691070 "orgName" : org_name ,
1070- "loginSource" : user .login_source
1071+ "loginSource" : client .login_source
10711072 }
10721073 try :
10731074 publish_to_mailer (notification_type , data = data )
@@ -1078,7 +1079,7 @@ def send_approved_rejected_notification(receipt_admin_emails, org_name, org_id,
10781079
10791080 @staticmethod
10801081 def send_approved_rejected_govm_govn_notification (
1081- receipt_admin_email , org_name , org_id , org_status : OrgStatus , origin_url , user : UserModel
1082+ receipt_admin_email , org_name , org_id , org_status : OrgStatus , origin_url , client_id : int
10821083 ):
10831084 """Send Approved govm notification to the user."""
10841085 current_app .logger .debug ("<send_approved_rejected_govm_govn_notification" )
@@ -1090,7 +1091,8 @@ def send_approved_rejected_govm_govn_notification(
10901091 else :
10911092 return # Don't send mail for any other status change
10921093 app_url = f"{ origin_url } /"
1093- data = {"accountId" : org_id , "emailAddresses" : receipt_admin_email , "contextUrl" : app_url , "orgName" : org_name , "loginSource" : user .login_source }
1094+ client : UserModel = UserModel .find_by_id (client_id )
1095+ data = {"accountId" : org_id , "emailAddresses" : receipt_admin_email , "contextUrl" : app_url , "orgName" : org_name , "loginSource" : client .login_source }
10941096 try :
10951097 publish_to_mailer (notification_type , data = data )
10961098 current_app .logger .debug ("send_approved_rejected_govm_govn_notification>" )
0 commit comments