mirror of
https://github.com/ansible/awx.git
synced 2026-05-13 04:17:36 -02:30
set messages default
This commit is contained in:
@@ -5,6 +5,7 @@ from __future__ import unicode_literals
|
|||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
import awx.main.fields
|
import awx.main.fields
|
||||||
|
import awx.main.models.notifications
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@@ -17,7 +18,7 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='notificationtemplate',
|
model_name='notificationtemplate',
|
||||||
name='messages',
|
name='messages',
|
||||||
field=awx.main.fields.JSONField(default=dict,
|
field=awx.main.fields.JSONField(default=awx.main.models.notifications.NotificationTemplate.default_messages,
|
||||||
help_text='Optional custom messages for notification template.',
|
help_text='Optional custom messages for notification template.',
|
||||||
null=True,
|
null=True,
|
||||||
blank=True),
|
blank=True),
|
||||||
|
|||||||
@@ -72,10 +72,16 @@ class NotificationTemplate(CommonModelNameNotUnique):
|
|||||||
|
|
||||||
notification_configuration = JSONField(blank=False)
|
notification_configuration = JSONField(blank=False)
|
||||||
|
|
||||||
|
def default_messages():
|
||||||
|
DEFAULT_MSG = "{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}: {{ url }}"
|
||||||
|
return {'started': { 'message': DEFAULT_MSG, 'body': ''},
|
||||||
|
'success': { 'message': DEFAULT_MSG, 'body': ''},
|
||||||
|
'error': { 'message': DEFAULT_MSG, 'body': ''}}
|
||||||
|
|
||||||
messages = JSONField(
|
messages = JSONField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
default=dict,
|
default=default_messages,
|
||||||
help_text=_('Optional custom messages for notification template.'))
|
help_text=_('Optional custom messages for notification template.'))
|
||||||
|
|
||||||
def has_message(self, condition):
|
def has_message(self, condition):
|
||||||
|
|||||||
Reference in New Issue
Block a user