Skip to content

Commit

Permalink
fixing issue #111 (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
seg1129 authored Nov 23, 2019
1 parent e1f13fe commit 46d1ca2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ehb_service/apps/api/views/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,21 @@ def output_relationships(self, relationship_objects, relationships_dict=[]):
return relationships_dict

def relationships_by_protocol(self, protocol_id):
all_protocol_relationships = SubjectFamRelation.objects.filter(protocol_id=protocol_id)
return(self.output_relationships(all_protocol_relationships))
relationships_dict = []
all_protocol_relationships = list(SubjectFamRelation.objects.filter(protocol_id=protocol_id))
for relationship in all_protocol_relationships:
print(relationship.subject_1.id)
relationships_dict.append({
"subject_1_id": relationship.subject_1.id,
"subject_1_org_id": relationship.subject_1.organization_subject_id,
"subject_2_id": relationship.subject_2.id,
"subject_2_org_id": relationship.subject_2.organization_subject_id,
"subject_1_role": relationship.subject_1_role.desc,
"subject_2_role": relationship.subject_2_role.desc,
"protocol_id": relationship.protocol_id,
"id": relationship.id
})
return(relationships_dict)

def relationships_by_subject(self, subject_id):
relationships_dict = []
Expand Down

0 comments on commit 46d1ca2

Please sign in to comment.