Skip to content

Commit

Permalink
20142 Update consent letters (#1524)
Browse files Browse the repository at this point in the history
* update email files

* update email consent letter logic

* add attachment to consent letter email

* fix template string env variables

* bump version

* fix NAMES_INFORMATION_URL link
  • Loading branch information
semmatti authored Apr 26, 2024
1 parent f52aba4 commit 2901824
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 28 deletions.
4 changes: 2 additions & 2 deletions api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class Config(object):

NAME_REQUEST_URL = os.getenv('NAME_REQUEST_URL', '')
NAMES_INFORMATION_URL = os.getenv('NAMES_INFORMATION_URL',
'https://www2.gov.bc.ca/gov/content/employment-business/business/managing-a-business/ \
permits-licences/businesses-incorporated-companies/approval-business-name')
'https://www2.gov.bc.ca/gov/content/employment-business/business/managing-a-business/\
permits-licences/businesses-incorporated-companies/approval-business-name')

DECIDE_BUSINESS_URL = os.getenv('DECIDE_BUSINESS_URL', '')
BUSINESS_CHANGES_URL = os.getenv('BUSINESS_CHANGES_URL', '')
Expand Down
2 changes: 1 addition & 1 deletion api/namex/VERSION.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '1.1.54'
__version__ = '1.1.55'

60 changes: 39 additions & 21 deletions api/namex/resources/name_requests/report_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def email_consent_letter(self, nr_id):
nr_model = Request.query.get(nr_id)
if not nr_model:
return jsonify(message='{nr_id} not found'.format(nr_id=nr_model.id)), HTTPStatus.NOT_FOUND
report, status_code = ReportResource._get_report(nr_model)
if status_code != HTTPStatus.OK:
return jsonify(message=str(report)), status_code
report_name = nr_model.nrNum + ' - ' + CONSENT_EMAIL_SUBJECT
recipient_emails = []
for applicant in nr_model.applicants:
Expand All @@ -49,15 +52,26 @@ def email_consent_letter(self, nr_id):
ReportResource._add_expiry_date(nr_model)
recipients = ','.join(recipient_emails)
template_path = current_app.config.get('REPORT_TEMPLATE_PATH')
email_body = Path(f'{template_path}/emails/consent.md').read_text()
email_body = email_body.replace('{{EXPIRATION_DATE}}', nr_model.expirationDate.strftime(DATE_FORMAT))
email_body = email_body.replace('{{NAMEREQUEST_NUMBER}}', nr_model.nrNum)
file_name = 'consent'
instruction_group = ReportResource._get_instruction_group(nr_model.entity_type_cd)
if instruction_group:
file_name = f"{file_name}-{instruction_group}"
email_template = Path(f'{template_path}/emails/{file_name}.md').read_text()
email_body = ReportResource._build_email_body(email_template, nr_model)
attachments = [
{
'fileName': report_name.replace(' - ', ' ').replace(' ', '_') + '.pdf',
'fileBytes': base64.b64encode(report).decode(),
'fileUrl': '',
'attachOrder': 1
}
]
email = {
'recipients': recipients,
'content': {
'subject': report_name,
'body': email_body,
'attachments': []
'attachments': attachments
}
}
return ReportResource._send_email(email)
Expand All @@ -78,7 +92,7 @@ def email_report(self, nr_id):
recipient_emails.append(applicant.emailAddress)
recipients = ','.join(recipient_emails)
template_path = current_app.config.get('REPORT_TEMPLATE_PATH')
email_body = Path(f'{template_path}/emails/rejected.md').read_text()
email_template = Path(f'{template_path}/emails/rejected.md').read_text()
if nr_model.stateCd in [State.APPROVED, State.CONDITIONAL]:
instruction_group = ReportResource._get_instruction_group(nr_model.entity_type_cd)
file_name=''
Expand All @@ -91,22 +105,9 @@ def email_report(self, nr_id):
file_name += '-'
file_name += instruction_group

email_body = Path(f'{template_path}/emails/{file_name}.md').read_text()
email_body = email_body.replace('{{EXPIRATION_DATE}}', nr_model.expirationDate.strftime(DATE_FORMAT))

DECIDE_BUSINESS_URL = current_app.config.get('DECIDE_BUSINESS_URL')
CORP_FORMS_URL = current_app.config.get('CORP_FORMS_URL')
CORP_ONLINE_URL = current_app.config.get('COLIN_URL')
NAME_REQUEST_URL = current_app.config.get('NAME_REQUEST_URL')
NAMES_INFORMATION_URL = current_app.config.get('NAMES_INFORMATION_URL')
SOCIETIES_URL = current_app.config.get('SOCIETIES_URL')
email_body = email_body.replace('{{NAMES_INFORMATION_URL}}', NAMES_INFORMATION_URL)
email_body = email_body.replace('{{NAME_REQUEST_URL}}', NAME_REQUEST_URL)
email_body = email_body.replace('{{NAMEREQUEST_NUMBER}}', nr_model.nrNum)
email_body = email_body.replace('{{BUSINESS_URL}}', DECIDE_BUSINESS_URL)
email_body = email_body.replace('{{CORP_ONLINE_URL}}', CORP_ONLINE_URL)
email_body = email_body.replace('{{CORP_FORMS_URL}}', CORP_FORMS_URL)
email_body = email_body.replace('{{SOCIETIES_URL}}', SOCIETIES_URL)
email_template = Path(f'{template_path}/emails/{file_name}.md').read_text()

email_body = ReportResource._build_email_body(email_template, nr_model)

