diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 5d9d9c6a7f..ee4625da3e 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -38,9 +38,8 @@ from rest_framework.utils.serializer_helpers import ReturnList from polymorphic.models import PolymorphicModel # AWX -from awx.main.constants import SCHEDULEABLE_PROVIDERS, ANSI_SGR_PATTERN +from awx.main.constants import SCHEDULEABLE_PROVIDERS, ANSI_SGR_PATTERN, ACTIVE_STATES, TOKEN_CENSOR from awx.main.models import * # noqa -from awx.main.constants import ACTIVE_STATES, TOKEN_CENSOR from awx.main.models.base import NEW_JOB_TYPE_CHOICES from awx.main.access import get_user_capabilities from awx.main.fields import ImplicitRoleField diff --git a/awx/main/signals.py b/awx/main/signals.py index ea4a5ae927..abbe83a27d 100644 --- a/awx/main/signals.py +++ b/awx/main/signals.py @@ -31,6 +31,7 @@ import six from awx.main.models import * # noqa from django.contrib.sessions.models import Session from awx.api.serializers import * # noqa +from awx.main.constants import TOKEN_CENSOR from awx.main.utils import model_instance_diff, model_to_dict, camelcase_to_underscore from awx.main.utils import ignore_inventory_computed_fields, ignore_inventory_group_removal, _inventory_updates from awx.main.tasks import update_inventory_computed_fields @@ -449,6 +450,8 @@ model_serializer_mapping = { WorkflowJobTemplate: WorkflowJobTemplateSerializer, WorkflowJobTemplateNode: WorkflowJobTemplateNodeSerializer, WorkflowJob: WorkflowJobSerializer, + OAuth2AccessToken: OAuth2TokenSerializer, + OAuth2Application: OAuth2ApplicationSerializer, } @@ -468,7 +471,7 @@ def activity_stream_create(sender, instance, created, **kwargs): if 'extra_vars' in changes: changes['extra_vars'] = instance.display_extra_vars() if type(instance) == OAuth2AccessToken: - changes['token'] = '*************' + changes['token'] = TOKEN_CENSOR activity_entry = ActivityStream( operation='create', object1=object1, diff --git a/awx/main/utils/common.py b/awx/main/utils/common.py index 89511ab4b9..13ff87e956 100644 --- a/awx/main/utils/common.py +++ b/awx/main/utils/common.py @@ -383,7 +383,7 @@ def _convert_model_field_for_display(obj, field_name, password_fields=None): field_val = json.dumps(field_val, ensure_ascii=False) except Exception: pass - if type(field_val) not in (bool, int, type(None)): + if type(field_val) not in (bool, int, type(None), long): field_val = smart_str(field_val) return field_val @@ -416,10 +416,8 @@ def model_instance_diff(old, new, serializer_mapping=None): _convert_model_field_for_display(old, field, password_fields=old_password_fields), _convert_model_field_for_display(new, field, password_fields=new_password_fields), ) - if len(diff) == 0: diff = None - return diff @@ -438,7 +436,6 @@ def model_to_dict(obj, serializer_mapping=None): if field.name not in allowed_fields: continue attr_d[field.name] = _convert_model_field_for_display(obj, field.name, password_fields=password_fields) - return attr_d