mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 02:19:58 -03:30
Add functions in migration file for deleting and altering 'any' state notifications
This commit is contained in:
parent
17c89ed412
commit
69502bc133
@ -5,6 +5,21 @@ from __future__ import unicode_literals
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def forwards_split_unified_job_template_any(apps, schema_editor):
|
||||
UnifiedJobTemplate = apps.get_model('main', 'unifiedjobtemplate')
|
||||
for ujt in UnifiedJobTemplate.objects.all():
|
||||
for ujt_notification in ujt.notification_templates_any.all():
|
||||
ujt.notification_templates_success.add(ujt_notification)
|
||||
ujt.notification_templates_error.add(ujt_notification)
|
||||
|
||||
def forwards_split_organization_any(apps, schema_editor):
|
||||
Organization = apps.get_model('main', 'organization')
|
||||
for org in Organization.objects.all():
|
||||
for org_notification in org.notification_templates_any.all():
|
||||
org.notification_templates_success.add(org_notification)
|
||||
org.notification_templates_error.add(org_notification)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
@ -22,7 +37,8 @@ class Migration(migrations.Migration):
|
||||
name='notification_templates_started',
|
||||
field=models.ManyToManyField(blank=True, related_name='unifiedjobtemplate_notification_templates_for_started', to='main.NotificationTemplate'),
|
||||
),
|
||||
# migrations.RunPython() stuff goes in here
|
||||
# Separate out "any" notifications into "success" and "error" before the "any" state gets deleted.
|
||||
migrations.RunPython(forwards_split_unified_job_template_any, forwards_split_organization_any),
|
||||
migrations.RemoveField(
|
||||
model_name='organization',
|
||||
name='notification_templates_any',
|
||||
|
||||
@ -243,8 +243,6 @@ class JobNotificationMixin(object):
|
||||
notification_template_type = 'error'
|
||||
all_notification_templates = set(notification_templates.get(notification_template_type, []))
|
||||
if len(all_notification_templates):
|
||||
# if status_str != 'running':
|
||||
# all_notification_templates.update(notification_templates.get('any', []))
|
||||
try:
|
||||
(notification_subject, notification_body) = getattr(self, 'build_notification_%s_message' % status_str)()
|
||||
except AttributeError:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user