mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Enforce org dependency of notification template.
This commit is contained in:
@@ -98,4 +98,20 @@ class Migration(migrations.Migration):
|
|||||||
name='launch_type',
|
name='launch_type',
|
||||||
field=models.CharField(default=b'manual', max_length=20, editable=False, choices=[(b'manual', 'Manual'), (b'relaunch', 'Relaunch'), (b'callback', 'Callback'), (b'scheduled', 'Scheduled'), (b'dependency', 'Dependency'), (b'workflow', 'Workflow'), (b'sync', 'Sync'), (b'scm', 'SCM Update')]),
|
field=models.CharField(default=b'manual', max_length=20, editable=False, choices=[(b'manual', 'Manual'), (b'relaunch', 'Relaunch'), (b'callback', 'Callback'), (b'scheduled', 'Scheduled'), (b'dependency', 'Dependency'), (b'workflow', 'Workflow'), (b'sync', 'Sync'), (b'scm', 'SCM Update')]),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
# Named URL
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='notificationtemplate',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=512),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='notificationtemplate',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(related_name='notification_templates', to='main.Organization', null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name='notificationtemplate',
|
||||||
|
unique_together=set([('organization', 'name')]),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ logger = logging.getLogger('awx.main.models.notifications')
|
|||||||
__all__ = ['NotificationTemplate', 'Notification']
|
__all__ = ['NotificationTemplate', 'Notification']
|
||||||
|
|
||||||
|
|
||||||
class NotificationTemplate(CommonModel):
|
class NotificationTemplate(CommonModelNameNotUnique):
|
||||||
|
|
||||||
NOTIFICATION_TYPES = [('email', _('Email'), CustomEmailBackend),
|
NOTIFICATION_TYPES = [('email', _('Email'), CustomEmailBackend),
|
||||||
('slack', _('Slack'), SlackBackend),
|
('slack', _('Slack'), SlackBackend),
|
||||||
@@ -41,12 +41,13 @@ class NotificationTemplate(CommonModel):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
|
unique_together = ('organization', 'name')
|
||||||
|
|
||||||
organization = models.ForeignKey(
|
organization = models.ForeignKey(
|
||||||
'Organization',
|
'Organization',
|
||||||
blank=False,
|
blank=False,
|
||||||
null=True,
|
null=True,
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.CASCADE,
|
||||||
related_name='notification_templates',
|
related_name='notification_templates',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user