Notification endpoints and url expositions

Also some changes to the footprint of the notification handler classes
This commit is contained in:
Matthew Jones
2016-02-04 11:30:40 -05:00
parent 96b0fb168f
commit 172207cd4b
7 changed files with 51 additions and 4 deletions

View File

@@ -4,6 +4,9 @@
import logging
from django.db import models
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from awx.main.models.base import * # noqa
from awx.main.notifications.email_backend import CustomEmailBackend
from awx.main.notifications.slack_backend import SlackBackend
@@ -14,6 +17,8 @@ from jsonfield import JSONField
logger = logging.getLogger('awx.main.models.notifications')
__all__ = ['NotificationTemplate']
class NotificationTemplate(CommonModel):
NOTIFICATION_TYPES = [('email', _('Email'), CustomEmailBackend),
@@ -32,6 +37,9 @@ class NotificationTemplate(CommonModel):
notification_configuration = JSONField(blank=False)
def get_absolute_url(self):
return reverse('api:notification_template_detail', args=(self.pk,))
@property
def notification_class(self):
return CLASS_FOR_NOTIFICATION_TYPE[self.notification_type]