-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PIMS-2132: Fields included in the notification emails (#2727)
- Loading branch information
1 parent
63ebf37
commit a27b02a
Showing
13 changed files
with
76 additions
and
4 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
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
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
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
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
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
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
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
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
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
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
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
50 changes: 50 additions & 0 deletions
50
express-api/src/typeorm/Migrations/1728680019519-AddAdminAreaToERPNotifications.ts
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,50 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddAdminAreaToERPNotifications1728680019519 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
-- update the "New Disposal Project Submitted template" first because of different formatting and spacing | ||
-- add a new line for the Site Location using the admin area name | ||
UPDATE notification_template | ||
SET body = REGEXP_REPLACE( | ||
body, | ||
'Site Address: {{ property.Address1 }}' || chr(10) || '[[:space:]]+<br>', -- to find all instances of spaces before the <br> that follows after a new line | ||
'Site Address: {{ property.Address1 }}<br>' || chr(10) || chr(9) || chr(9) || chr(9) || chr(9) || chr(9) || 'Site Location: {{ property.AdministrativeArea.Name }}<br>', | ||
'g') -- 'g' to replace all instances within a template | ||
WHERE body LIKE '%Site Address: {{ property.Address1 }}' || chr(10) || '%<br>%' AND id = 1`); | ||
await queryRunner.query(` | ||
-- update the other 10 templates which have different spacing | ||
UPDATE notification_template | ||
SET body = REGEXP_REPLACE( | ||
body, | ||
'Site Address: {{ property.Address1 }}<br>', | ||
'Site Address: {{ property.Address1 }}<br>' || chr(10) || chr(9) || chr(9) || chr(9) || chr(9) || chr(9) || chr(9) || chr(9) || chr(9) || chr(9) || 'Site Location: {{ property.AdministrativeArea.Name }}<br>', | ||
'g') -- 'g' to replace all instances within a template | ||
WHERE body LIKE '%Site Address: {{ property.Address1 }}<br>%' AND id >= 5 and id <= 14`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
-- Remove administrative area line | ||
UPDATE notification_template | ||
SET body = REGEXP_REPLACE( | ||
body, | ||
'Site Address: {{ property.Address1 }}<br>[\\s\\t]*Site Location: {{ property.AdministrativeArea.Name }}<br>', | ||
'Site Address: {{ property.Address1 }}' || chr(10) || chr(9) || chr(9) || chr(9) || chr(9) || chr(9) || '<br>', | ||
'g') | ||
WHERE body LIKE '%Site Location: {{ property.AdministrativeArea.Name }}<br>%' | ||
AND id = 1`); | ||
|
||
await queryRunner.query(` | ||
-- Remove Site Location line and set it back the way it was | ||
UPDATE notification_template | ||
SET body = REGEXP_REPLACE( | ||
body, | ||
'Site Address: {{ property.Address1 }}<br>[\\s\\t]*Site Location: {{ property.AdministrativeArea.Name }}<br>', | ||
'Site Address: {{ property.Address1 }}<br>', | ||
'g') -- 'g' to replace all instances within a template | ||
WHERE body LIKE '%Site Location: {{ property.AdministrativeArea.Name }}<br>%' | ||
AND id >= 5 AND id <= 14 | ||
`); | ||
} | ||
} |