1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Merge pull request #1147 from AlanCoding/exclude_last_used

Exclude last_used from activity stream
This commit is contained in:
Alan Rominger 2018-03-28 14:32:55 -04:00 committed by GitHub
commit ae5d17d151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -350,11 +350,14 @@ def get_allowed_fields(obj, serializer_mapping):
allowed_fields = [x for x in serializer_actual.fields if not serializer_actual.fields[x].read_only] + ['id']
else:
allowed_fields = [x.name for x in obj._meta.fields]
if obj._meta.model_name == 'user':
field_blacklist = ['last_login']
allowed_fields = [f for f in allowed_fields if f not in field_blacklist]
if obj._meta.model_name == 'oauth2application':
field_blacklist = ['client_secret']
ACTIVITY_STREAM_FIELD_EXCLUSIONS = {
'user': ['last_login'],
'oauth2accesstoken': ['last_used'],
'oauth2application': ['client_secret']
}
field_blacklist = ACTIVITY_STREAM_FIELD_EXCLUSIONS.get(obj._meta.model_name, [])
if field_blacklist:
allowed_fields = [f for f in allowed_fields if f not in field_blacklist]
return allowed_fields