Notification serializers, views, and tasks

* Implement concrete Notification model for notification runs
* Implement NotificationTemplate and Notification serializers and views
* Implement ancillary views
* Implement NotificationTemplate trigger m2m fields on all job templates
  via a fields mixin
* Link NotificationTemplates with an org
* Link notifications with the activity stream
* Implement Notification celery tasks
* Extend Backend field parameters to identify sender and receiver as
  parameters needed by the message and not the backend itself
* Updates to backends to better fit the django email backend model as it
  relates to Messages
* Implement success job chain task + notifications
* Implement notifications in error job chain task
This commit is contained in:
Matthew Jones
2016-02-09 23:12:55 -05:00
parent 319deffc18
commit 8db2f60405
18 changed files with 502 additions and 20 deletions
+7 -3
View File
@@ -10,7 +10,10 @@ logger = logging.getLogger('awx.main.notifications.slack_backend')
class SlackBackend(BaseEmailBackend):
init_parameters = {"token": {"label": "Token", "type": "password"}}
init_parameters = {"token": {"label": "Token", "type": "password"},
"channels": {"label": "Destination Channels", "type": "list"}}
recipient_parameter = "channels"
sender_parameter = None
def __init__(self, token, fail_silently=False, **kwargs):
super(SlackBackend, self).__init__(fail_silently=fail_silently)
@@ -37,8 +40,9 @@ class SlackBackend(BaseEmailBackend):
sent_messages = 0
for m in messages:
try:
self.connection.rtm_send_message(m.to, m.body)
sent_messages += 1
for r in m.recipients():
self.connection.rtm_send_message(r, m.body)
sent_messages += 1
except Exception as e:
if not self.fail_silently:
raise