Skip to content

Commit

Permalink
feat: readability improvment to notifications
Browse files Browse the repository at this point in the history
We've already improved the notification subject elements to be more
easily distinguishable and searchable in email.  We should do the same
for the pre_initial messages we send out when an environment is defined
but it's not yet scheduled to go out.

We'll revamp all notification methods here so they identify at least the
cloud environment and ticket number assopciated with them.

Change-Id: Ie979489e7bb02da2c9c3349c43644995f8551c04
  • Loading branch information
sadsfae committed Apr 2, 2020
1 parent 31fee10 commit 550790f
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions quads/tools/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,35 @@ def create_message(
postman.send_email()


def create_future_initial_message(real_owner, cloud_info, cc):
def create_future_initial_message(cloud_obj, cloud_info):
template_file = "future_initial_message"
cloud = cloud_obj.name
ticket = cloud_obj.ticket
cc_users = conf["report_cc"].split(",")
for user in cc:
for user in cloud_obj.ccuser:
cc_users.append("%s@%s" % (user, conf["domain"]))
with open(os.path.join(TEMPLATES_PATH, template_file)) as _file:
template = Template(_file.read())
content = template.render(
cloud_info=cloud_info,
wp_wiki=conf["wp_wiki"],
)
postman = Postman("New QUADS Assignment Defined for the Future", real_owner, cc_users, content)
postman = Postman("New QUADS Assignment Defined for the Future: %s - %s" % (
cloud,
ticket
), cloud_obj.owner, cc_users, content)
postman.send_email()


def create_future_message(
real_owner,
cloud_obj,
future_days,
cloud,
cloud_info,
cc,
host_list_expire,
):
cc_users = conf["report_cc"].split(",")
for user in cc:
ticket = cloud_obj.ticket
for user in cloud_obj.ccuser:
cc_users.append("%s@%s" % (user, conf["domain"]))
template_file = "future_message"
with open(os.path.join(TEMPLATES_PATH, template_file)) as _file:
Expand All @@ -132,10 +136,13 @@ def create_future_message(
days_to_report=future_days,
cloud_info=cloud_info,
wp_wiki=conf["wp_wiki"],
cloud=cloud,
cloud=cloud_obj.name,
hosts=host_list_expire,
)
postman = Postman("QUADS upcoming assignment notification", real_owner, cc_users, content)
postman = Postman("QUADS upcoming assignment notification - %s - %s" % (
cloud_obj.name,
ticket
), cloud_obj.owner, cc_users, content)
postman.send_email()


Expand Down Expand Up @@ -210,9 +217,8 @@ def main():
if not notification_obj.pre_initial and conf["email_notify"]:
logger.info('=============== Future Initial Message')
create_future_initial_message(
cloud.owner,
cloud,
cloud_info,
cloud.ccuser,
)
notification_obj.update(pre_initial=True)

Expand All @@ -228,11 +234,9 @@ def main():
if diff:
logger.info('=============== Additional Message')
create_future_message(
cloud.owner,
cloud,
day,
cloud.name,
cloud_info,
cloud.ccuser,
host_list,
)
notification_obj.update(pre=True)
Expand Down

0 comments on commit 550790f

Please sign in to comment.