From 1f723e94044495a93ba97655690f64eea286583d Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 17 Dec 2014 12:52:29 -0500 Subject: [PATCH] More work on unicode for project dirs --- awx/main/models/projects.py | 2 +- awx/main/utils.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index b82b2350eb..a3565efce1 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -191,7 +191,7 @@ class ProjectOptions(models.Model): if 'tasks' in playbook.split(os.sep): continue results.append(playbook) - return sorted(results, key=lambda x: unicode(x).lower()) + return sorted(results, key=lambda x: smart_str(x).lower()) class Project(UnifiedJobTemplate, ProjectOptions): diff --git a/awx/main/utils.py b/awx/main/utils.py index 5e90c33d38..5f68b9c7ad 100644 --- a/awx/main/utils.py +++ b/awx/main/utils.py @@ -18,6 +18,8 @@ import tempfile # Django REST Framework from rest_framework.exceptions import ParseError, PermissionDenied +from django.utils.encoding import smart_str + # PyCrypto from Crypto.Cipher import AES @@ -285,9 +287,9 @@ def model_instance_diff(old, new, serializer_mapping=None): if old_value != new_value and field not in Credential.PASSWORD_FIELDS: if type(old_value) not in (bool, int, type(None)): - old_value = unicode(old_value) + old_value = smart_str(old_value) if type(new_value) not in (bool, int, type(None)): - new_value = unicode(new_value) + new_value = smart_str(new_value) diff[field] = (old_value, new_value) elif old_value != new_value and field in Credential.PASSWORD_FIELDS: diff[field] = (u"hidden", u"hidden") @@ -317,7 +319,7 @@ def model_to_dict(obj, serializer_mapping=None): if field.name not in Credential.PASSWORD_FIELDS: field_val = getattr(obj, field.name, None) if type(field_val) not in (bool, int, type(None)): - attr_d[field.name] = unicode(field_val) + attr_d[field.name] = smart_str(field_val) else: attr_d[field.name] = field_val else: