示例#1
0
文件: api.py 项目: pombreda/ralph
 def dehydrate(self, bundle, **kwargs):
     result = []
     id_ = bundle.obj.id
     for q, dir_name, other in (
         (Q(parent_id=id_), 'OUTGOING', 'child'),
         (Q(child_id=id_), 'INCOMING', 'parent'),
     ):
         for relation in CIRelation.objects.filter(q).select_related(other):
             other_ci = getattr(relation, other)
             result.append({
                 'type':
                 CI_RELATION_TYPES.name_from_id(relation.type),
                 'dir':
                 dir_name,
                 'id':
                 other_ci.id,
                 'resource_uri':
                 CIResourceV010(
                     api_name=self.api_name).get_resource_uri(other_ci),
                 'name':
                 other_ci.name,
                 'ci_type':
                 other_ci.type_id,
             })
     return result
示例#2
0
文件: api.py 项目: pydubreucq/ralph
 def dehydrate(self, bundle, **kwargs):
     result = []
     id_ = bundle.obj.id
     for q, dir_name, other in ((Q(parent_id=id_), "OUTGOING", "child"), (Q(child_id=id_), "INCOMING", "parent")):
         for relation in CIRelation.objects.filter(q).select_related(other):
             other_ci = getattr(relation, other)
             result.append(
                 {
                     "type": CI_RELATION_TYPES.name_from_id(relation.type),
                     "dir": dir_name,
                     "id": other_ci.id,
                     "resource_uri": CIResourceV010(api_name=self.api_name).get_resource_uri(other_ci),
                     "name": other_ci.name,
                     "ci_type": other_ci.type_id,
                 }
             )
     return result
示例#3
0
文件: api.py 项目: deejay1/ralph
 def dehydrate(self, bundle, **kwargs):
     result = []
     id_ = bundle.obj.id
     for q, dir_name, other in (
         (Q(parent_id=id_), 'OUTGOING', 'child'),
         (Q(child_id=id_), 'INCOMING', 'parent'),
     ):
         for relation in CIRelation.objects.filter(q).select_related(other):
             other_ci = getattr(relation, other)
             result.append(
                 {
                     'type': CI_RELATION_TYPES.name_from_id(relation.type),
                     'dir': dir_name,
                     'id': other_ci.id,
                     'resource_uri': CIResourceV010(
                         api_name=self.api_name
                     ).get_resource_uri(other_ci),
                     'name': other_ci.name,
                     'ci_type': other_ci.type_id,
                 }
             )
     return result