Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a display bug in notification bodies with unicode characters #8313

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion awx/main/models/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ def context(self, serialized_job):
'job': job_context,
'job_friendly_name': self.get_notification_friendly_name(),
'url': self.get_ui_url(),
'job_metadata': json.dumps(self.notification_data(), indent=4)
'job_metadata': json.dumps(
self.notification_data(),
ensure_ascii=False,
indent=4
)
}

def build_context(node, fields, allowed_fields):
Expand Down
9 changes: 9 additions & 0 deletions awx/main/tests/functional/models/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ def check_structure(expected_structure, obj):
context = job.context(job_serialization)
check_structure(TestJobNotificationMixin.CONTEXT_STRUCTURE, context)


@pytest.mark.django_db
def test_context_job_metadata_with_unicode(self):
job = Job.objects.create(name='批量安装项目')
job_serialization = UnifiedJobSerializer(job).to_representation(job)
context = job.context(job_serialization)
assert '批量安装项目' in context['job_metadata']


def test_context_stub(self):
"""The context stub is a fake context used to validate custom notification messages. Ensure that
this also has the expected structure. Furthermore, ensure that the stub context contains
Expand Down