Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from jinja2 import Template

from account_mailer.email_processors import generate_template
from account_mailer.email_processors.utils import get_account_info
from account_mailer.pdf_utils import get_pdf_from_report_api


Expand All @@ -42,10 +43,16 @@ def process(data: dict, token: str) -> dict:
}


def _get_account_unlock_email(email_msg):
filled_template = generate_template(current_app.config.get("TEMPLATE_PATH"), email_msg.get("template_name"))
def _get_account_unlock_email(data):
org_id = data.get("accountId")
_, account_name_with_branch = get_account_info(org_id)
filled_template = generate_template(current_app.config.get("TEMPLATE_PATH"), data.get("template_name"))
jnja_template = Template(filled_template, autoescape=True)
html_out = jnja_template.render(account_name=email_msg.get("account_name"), logo_url=email_msg.get("logo_url"))
html_out = jnja_template.render(
logo_url=data.get("logo_url"),
account_name_with_branch=account_name_with_branch,
account_number=org_id,
)
return html_out


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,20 @@
# limitations under the License.
"""A Template for the account suspended email."""

# Local application imports
from auth_api.models import Org as OrgModel

# Third-party imports
from flask import current_app
from jinja2 import Template

from account_mailer.auth_utils import get_dashboard_url, get_login_url, get_payment_statements_url
from account_mailer.email_processors import generate_template
from account_mailer.email_processors.utils import get_account_info


def process(org_id, recipients, template_name, subject, logo_url, **kwargs) -> dict:
"""Build the email for Account notification."""
current_app.logger.debug("account notification: %s", org_id)

account_name: str = None
account_name_with_branch: str = None
if org_id:
org: OrgModel = OrgModel.find_by_id(org_id)
account_name = org.name
account_name_with_branch = org.name
if org.branch_name:
account_name_with_branch = f"{org.name} - {org.branch_name}"
current_app.logger.debug("account notification: %s", org_id)

account_name, account_name_with_branch = get_account_info(org_id)

# fill in template
filled_template = generate_template(current_app.config.get("TEMPLATE_PATH"), template_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
from jinja2 import Template

from account_mailer.email_processors import generate_template
from account_mailer.email_processors.utils import get_account_info
from account_mailer.pdf_utils import get_pdf_from_report_api, get_pdf_from_storage


def process(email_msg: dict, token: str) -> dict:
def process(email_msg: dict, org_id: str, token: str) -> dict:
"""Build the email for PAD Confirmation notification."""
current_app.logger.debug("email_msg notification: %s", email_msg)
# fill in template

_, account_name_with_branch = get_account_info(org_id)
username = email_msg.get("padTosAcceptedBy")
pad_tos_file_name = current_app.config["PAD_TOS_FILE"]
admin_emails, admin_name = _get_admin_emails(username)
pdf_attachment = _get_pad_confirmation_report_pdf(email_msg, token)
tos_attachment = _get_pdf(pad_tos_file_name)
html_body = _get_pad_confirmation_email_body(email_msg, admin_name)
html_body = _get_pad_confirmation_email_body(email_msg, admin_name, account_name_with_branch, org_id)
return {
"recipients": admin_emails,
"content": {
Expand Down Expand Up @@ -73,11 +73,17 @@ def _get_admin_emails(username):
return admin_emails, admin_name


def _get_pad_confirmation_email_body(email_msg, admin_name):
def _get_pad_confirmation_email_body(email_msg, admin_name, account_name_with_branch, account_number):
filled_template = generate_template(current_app.config.get("TEMPLATE_PATH"), "pad_confirmation_email")
# render template with vars from email msg
jnja_template = Template(filled_template, autoescape=True)
html_out = jnja_template.render(request=email_msg, admin_name=admin_name, logo_url=email_msg.get("logo_url"))
html_out = jnja_template.render(
request=email_msg,
admin_name=admin_name,
logo_url=email_msg.get("logo_url"),
account_name_with_branch=account_name_with_branch,
account_number=account_number,
)
return html_out


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright © 2019 Province of British Columbia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utility functions for email processors."""

from auth_api.models import Org as OrgModel


def get_account_info(org_id: int | None) -> tuple[str | None, str | None]:
"""Get account name and account name with branch for an org."""
if not org_id:
return None, None
org = OrgModel.find_by_id(org_id)
account_name = org.name
account_name_with_branch = org.name
if org.branch_name:
account_name_with_branch = f"{org.name} - {org.branch_name}"
return account_name, account_name_with_branch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Account: {{ account_name_with_branch }} (Account Number: {{ account_number }})

We have received payment in the amount of ${{ paid_amount }}. Payment received over the outstanding balance has been applied as a credit to your account and will be applied to future purchases.
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Account: {{ account_name_with_branch }} (Account Number: {{ account_number }})

We have received payment in the amount of ${{ paid_amount }} and your products are now available.
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Account: {{ account_name_with_branch }} (Account Number: {{ account_number }})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image


We have received payment in the amount of ${{ paid_amount }}. Please pay the outstanding balance to access your products.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Account: {{ account_name_with_branch }} (Account Number: {{ account_number }})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image


Please find attached your **Confirmation Letter of Pre-Authorized Debit (PAD) Sign-up** and a copy of your **Business Pre-Authorized Debit Terms and Conditions Agreement** with BC Registries and Online Services.

If you have questions, please contact the BC Online Partnership Office. Contact details are included in your confirmation letter.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Account: {{ account_name_with_branch }} (Account Number: {{ account_number }})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image


When you setup pre-authorized debit, the bank information you entered was invalid.

To unlock your account, please review and update your bank information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Account: {{ account_name_with_branch }} (Account Number: {{ account_number }})

# You've been approved for {{ product_access_descriptor }} access to {{ category_descriptor }}.

{% if is_reapproved %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Account: {{ account_name_with_branch }} (Account Number: {{ account_number }})

# Your application for {{ product_access_descriptor }} access to {{ category_descriptor }} has been received.

BC Registries staff have received your application to have **{{ product_name }}** access to {{ category_descriptor }}, and your request is under review.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Account: {{ account_name_with_branch }} (Account Number: {{ account_number }})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image


# Your Team Member Request is On hold.

Thank you for your interest with BC Registries and Online Services. Our office was attempting to approve your application sent on {{ applicationDate }} but, had to place your account creation request on hold for the following reason(s):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Account: {{ account_name_with_branch }} (Account Number: {{ account_number }})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image


# Your Account Creation Request is On hold.

Thank you for your interest with BC Registries and Online Services. Our office was attempting to approve your application sent on {{ applicationDate }} but, had to place your account creation request on hold for the following reason(s):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Account: {{ account_name_with_branch }} (Account Number: {{ account_number }})

# **{{ user_first_name }} {{ user_last_name }}** has submitted a request that requires your approval. You will need to log in using your IDIR to approve this request.

[Review Account]({{ context_url }})
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def handle_pad_account_create(message_type, email_msg):
return
email_msg["registry_logo_url"] = google_store.GoogleStoreService.get_static_resource_url("bc_registry_logo_pdf.svg")
token = RestService.get_service_account_token()
email_dict = pad_confirmation.process(email_msg, token)
org_id = email_msg.get("accountId")
email_dict = pad_confirmation.process(email_msg, org_id, token)
process_email(email_dict, token)


Expand Down