More work on unicode for project dirs

This commit is contained in:
Matthew Jones 2014-12-17 12:52:29 -05:00
parent edb646fdf9
commit 1f723e9404
2 changed files with 6 additions and 4 deletions

View File

@ -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):

View File

@ -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: