mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
show default messages in options
This commit is contained in:
@@ -114,6 +114,17 @@ class Metadata(metadata.SimpleMetadata):
|
|||||||
for (notification_type_name, notification_tr_name, notification_type_class) in NotificationTemplate.NOTIFICATION_TYPES:
|
for (notification_type_name, notification_tr_name, notification_type_class) in NotificationTemplate.NOTIFICATION_TYPES:
|
||||||
field_info[notification_type_name] = notification_type_class.init_parameters
|
field_info[notification_type_name] = notification_type_class.init_parameters
|
||||||
|
|
||||||
|
# Special handling of notification messages where the required properties
|
||||||
|
# are conditional on the type selected.
|
||||||
|
try:
|
||||||
|
view_model = field.context['view'].model
|
||||||
|
except (AttributeError, KeyError):
|
||||||
|
view_model = None
|
||||||
|
if view_model == NotificationTemplate and field.field_name == 'messages':
|
||||||
|
for (notification_type_name, notification_tr_name, notification_type_class) in NotificationTemplate.NOTIFICATION_TYPES:
|
||||||
|
field_info[notification_type_name] = notification_type_class.default_messages
|
||||||
|
|
||||||
|
|
||||||
# Update type of fields returned...
|
# Update type of fields returned...
|
||||||
if field.field_name == 'type':
|
if field.field_name == 'type':
|
||||||
field_info['type'] = 'choice'
|
field_info['type'] = 'choice'
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ class CustomEmailBackend(EmailBackend):
|
|||||||
"sender": {"label": "Sender Email", "type": "string"},
|
"sender": {"label": "Sender Email", "type": "string"},
|
||||||
"recipients": {"label": "Recipient List", "type": "list"},
|
"recipients": {"label": "Recipient List", "type": "list"},
|
||||||
"timeout": {"label": "Timeout", "type": "int", "default": 30}}
|
"timeout": {"label": "Timeout", "type": "int", "default": 30}}
|
||||||
|
|
||||||
|
DEFAULT_SUBJECT = "{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}: {{ url }}"
|
||||||
|
DEFAULT_BODY = smart_text(_("{{ job_friendly_name }} #{{ job.id }} had status {{ job.status }}, view details at {{ url }}\n\n{{ job_summary_dict }}"))
|
||||||
|
default_messages = {"started": {"message": DEFAULT_SUBJECT, "body": DEFAULT_BODY},
|
||||||
|
"success": {"message": DEFAULT_SUBJECT, "body": DEFAULT_BODY},
|
||||||
|
"error": {"message": DEFAULT_SUBJECT, "body": DEFAULT_BODY}}
|
||||||
recipient_parameter = "recipients"
|
recipient_parameter = "recipients"
|
||||||
sender_parameter = "sender"
|
sender_parameter = "sender"
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ class GrafanaBackend(AWXBaseEmailBackend):
|
|||||||
recipient_parameter = "grafana_url"
|
recipient_parameter = "grafana_url"
|
||||||
sender_parameter = None
|
sender_parameter = None
|
||||||
|
|
||||||
|
DEFAULT_SUBJECT = "{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}: {{ url }}"
|
||||||
|
default_messages = {"started": {"message": DEFAULT_SUBJECT},
|
||||||
|
"success": {"message": DEFAULT_SUBJECT},
|
||||||
|
"error": {"message": DEFAULT_SUBJECT}}
|
||||||
|
|
||||||
def __init__(self, grafana_key,dashboardId=None, panelId=None, annotation_tags=None, grafana_no_verify_ssl=False, isRegion=True,
|
def __init__(self, grafana_key,dashboardId=None, panelId=None, annotation_tags=None, grafana_no_verify_ssl=False, isRegion=True,
|
||||||
fail_silently=False, **kwargs):
|
fail_silently=False, **kwargs):
|
||||||
super(GrafanaBackend, self).__init__(fail_silently=fail_silently)
|
super(GrafanaBackend, self).__init__(fail_silently=fail_silently)
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ class HipChatBackend(AWXBaseEmailBackend):
|
|||||||
recipient_parameter = "rooms"
|
recipient_parameter = "rooms"
|
||||||
sender_parameter = "message_from"
|
sender_parameter = "message_from"
|
||||||
|
|
||||||
|
DEFAULT_SUBJECT = "{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}: {{ url }}"
|
||||||
|
default_messages = {"started": {"message": DEFAULT_SUBJECT},
|
||||||
|
"success": {"message": DEFAULT_SUBJECT},
|
||||||
|
"error": {"message": DEFAULT_SUBJECT}}
|
||||||
|
|
||||||
def __init__(self, token, color, api_url, notify, fail_silently=False, **kwargs):
|
def __init__(self, token, color, api_url, notify, fail_silently=False, **kwargs):
|
||||||
super(HipChatBackend, self).__init__(fail_silently=fail_silently)
|
super(HipChatBackend, self).__init__(fail_silently=fail_silently)
|
||||||
self.token = token
|
self.token = token
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ class IrcBackend(AWXBaseEmailBackend):
|
|||||||
recipient_parameter = "targets"
|
recipient_parameter = "targets"
|
||||||
sender_parameter = None
|
sender_parameter = None
|
||||||
|
|
||||||
|
DEFAULT_SUBJECT = "{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}: {{ url }}"
|
||||||
|
default_messages = {"started": {"message": DEFAULT_SUBJECT},
|
||||||
|
"success": {"message": DEFAULT_SUBJECT},
|
||||||
|
"error": {"message": DEFAULT_SUBJECT}}
|
||||||
|
|
||||||
def __init__(self, server, port, nickname, password, use_ssl, fail_silently=False, **kwargs):
|
def __init__(self, server, port, nickname, password, use_ssl, fail_silently=False, **kwargs):
|
||||||
super(IrcBackend, self).__init__(fail_silently=fail_silently)
|
super(IrcBackend, self).__init__(fail_silently=fail_silently)
|
||||||
self.server = server
|
self.server = server
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ class MattermostBackend(AWXBaseEmailBackend):
|
|||||||
recipient_parameter = "mattermost_url"
|
recipient_parameter = "mattermost_url"
|
||||||
sender_parameter = None
|
sender_parameter = None
|
||||||
|
|
||||||
|
DEFAULT_SUBJECT = "{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}: {{ url }}"
|
||||||
|
default_messages = {"started": {"message": DEFAULT_SUBJECT},
|
||||||
|
"success": {"message": DEFAULT_SUBJECT},
|
||||||
|
"error": {"message": DEFAULT_SUBJECT}}
|
||||||
|
|
||||||
def __init__(self, mattermost_no_verify_ssl=False, mattermost_channel=None, mattermost_username=None,
|
def __init__(self, mattermost_no_verify_ssl=False, mattermost_channel=None, mattermost_username=None,
|
||||||
mattermost_icon_url=None, fail_silently=False, **kwargs):
|
mattermost_icon_url=None, fail_silently=False, **kwargs):
|
||||||
super(MattermostBackend, self).__init__(fail_silently=fail_silently)
|
super(MattermostBackend, self).__init__(fail_silently=fail_silently)
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ class PagerDutyBackend(AWXBaseEmailBackend):
|
|||||||
recipient_parameter = "service_key"
|
recipient_parameter = "service_key"
|
||||||
sender_parameter = "client_name"
|
sender_parameter = "client_name"
|
||||||
|
|
||||||
|
DEFAULT_SUBJECT = "{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}: {{ url }}"
|
||||||
|
DEFAULT_BODY = "{{ job_summary_dict }}"
|
||||||
|
default_messages = {"started": { "message": DEFAULT_SUBJECT, "body": DEFAULT_BODY},
|
||||||
|
"success": { "message": DEFAULT_SUBJECT, "body": DEFAULT_BODY},
|
||||||
|
"error": { "message": DEFAULT_SUBJECT, "body": DEFAULT_BODY}}
|
||||||
|
|
||||||
def __init__(self, subdomain, token, fail_silently=False, **kwargs):
|
def __init__(self, subdomain, token, fail_silently=False, **kwargs):
|
||||||
super(PagerDutyBackend, self).__init__(fail_silently=fail_silently)
|
super(PagerDutyBackend, self).__init__(fail_silently=fail_silently)
|
||||||
self.subdomain = subdomain
|
self.subdomain = subdomain
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ class RocketChatBackend(AWXBaseEmailBackend):
|
|||||||
recipient_parameter = "rocketchat_url"
|
recipient_parameter = "rocketchat_url"
|
||||||
sender_parameter = None
|
sender_parameter = None
|
||||||
|
|
||||||
|
DEFAULT_SUBJECT = "{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}: {{ url }}"
|
||||||
|
default_messages = {"started": {"message": DEFAULT_SUBJECT},
|
||||||
|
"success": {"message": DEFAULT_SUBJECT},
|
||||||
|
"error": {"message": DEFAULT_SUBJECT}}
|
||||||
|
|
||||||
def __init__(self, rocketchat_no_verify_ssl=False, rocketchat_username=None, rocketchat_icon_url=None, fail_silently=False, **kwargs):
|
def __init__(self, rocketchat_no_verify_ssl=False, rocketchat_username=None, rocketchat_icon_url=None, fail_silently=False, **kwargs):
|
||||||
super(RocketChatBackend, self).__init__(fail_silently=fail_silently)
|
super(RocketChatBackend, self).__init__(fail_silently=fail_silently)
|
||||||
self.rocketchat_no_verify_ssl = rocketchat_no_verify_ssl
|
self.rocketchat_no_verify_ssl = rocketchat_no_verify_ssl
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ class SlackBackend(AWXBaseEmailBackend):
|
|||||||
recipient_parameter = "channels"
|
recipient_parameter = "channels"
|
||||||
sender_parameter = None
|
sender_parameter = None
|
||||||
|
|
||||||
|
DEFAULT_SUBJECT = "{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}: {{ url }}"
|
||||||
|
default_messages = {"started": {"message": DEFAULT_SUBJECT},
|
||||||
|
"success": {"message": DEFAULT_SUBJECT},
|
||||||
|
"error": {"message": DEFAULT_SUBJECT}}
|
||||||
|
|
||||||
def __init__(self, token, hex_color="", fail_silently=False, **kwargs):
|
def __init__(self, token, hex_color="", fail_silently=False, **kwargs):
|
||||||
super(SlackBackend, self).__init__(fail_silently=fail_silently)
|
super(SlackBackend, self).__init__(fail_silently=fail_silently)
|
||||||
self.token = token
|
self.token = token
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ class TwilioBackend(AWXBaseEmailBackend):
|
|||||||
recipient_parameter = "to_numbers"
|
recipient_parameter = "to_numbers"
|
||||||
sender_parameter = "from_number"
|
sender_parameter = "from_number"
|
||||||
|
|
||||||
|
DEFAULT_SUBJECT = "{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}: {{ url }}"
|
||||||
|
default_messages = {"started": {"message": DEFAULT_SUBJECT},
|
||||||
|
"success": {"message": DEFAULT_SUBJECT},
|
||||||
|
"error": {"message": DEFAULT_SUBJECT}}
|
||||||
|
|
||||||
def __init__(self, account_sid, account_token, fail_silently=False, **kwargs):
|
def __init__(self, account_sid, account_token, fail_silently=False, **kwargs):
|
||||||
super(TwilioBackend, self).__init__(fail_silently=fail_silently)
|
super(TwilioBackend, self).__init__(fail_silently=fail_silently)
|
||||||
self.account_sid = account_sid
|
self.account_sid = account_sid
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ class WebhookBackend(AWXBaseEmailBackend):
|
|||||||
recipient_parameter = "url"
|
recipient_parameter = "url"
|
||||||
sender_parameter = None
|
sender_parameter = None
|
||||||
|
|
||||||
|
DEFAULT_BODY = "{{ job_summary_dict }}"
|
||||||
|
default_messages = {"started": {"body": DEFAULT_BODY},
|
||||||
|
"success": {"body": DEFAULT_BODY},
|
||||||
|
"error": {"body": DEFAULT_BODY}}
|
||||||
|
|
||||||
def __init__(self, http_method, headers, disable_ssl_verification=False, fail_silently=False, username=None, password=None, **kwargs):
|
def __init__(self, http_method, headers, disable_ssl_verification=False, fail_silently=False, username=None, password=None, **kwargs):
|
||||||
self.http_method = http_method
|
self.http_method = http_method
|
||||||
self.disable_ssl_verification = disable_ssl_verification
|
self.disable_ssl_verification = disable_ssl_verification
|
||||||
|
|||||||
Reference in New Issue
Block a user