mirror of
https://github.com/ansible/awx.git
synced 2026-02-15 02:00:01 -03:30
* Job object can now control the output and generate K:V output for notification types that can support it * Notifications store the body as json/dict now to encode more information * Notification Type can further compose the message based on what is sensible for the notification type * This will also allow customizing the message template in the future * All notification types use sane defaults for the level of detail now
28 lines
1.3 KiB
Python
28 lines
1.3 KiB
Python
# Copyright (c) 2016 Ansible, Inc.
|
|
# All Rights Reserved.
|
|
|
|
import logging
|
|
|
|
from django.core.mail.backends.smtp import EmailBackend
|
|
|
|
class CustomEmailBackend(EmailBackend):
|
|
|
|
init_parameters = {"host": {"label": "Host", "type": "string"},
|
|
"port": {"label": "Port", "type": "int"},
|
|
"username": {"label": "Username", "type": "string"},
|
|
"password": {"label": "Password", "type": "password"},
|
|
"use_tls": {"label": "Use TLS", "type": "bool"},
|
|
"use_ssl": {"label": "Use SSL", "type": "bool"},
|
|
"sender": {"label": "Sender Email", "type": "string"},
|
|
"recipients": {"label": "Recipient List", "type": "list"}}
|
|
recipient_parameter = "recipients"
|
|
sender_parameter = "sender"
|
|
|
|
def format_body(self, body):
|
|
body_actual = "{} #{} had status {} on Ansible Tower, view details at {}\n\n".format(body['friendly_name'],
|
|
body['id'],
|
|
body['status'],
|
|
body['url'])
|
|
body_actual += pprint.pformat(body, indent=4)
|
|
return body_actual
|