Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions auth-api/src/auth_api/services/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,13 +980,13 @@ def change_org_status(self, status_code, suspension_reason_code):
return Org(org_model)

@staticmethod
def approve_or_reject(org_id: int, is_approved: bool, task_action: str = None):
def approve_or_reject(org_id: int, is_approved: bool, client_id: int, task_action: str = None):
"""Mark the affidavit as approved or rejected."""
current_app.logger.debug("<find_affidavit_by_org_id ")
# Get the org and check what's the current status
org: OrgModel = OrgModel.find_by_org_id(org_id)

# Current User
# Current User - usually staff admin
user: UserModel = UserModel.find_by_jwt_token()

if task_action == TaskAction.AFFIDAVIT_REVIEW.value:
Expand All @@ -1007,10 +1007,10 @@ def approve_or_reject(org_id: int, is_approved: bool, task_action: str = None):
admin_emails = UserService.get_admin_emails_for_org(org_id)
if admin_emails != "":
if org.access_type in (AccessType.EXTRA_PROVINCIAL.value, AccessType.REGULAR_BCEID.value):
Org.send_approved_rejected_notification(admin_emails, org.name, org.id, org.status_code, user)
Org.send_approved_rejected_notification(admin_emails, org.name, org.id, org.status_code, client_id)
elif org.access_type in (AccessType.GOVM.value, AccessType.GOVN.value):
Org.send_approved_rejected_govm_govn_notification(
admin_emails, org.name, org.id, org.status_code, user
admin_emails, org.name, org.id, org.status_code, client_id
)
else:
# continue but log error
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def send_staff_review_account_reminder(relationship_id, task_relationship_type=T
raise BusinessException(Error.FAILED_NOTIFICATION, None) from e

@staticmethod
def send_approved_rejected_notification(receipt_admin_emails, org_name, org_id, org_status: OrgStatus, user: UserModel = None):
def send_approved_rejected_notification(receipt_admin_emails, org_name, org_id, org_status: OrgStatus, client_id: int):
"""Send Approved/Rejected notification to the user."""
current_app.logger.debug("<send_approved_rejected_notification")

Expand All @@ -1062,12 +1062,13 @@ def send_approved_rejected_notification(receipt_admin_emails, org_name, org_id,
else:
return # Don't send mail for any other status change
app_url = current_app.config.get("WEB_APP_URL")
client: UserModel = UserModel.find_by_id(client_id)
data = {
"accountId": org_id,
"emailAddresses": receipt_admin_emails,
"contextUrl": app_url,
"orgName": org_name,
"loginSource": user.login_source
"loginSource": client.login_source
}
try:
publish_to_mailer(notification_type, data=data)
Expand All @@ -1078,7 +1079,7 @@ def send_approved_rejected_notification(receipt_admin_emails, org_name, org_id,

@staticmethod
def send_approved_rejected_govm_govn_notification(
receipt_admin_email, org_name, org_id, org_status: OrgStatus, origin_url, user: UserModel
receipt_admin_email, org_name, org_id, org_status: OrgStatus, origin_url, client_id: int
):
"""Send Approved govm notification to the user."""
current_app.logger.debug("<send_approved_rejected_govm_govn_notification")
Expand All @@ -1090,7 +1091,8 @@ def send_approved_rejected_govm_govn_notification(
else:
return # Don't send mail for any other status change
app_url = f"{origin_url}/"
data = {"accountId": org_id, "emailAddresses": receipt_admin_email, "contextUrl": app_url, "orgName": org_name, "loginSource": user.login_source}
client: UserModel = UserModel.find_by_id(client_id)
data = {"accountId": org_id, "emailAddresses": receipt_admin_email, "contextUrl": app_url, "orgName": org_name, "loginSource": client.login_source}
try:
publish_to_mailer(notification_type, data=data)
current_app.logger.debug("send_approved_rejected_govm_govn_notification>")
Expand Down
7 changes: 4 additions & 3 deletions auth-api/src/auth_api/services/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ def _update_relationship(self):
if task_model.relationship_type == TaskRelationshipType.ORG.value:
# Update Org relationship
org_id = task_model.relationship_id

if not is_hold:
self._update_org(
is_approved=is_approved, org_id=org_id, task_action=task_model.action
is_approved=is_approved, org_id=org_id, client_id=task_model.created_by_id, task_action=task_model.action
)
else:
# Task with ACCOUNT_REVIEW action cannot be put on hold
Expand Down Expand Up @@ -223,14 +224,14 @@ def _notify_admin_about_hold(
raise BusinessException(Error.FAILED_NOTIFICATION, None) from e

@staticmethod
def _update_org(is_approved: bool, org_id: int, task_action: str = None):
def _update_org(is_approved: bool, org_id: int, client_id: int, task_action: str = None):
"""Approve/Reject Affidavit and Org."""
from auth_api.services import Org as OrgService # pylint:disable=cyclic-import, import-outside-toplevel

current_app.logger.debug("<update_task_org ")

OrgService.approve_or_reject(
org_id=org_id, is_approved=is_approved, task_action=task_action
org_id=org_id, is_approved=is_approved, client_id=client_id, task_action=task_action
)

current_app.logger.debug(">update_task_org ")
Expand Down
81 changes: 41 additions & 40 deletions queue_services/account-mailer/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions queue_services/account-mailer/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ packages = [

[tool.poetry.dependencies]
python = ">=3.12,<3.13"
blinker = "1.8.2"
blinker = ">=1.9.0"
charset-normalizer = "3.3.2"
click = "8.1.7"
expiringdict = "1.2.2"
Expand All @@ -38,7 +38,7 @@ urllib3 = "2.6.3"
zipp = "3.19.1"

# VCS dependencies
auth-api = { git = "https://github.com/seeker25/sbc-auth.git", branch = "32356", subdirectory = "auth-api" }
auth-api = { git = "https://github.com/bcgov/sbc-auth.git", branch = "main", subdirectory = "auth-api" }
simple-cloudevent = { git = "https://github.com/daxiom/simple-cloudevent.py.git" }
cloud-sql-python-connector = "^1.13.0"
pkginfo = "^1.12.1.2"
Expand Down