events: fix default transport for successive migrations

This commit is contained in:
Jens Langhammer 2021-01-14 23:50:18 +01:00
parent 2579e168c3
commit 8684d106d5
1 changed files with 12 additions and 9 deletions

View File

@ -31,10 +31,11 @@ def notify_configuration_error(apps: Apps, schema_editor: BaseDatabaseSchemaEdit
name="default-notify-configuration-error", name="default-notify-configuration-error",
defaults={"group": admin_group, "severity": NotificationSeverity.ALERT}, defaults={"group": admin_group, "severity": NotificationSeverity.ALERT},
) )
default_transport = NotificationTransport.objects.using(db_alias).get( trigger.transports.set(
name="default-email-transport" NotificationTransport.objects.using(db_alias).filter(
name="default-email-transport"
)
) )
trigger.transports.add(default_transport)
trigger.save() trigger.save()
PolicyBinding.objects.using(db_alias).update_or_create( PolicyBinding.objects.using(db_alias).update_or_create(
target=trigger, target=trigger,
@ -69,10 +70,11 @@ def notify_update(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
name="default-notify-update", name="default-notify-update",
defaults={"group": admin_group, "severity": NotificationSeverity.ALERT}, defaults={"group": admin_group, "severity": NotificationSeverity.ALERT},
) )
default_transport = NotificationTransport.objects.using(db_alias).get( trigger.transports.set(
name="default-email-transport" NotificationTransport.objects.using(db_alias).filter(
name="default-email-transport"
)
) )
trigger.transports.add(default_transport)
trigger.save() trigger.save()
PolicyBinding.objects.using(db_alias).update_or_create( PolicyBinding.objects.using(db_alias).update_or_create(
target=trigger, target=trigger,
@ -111,10 +113,11 @@ def notify_exception(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
name="default-notify-exception", name="default-notify-exception",
defaults={"group": admin_group, "severity": NotificationSeverity.ALERT}, defaults={"group": admin_group, "severity": NotificationSeverity.ALERT},
) )
default_transport = NotificationTransport.objects.using(db_alias).get( trigger.transports.set(
name="default-email-transport" NotificationTransport.objects.using(db_alias).filter(
name="default-email-transport"
)
) )
trigger.transports.add(default_transport)
trigger.save() trigger.save()
PolicyBinding.objects.using(db_alias).update_or_create( PolicyBinding.objects.using(db_alias).update_or_create(
target=trigger, target=trigger,