Skip to content

Commit

Permalink
aded email utility to send request to sme
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian committed Jun 27, 2023
1 parent 061b76e commit 041ec07
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/core/user_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ def send_notifications_of_new_applications(
self.ses, ocp_email_group, lender_name
)

def send_request_to_sme(
self,
test,
):
email_utility.send_mail_request_to_sme(self.ses, test)


cognito = boto3.client(
"cognito-idp",
Expand Down
3 changes: 3 additions & 0 deletions app/routers/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ async def email_sme(
application_id = application.id
email_message = payload.message
lender_id = application.lender_id

# client.send_request_to_sme("test")

# create a new row in the table message saving th email body and the application id
new_message = core.Message(
application_id=application_id,
Expand Down
19 changes: 19 additions & 0 deletions app/utils/email_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,22 @@ def send_notification_new_app_to_ocp(ses, ocp_email_group, lender_name):
Template=email_templates.NEW_APPLICATION_SUBMISSION_OCP_TEMPLATE_NAME,
TemplateData=json.dumps(data),
)


def send_mail_request_to_sme(ses, test):
# todo refactor required when this function receives the user language
images_base_url = get_images_base_url()

data = {
**generate_common_data(),
"F1": "aaa",
# "LOGIN_URL": app_settings.frontend_url + "/login",
"LOGIN_IMAGE_LINK": images_base_url + "/logincompleteimage.png",
}

ses.send_templated_email(
Source=app_settings.email_sender_address,
Destination={"ToAddresses": ["test"]},
Template=email_templates.NEW_APPLICATION_SUBMISSION_OCP_TEMPLATE_NAME,
TemplateData=json.dumps(data),
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@
def upgrade() -> None:
op.add_column("message", sa.Column("lender_id", sa.Integer(), nullable=True))
op.create_foreign_key(None, "message", "lender", ["lender_id"], ["id"])
# Add new ENUM value
with op.get_context().autocommit_block():
op.execute(
"""
ALTER TYPE message_type ADD VALUE IF NOT EXISTS 'AWAITING_INFORMATION'
"""
)
# ### end Alembic commands ###


def downgrade() -> None:
op.drop_constraint(None, "message", type_="foreignkey")
op.drop_column("message", "lender_id")
# Downgrading ENUM is not directly possible in PostgreSQL
# ### end Alembic commands ###

0 comments on commit 041ec07

Please sign in to comment.