File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
ansible_base/rbac/service_api Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ class ObjectIDAnsibleIDField(serializers.Field):
4343
4444 def to_representation (self , value ):
4545 "The source for this field is object_id, which is ignored, use content_object instead"
46- assignment = self .parent .instance
46+ assignment = getattr (self , "_this_assignment" , None )
47+ if not assignment :
48+ return None
4749 content_object = assignment .content_object
4850 if isinstance (content_object , RemoteObject ):
4951 return None
@@ -69,6 +71,11 @@ class BaseAssignmentSerializer(serializers.ModelSerializer):
6971 # TODO: use the from_service to control what we sync back to
7072 from_service = serializers .CharField (write_only = True )
7173
74+ def to_representation (self , instance ):
75+ # hack to surface content_object for ObjectIDAnsibleIDField
76+ self .fields ["object_ansible_id" ]._this_assignment = instance
77+ return super ().to_representation (instance )
78+
7279 def get_created_by_ansible_id (self , obj ):
7380 return str (obj .created_by .resource .ansible_id )
7481
You can’t perform that action at this time.
0 commit comments