mirror of
https://github.com/ansible/awx.git
synced 2026-07-08 23:08:04 -02:30
Merge pull request #3837 from saito-hideki/issue/2891
Add credential info in expanded list view of inventory update Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
@@ -1091,7 +1091,7 @@ class BaseOAuth2TokenSerializer(BaseSerializer):
|
|||||||
raise PermissionDenied(str(e))
|
raise PermissionDenied(str(e))
|
||||||
|
|
||||||
|
|
||||||
class UserAuthorizedTokenSerializer(BaseOAuth2TokenSerializer):
|
class UserAuthorizedTokenSerializer(BaseOAuth2TokenSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
@@ -1143,7 +1143,7 @@ class OAuth2TokenSerializer(BaseOAuth2TokenSerializer):
|
|||||||
class OAuth2TokenDetailSerializer(OAuth2TokenSerializer):
|
class OAuth2TokenDetailSerializer(OAuth2TokenSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
read_only_fields = ('*', 'user', 'application')
|
read_only_fields = ('*', 'user', 'application')
|
||||||
|
|
||||||
|
|
||||||
class UserPersonalTokenSerializer(BaseOAuth2TokenSerializer):
|
class UserPersonalTokenSerializer(BaseOAuth2TokenSerializer):
|
||||||
@@ -1163,9 +1163,9 @@ class UserPersonalTokenSerializer(BaseOAuth2TokenSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class OAuth2ApplicationSerializer(BaseSerializer):
|
class OAuth2ApplicationSerializer(BaseSerializer):
|
||||||
|
|
||||||
show_capabilities = ['edit', 'delete']
|
show_capabilities = ['edit', 'delete']
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = OAuth2Application
|
model = OAuth2Application
|
||||||
fields = (
|
fields = (
|
||||||
@@ -1190,8 +1190,8 @@ class OAuth2ApplicationSerializer(BaseSerializer):
|
|||||||
'skip_authorization': {
|
'skip_authorization': {
|
||||||
'label': _('Skip Authorization')
|
'label': _('Skip Authorization')
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def to_representation(self, obj):
|
def to_representation(self, obj):
|
||||||
ret = super(OAuth2ApplicationSerializer, self).to_representation(obj)
|
ret = super(OAuth2ApplicationSerializer, self).to_representation(obj)
|
||||||
request = self.context.get('request', None)
|
request = self.context.get('request', None)
|
||||||
@@ -1200,7 +1200,7 @@ class OAuth2ApplicationSerializer(BaseSerializer):
|
|||||||
if obj.client_type == 'public':
|
if obj.client_type == 'public':
|
||||||
ret.pop('client_secret', None)
|
ret.pop('client_secret', None)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def get_related(self, obj):
|
def get_related(self, obj):
|
||||||
res = super(OAuth2ApplicationSerializer, self).get_related(obj)
|
res = super(OAuth2ApplicationSerializer, self).get_related(obj)
|
||||||
res.update(dict(
|
res.update(dict(
|
||||||
@@ -2007,17 +2007,22 @@ class InventorySourceOptionsSerializer(BaseSerializer):
|
|||||||
# TODO: remove when old 'credential' fields are removed
|
# TODO: remove when old 'credential' fields are removed
|
||||||
def get_summary_fields(self, obj):
|
def get_summary_fields(self, obj):
|
||||||
summary_fields = super(InventorySourceOptionsSerializer, self).get_summary_fields(obj)
|
summary_fields = super(InventorySourceOptionsSerializer, self).get_summary_fields(obj)
|
||||||
|
all_creds = []
|
||||||
if 'credential' in summary_fields:
|
if 'credential' in summary_fields:
|
||||||
cred = obj.get_cloud_credential()
|
cred = obj.get_cloud_credential()
|
||||||
if cred:
|
if cred:
|
||||||
summary_fields['credential'] = {
|
summarized_cred = {
|
||||||
'id': cred.id, 'name': cred.name, 'description': cred.description,
|
'id': cred.id, 'name': cred.name, 'description': cred.description,
|
||||||
'kind': cred.kind, 'cloud': True
|
'kind': cred.kind, 'cloud': True
|
||||||
}
|
}
|
||||||
|
summary_fields['credential'] = summarized_cred
|
||||||
|
all_creds.append(summarized_cred)
|
||||||
if self.version > 1:
|
if self.version > 1:
|
||||||
summary_fields['credential']['credential_type_id'] = cred.credential_type_id
|
summary_fields['credential']['credential_type_id'] = cred.credential_type_id
|
||||||
else:
|
else:
|
||||||
summary_fields.pop('credential')
|
summary_fields.pop('credential')
|
||||||
|
if self.version > 1:
|
||||||
|
summary_fields['credentials'] = all_creds
|
||||||
return summary_fields
|
return summary_fields
|
||||||
|
|
||||||
|
|
||||||
@@ -5116,4 +5121,3 @@ class ActivityStreamSerializer(BaseSerializer):
|
|||||||
if obj.setting:
|
if obj.setting:
|
||||||
summary_fields['setting'] = [obj.setting]
|
summary_fields['setting'] = [obj.setting]
|
||||||
return summary_fields
|
return summary_fields
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user