email = {
'recipients': recipients,
Expand All @@ -130,6 +131,23 @@ def email_report(self, nr_id):
except Exception as err:
return handle_exception(err, 'Error retrieving the report.', 500)

@staticmethod
def _build_email_body(template: str, nr_model):
var_map = {
'{{NAMES_INFORMATION_URL}}': current_app.config.get('NAMES_INFORMATION_URL'),
'{{NAME_REQUEST_URL}}': current_app.config.get('NAME_REQUEST_URL'),
'{{NAMEREQUEST_NUMBER}}': nr_model.nrNum,
'{{BUSINESS_URL}}': current_app.config.get('BUSINESS_URL'),
'{{DECIDE_BUSINESS_URL}}': current_app.config.get('DECIDE_BUSINESS_URL'),
'{{CORP_ONLINE_URL}}': current_app.config.get('COLIN_URL'),
'{{CORP_FORMS_URL}}': current_app.config.get('CORP_FORMS_URL'),
'{{SOCIETIES_URL}}': current_app.config.get('SOCIETIES_URL'),
'{{EXPIRATION_DATE}}': nr_model.expirationDate.strftime(DATE_FORMAT)
}
for template_string, val in var_map.items():
template = template.replace(template_string, val)
return template

@cors.crossdomain(origin='*')
def get(self, nr_id):
try:
Expand Down
30 changes: 30 additions & 0 deletions api/report-templates/emails/consent-colin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Consent Letter Accepted

The consent letter for your name request has been received and we have **approved** your name request. Follow the steps below to complete your application using this name. If the name request expires before the business is registered, a new name request will be required.

---

# Your Next Steps

Follow these steps to complete your application using this name:

1. Visit [BC Corporate Online]({{CORP_ONLINE_URL}})
2. Complete and submit the form along with any required documentation and payment

---

# Your Name Request Details

**Name Request Number:**
{{NAMEREQUEST_NUMBER}}

**Name Request Expiry Date and Time:**
{{EXPIRATION_DATE}}

---

**Business Registry**
BC Registries and Online Services
Toll Free: 1-877-370-1033
Victoria Office: 250-370-1033
Email: [[email protected]]([email protected])
46 changes: 46 additions & 0 deletions api/report-templates/emails/consent-modernized.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Consent Letter Accepted

The consent letter for your name request has been received and we have **approved** your name request. Follow the steps below to complete your application using this name. If the name request expires before the business is registered, a new name request will be required.

---

# Your Next Steps

Follow these steps to complete your application using this name:
1. Visit [BC Registries and Online Services]({{DECIDE_BUSINESS_URL}})
2. Log in with your BC Registries Account
3. Look-up your Name Request
4. Complete and submit the form along with any required documentation and payment


If you don\'t have a BC Registries Account, [create one here]({{BUSINESS_URL}}).

If you were not signed into your BC Registries Account when this Name Request was created, you will need to affiliate the two together. Follow these steps to affiliate a Name Request with your BC Registries Account.

1. Log in at [BC Registries and Online Services]({{DECIDE_BUSINESS_URL}})
2. Log in with your BC Registries Account
3. Navigate to My Business Registry
4. Select Name Request radio button
5. Enter the NR number in the field provided and select the match found
6. Enter the phone number or email address used to create the Name Request and press Manage This Name Request
7. The Name Request is successfully affiliated with your BC Registries Account if you see the Name Request in My List
8. Follow the action button beside the name to start the application

---

# Your Name Request Details

**Name Request Number:**
{{NAMEREQUEST_NUMBER}}

**Name Request Expiry Date and Time:**
{{EXPIRATION_DATE}}

---

**Business Registry**
BC Registries and Online Services
Toll Free: 1-877-370-1033
Victoria Office: 250-370-1033
Email: [[email protected]]([email protected])

31 changes: 31 additions & 0 deletions api/report-templates/emails/consent-so.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Consent Letter Accepted

The consent letter for your name request has been received and we have **approved** your name request. Follow the steps below to complete your application using this name. If the name request expires before the business is registered, a new name request will be required.

---

# Your Next Steps

Follow these steps to complete your application using this name:

1. Visit [Societies Online]({{SOCIETIES_URL}})
2. Log in with your BCeID
3. Complete your application with the approved Name Request Number

---

# Your Name Request Details

**Name Request Number:**
{{NAMEREQUEST_NUMBER}}

**Name Request Expiry Date and Time:**
{{EXPIRATION_DATE}}

---

**Business Registry**
BC Registries and Online Services
Toll Free: 1-877-370-1033
Victoria Office: 250-370-1033
Email: [[email protected]]([email protected])
23 changes: 19 additions & 4 deletions api/report-templates/emails/consent.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
# Consent Letter Acceptance Confirmation
# Consent Letter Accepted

Thank you for using Name Requests Online. The consent letter for your Name Request **{{NAMEREQUEST_NUMBER}}** has been received. You will receive another email notification with the result of the review. Please note: Your name request will expire on **{{EXPIRATION_DATE}}**.
The consent letter for your name request has been received and we have **approved** your name request. Follow the steps below to complete your application using this name. If the name request expires before the business is registered, a new name request will be required.

---

PLEASE DO NOT REPLY TO THIS EMAIL. It was sent from an unmonitored email address and the Corporate Registry is unable to respond to any replies.
# Your Next Steps

Follow these steps to complete your application using this name:

1. Visit [Forms, fees and information packages page]({{CORP_FORMS_URL}}) and download the appropriate form
2. Complete and submit the form along with any additional required documentation and payment

---

# Your Name Request Details

**Name Request Number:**
{{NAMEREQUEST_NUMBER}}

**Name Request Expiry Date and Time:**
{{EXPIRATION_DATE}}

---

**Business Registry**
BC Registries and Online Services
Toll Free: 1-877-370-1033
Victoria Office: 250-370-1033
Email: [[email protected]]([email protected])
Email: [[email protected]]([email protected])

0 comments on commit 2901824

Please sign in to comment.