Skip to content

Commit

Permalink
Update emails.py
Browse files Browse the repository at this point in the history
  • Loading branch information
michplunkett committed Aug 3, 2023
1 parent 034504e commit 2eb7464
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions OpenOversight/app/models/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from flask import current_app, render_template

from OpenOversight.app.utils.constants import KEY_OO_MAIL_SUBJECT_PREFIX


class Email:
"""Base class for all emails."""
Expand All @@ -22,7 +24,9 @@ def create_message(self):

class AdministratorApprovalEmail(Email):
def __init__(self, receiver: str, user, admin):
subject = f"{current_app.config['OO_MAIL_SUBJECT_PREFIX']} New User Registered"
subject = (
f"{current_app.config[KEY_OO_MAIL_SUBJECT_PREFIX]} New User Registered"
)
body = render_template(
"auth/email/new_registration.html", user=user, admin=admin
)
Expand All @@ -32,7 +36,7 @@ def __init__(self, receiver: str, user, admin):
class ChangeEmailAddressEmail(Email):
def __init__(self, receiver: str, user, token: str):
subject = (
f"{current_app.config['OO_MAIL_SUBJECT_PREFIX']} Confirm Your Email "
f"{current_app.config[KEY_OO_MAIL_SUBJECT_PREFIX]} Confirm Your Email "
f"Address"
)
body = render_template("auth/email/change_email.html", user=user, token=token)
Expand All @@ -41,9 +45,7 @@ def __init__(self, receiver: str, user, token: str):

class ChangePasswordEmail(Email):
def __init__(self, receiver: str, user):
subject = (
f"{current_app.config['OO_MAIL_SUBJECT_PREFIX']} Your Password Has Changed"
)
subject = f"{current_app.config[KEY_OO_MAIL_SUBJECT_PREFIX]} Your Password Has Changed"
body = render_template(
"auth/email/change_password.html",
user=user,
Expand All @@ -54,14 +56,16 @@ def __init__(self, receiver: str, user):

class ConfirmAccountEmail(Email):
def __init__(self, receiver: str, user, token: str):
subject = f"{current_app.config['OO_MAIL_SUBJECT_PREFIX']} Confirm Your Account"
subject = (
f"{current_app.config[KEY_OO_MAIL_SUBJECT_PREFIX]} Confirm Your Account"
)
body = render_template("auth/email/confirm.html", user=user, token=token)
super().__init__(body, subject, receiver)


class ConfirmedUserEmail(Email):
def __init__(self, receiver: str, user, admin):
subject = f"{current_app.config['OO_MAIL_SUBJECT_PREFIX']} New User Confirmed"
subject = f"{current_app.config[KEY_OO_MAIL_SUBJECT_PREFIX]} New User Confirmed"
body = render_template(
"auth/email/new_confirmation.html", user=user, admin=admin
)
Expand All @@ -70,6 +74,8 @@ def __init__(self, receiver: str, user, admin):

class ResetPasswordEmail(Email):
def __init__(self, receiver: str, user, token: str):
subject = f"{current_app.config['OO_MAIL_SUBJECT_PREFIX']} Reset Your Password"
subject = (
f"{current_app.config[KEY_OO_MAIL_SUBJECT_PREFIX]} Reset Your Password"
)
body = render_template("auth/email/reset_password.html", user=user, token=token)
super().__init__(body, subject, receiver)

0 comments on commit 2eb7464

Please sign in to comment.