-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic support for email templates
- Loading branch information
Showing
17 changed files
with
293 additions
and
7 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
project_rossum_deploy/commands/download/email_templates.py
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,57 @@ | ||
import asyncio | ||
from anyio import Path | ||
from rossum_api import ElisAPIClient | ||
from rossum_api.api_client import Resource | ||
|
||
from project_rossum_deploy.commands.download.helpers import ( | ||
should_write_object, | ||
) | ||
|
||
from project_rossum_deploy.common.read_write import write_json | ||
from project_rossum_deploy.utils.functions import ( | ||
templatize_name_id, | ||
) | ||
|
||
|
||
async def download_email_templates_for_queue( | ||
client: ElisAPIClient, | ||
queue_id: int, | ||
parent_dir: Path, | ||
changed_files: list = [], | ||
download_all: bool = False, | ||
): | ||
# email_templates = [] | ||
|
||
paginated_email_templates = [ | ||
email_template | ||
async for email_template in client.list_all_email_templates(queue=queue_id) | ||
] | ||
|
||
# Refetch in case the paginated fields don't include everything | ||
# Use raw dicts and not dataclasses in case of fields not defined in the Rossum API lib | ||
full_email_templates = await asyncio.gather( | ||
*[ | ||
client._http_client.fetch_one(Resource.EmailTemplate, email_template.id) | ||
for email_template in paginated_email_templates | ||
] | ||
) | ||
|
||
for email_template in full_email_templates: | ||
email_template_path = ( | ||
parent_dir | ||
/ "email_templates" | ||
/ f'{templatize_name_id(email_template["name"], email_template["id"])}.json' | ||
) | ||
if download_all or await should_write_object( | ||
email_template_path, email_template, changed_files | ||
): | ||
await write_json( | ||
email_template_path, | ||
email_template, | ||
Resource.EmailTemplate, | ||
log_message=f"Pulled {email_template_path}", | ||
) | ||
|
||
# email_templates.append((destination_local, email_template)) | ||
|
||
# return email_templates |
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
22 changes: 22 additions & 0 deletions
22
...eues/queue1_[1162844]/email_templates/Annotation status change - confirmed_[5851992].json
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,22 @@ | ||
{ | ||
"id": 5851992, | ||
"url": "https://shared-eu2.rossum.app/api/v1/email_templates/5851992", | ||
"name": "Annotation status change - confirmed", | ||
"queue": "https://shared-eu2.rossum.app/api/v1/queues/1162844", | ||
"organization": "https://shared-eu2.rossum.app/api/v1/organizations/263865", | ||
"subject": "Verified documents: {{ parent_email_subject }}", | ||
"message": "<p>Dear sender,<br><br>Your documents have been checked by annotator.<br><br>{{ document_list }}<br><br>Regards</p>\n", | ||
"type": "custom", | ||
"enabled": false, | ||
"automate": false, | ||
"triggers": [ | ||
"https://shared-eu2.rossum.app/api/v1/triggers/4687095" | ||
], | ||
"to": [ | ||
{ | ||
"email": "{{sender_email}}" | ||
} | ||
], | ||
"cc": [], | ||
"bcc": [] | ||
} |
22 changes: 22 additions & 0 deletions
22
...ueues/queue1_[1162844]/email_templates/Annotation status change - exported_[5851994].json
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,22 @@ | ||
{ | ||
"id": 5851994, | ||
"url": "https://shared-eu2.rossum.app/api/v1/email_templates/5851994", | ||
"name": "Annotation status change - exported", | ||
"queue": "https://shared-eu2.rossum.app/api/v1/queues/1162844", | ||
"organization": "https://shared-eu2.rossum.app/api/v1/organizations/263865", | ||
"subject": "Documents exported: {{ parent_email_subject }}", | ||
"message": "<p>Dear sender,<br><br>Your documents have been successfully exported.<br><br>{{ document_list }}<br><br>Regards</p>\n", | ||
"type": "custom", | ||
"enabled": false, | ||
"automate": false, | ||
"triggers": [ | ||
"https://shared-eu2.rossum.app/api/v1/triggers/4687097" | ||
], | ||
"to": [ | ||
{ | ||
"email": "{{sender_email}}" | ||
} | ||
], | ||
"cc": [], | ||
"bcc": [] | ||
} |
22 changes: 22 additions & 0 deletions
22
...ueues/queue1_[1162844]/email_templates/Annotation status change - received_[5851990].json
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,22 @@ | ||
{ | ||
"id": 5851990, | ||
"url": "https://shared-eu2.rossum.app/api/v1/email_templates/5851990", | ||
"name": "Annotation status change - received", | ||
"queue": "https://shared-eu2.rossum.app/api/v1/queues/1162844", | ||
"organization": "https://shared-eu2.rossum.app/api/v1/organizations/263865", | ||
"subject": "Documents received: {{ parent_email_subject }}", | ||
"message": "<p>Dear sender,<br><br>Your documents have been successfully received.<br><br>{{ document_list }}<br><br>Regards</p>\n", | ||
"type": "custom", | ||
"enabled": false, | ||
"automate": false, | ||
"triggers": [ | ||
"https://shared-eu2.rossum.app/api/v1/triggers/4687093" | ||
], | ||
"to": [ | ||
{ | ||
"email": "{{sender_email}}" | ||
} | ||
], | ||
"cc": [], | ||
"bcc": [] | ||
} |
20 changes: 20 additions & 0 deletions
20
...526238]/queues/queue1_[1162844]/email_templates/Default rejection template_[5851989].json
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,20 @@ | ||
{ | ||
"id": 5851989, | ||
"url": "https://shared-eu2.rossum.app/api/v1/email_templates/5851989", | ||
"name": "Default rejection template", | ||
"queue": "https://shared-eu2.rossum.app/api/v1/queues/1162844", | ||
"organization": "https://shared-eu2.rossum.app/api/v1/organizations/263865", | ||
"subject": "Rejected document {{parent_email_subject}}", | ||
"message": "<p>Dear sender,<br><br>The attached document has been rejected.<br><br><br>Best regards,<br>{{ user_name }}</p>\n", | ||
"type": "rejection_default", | ||
"enabled": true, | ||
"automate": true, | ||
"triggers": [], | ||
"to": [ | ||
{ | ||
"email": "{{sender_email}}" | ||
} | ||
], | ||
"cc": [], | ||
"bcc": [] | ||
} |
22 changes: 22 additions & 0 deletions
22
...ues/queue1_[1162844]/email_templates/Email with no processable attachments_[5851996].json
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,22 @@ | ||
{ | ||
"id": 5851996, | ||
"url": "https://shared-eu2.rossum.app/api/v1/email_templates/5851996", | ||
"name": "Email with no processable attachments", | ||
"queue": "https://shared-eu2.rossum.app/api/v1/queues/1162844", | ||
"organization": "https://shared-eu2.rossum.app/api/v1/organizations/263865", | ||
"subject": "No processable documents: {{ parent_email_subject }}", | ||
"message": "<p>Dear sender,<br><br>Unfortunately, we have not received any document in the email that we can process. Please send a corrected version if appropriate.<br><br>Regards</p>", | ||
"type": "email_with_no_processable_attachments", | ||
"enabled": false, | ||
"automate": false, | ||
"triggers": [ | ||
"https://shared-eu2.rossum.app/api/v1/triggers/4687099" | ||
], | ||
"to": [ | ||
{ | ||
"email": "{{sender_email}}" | ||
} | ||
], | ||
"cc": [], | ||
"bcc": [] | ||
} |
22 changes: 22 additions & 0 deletions
22
...eues/queue2_[1162843]/email_templates/Annotation status change - confirmed_[5851991].json
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,22 @@ | ||
{ | ||
"id": 5851991, | ||
"url": "https://shared-eu2.rossum.app/api/v1/email_templates/5851991", | ||
"name": "Annotation status change - confirmed", | ||
"queue": "https://shared-eu2.rossum.app/api/v1/queues/1162843", | ||
"organization": "https://shared-eu2.rossum.app/api/v1/organizations/263865", | ||
"subject": "Verified documents: {{ parent_email_subject }}", | ||
"message": "<p>Dear sender,<br><br>Your documents have been checked by annotator.<br><br>{{ document_list }}<br><br>Regards</p>\n", | ||
"type": "custom", | ||
"enabled": false, | ||
"automate": false, | ||
"triggers": [ | ||
"https://shared-eu2.rossum.app/api/v1/triggers/4687094" | ||
], | ||
"to": [ | ||
{ | ||
"email": "{{sender_email}}" | ||
} | ||
], | ||
"cc": [], | ||
"bcc": [] | ||
} |
22 changes: 22 additions & 0 deletions
22
...ueues/queue2_[1162843]/email_templates/Annotation status change - exported_[5851993].json
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,22 @@ | ||
{ | ||
"id": 5851993, | ||
"url": "https://shared-eu2.rossum.app/api/v1/email_templates/5851993", | ||
"name": "Annotation status change - exported", | ||
"queue": "https://shared-eu2.rossum.app/api/v1/queues/1162843", | ||
"organization": "https://shared-eu2.rossum.app/api/v1/organizations/263865", | ||
"subject": "Documents exported: {{ parent_email_subject }}", | ||
"message": "<p>Dear sender,<br><br>Your documents have been successfully exported.<br><br>{{ document_list }}<br><br>Regards</p>\n", | ||
"type": "custom", | ||
"enabled": false, | ||
"automate": false, | ||
"triggers": [ | ||
"https://shared-eu2.rossum.app/api/v1/triggers/4687096" | ||
], | ||
"to": [ | ||
{ | ||
"email": "{{sender_email}}" | ||
} | ||
], | ||
"cc": [], | ||
"bcc": [] | ||
} |
22 changes: 22 additions & 0 deletions
22
...ueues/queue2_[1162843]/email_templates/Annotation status change - received_[5851988].json
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,22 @@ | ||
{ | ||
"id": 5851988, | ||
"url": "https://shared-eu2.rossum.app/api/v1/email_templates/5851988", | ||
"name": "Annotation status change - received", | ||
"queue": "https://shared-eu2.rossum.app/api/v1/queues/1162843", | ||
"organization": "https://shared-eu2.rossum.app/api/v1/organizations/263865", | ||
"subject": "Documents received: {{ parent_email_subject }}", | ||
"message": "<p>Dear sender,<br><br>Your documents have been successfully received.<br><br>{{ document_list }}<br><br>Regards</p>\n", | ||
"type": "custom", | ||
"enabled": false, | ||
"automate": false, | ||
"triggers": [ | ||
"https://shared-eu2.rossum.app/api/v1/triggers/4687092" | ||
], | ||
"to": [ | ||
{ | ||
"email": "{{sender_email}}" | ||
} | ||
], | ||
"cc": [], | ||
"bcc": [] | ||
} |
20 changes: 20 additions & 0 deletions
20
...526237]/queues/queue2_[1162843]/email_templates/Default rejection template_[5851987].json
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,20 @@ | ||
{ | ||
"id": 5851987, | ||
"url": "https://shared-eu2.rossum.app/api/v1/email_templates/5851987", | ||
"name": "Default rejection template", | ||
"queue": "https://shared-eu2.rossum.app/api/v1/queues/1162843", | ||
"organization": "https://shared-eu2.rossum.app/api/v1/organizations/263865", | ||
"subject": "Rejected document {{parent_email_subject}}", | ||
"message": "<p>Dear sender,<br><br>The attached document has been rejected.<br><br><br>Best regards,<br>{{ user_name }}</p>\n", | ||
"type": "rejection_default", | ||
"enabled": true, | ||
"automate": true, | ||
"triggers": [], | ||
"to": [ | ||
{ | ||
"email": "{{sender_email}}" | ||
} | ||
], | ||
"cc": [], | ||
"bcc": [] | ||
} |
22 changes: 22 additions & 0 deletions
22
...ues/queue2_[1162843]/email_templates/Email with no processable attachments_[5851995].json
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,22 @@ | ||
{ | ||
"id": 5851995, | ||
"url": "https://shared-eu2.rossum.app/api/v1/email_templates/5851995", | ||
"name": "Email with no processable attachments", | ||
"queue": "https://shared-eu2.rossum.app/api/v1/queues/1162843", | ||
"organization": "https://shared-eu2.rossum.app/api/v1/organizations/263865", | ||
"subject": "No processable documents: {{ parent_email_subject }}", | ||
"message": "<p>Dear sender,<br><br>Unfortunately, we have not received any document in the email that we can process. Please send a corrected version if appropriate.<br><br>Regards</p>", | ||
"type": "email_with_no_processable_attachments", | ||
"enabled": false, | ||
"automate": false, | ||
"triggers": [ | ||
"https://shared-eu2.rossum.app/api/v1/triggers/4687098" | ||
], | ||
"to": [ | ||
{ | ||
"email": "{{sender_email}}" | ||
} | ||
], | ||
"cc": [], | ||
"bcc": [] | ||
} |