Enforce org dependency of notification template.

This commit is contained in:
Aaron Tan
2017-04-27 14:06:39 -04:00
parent 25fae0eafd
commit d0d201863b
2 changed files with 19 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ logger = logging.getLogger('awx.main.models.notifications')
__all__ = ['NotificationTemplate', 'Notification']
class NotificationTemplate(CommonModel):
class NotificationTemplate(CommonModelNameNotUnique):
NOTIFICATION_TYPES = [('email', _('Email'), CustomEmailBackend),
('slack', _('Slack'), SlackBackend),
@@ -41,12 +41,13 @@ class NotificationTemplate(CommonModel):
class Meta:
app_label = 'main'
unique_together = ('organization', 'name')
organization = models.ForeignKey(
'Organization',
blank=False,
null=True,
on_delete=models.SET_NULL,
on_delete=models.CASCADE,
related_name='notification_templates',
)