Skip to content

Commit

Permalink
test state for link_inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
rkoschmitzky committed Jun 29, 2023
1 parent bdc32f9 commit 6a1ab8e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/trackteroid/entities/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,19 @@ def link_inputs(self, collection):
Returns:
self
"""
self.fetch_attributes("incoming_links.from_id")
self.fetch_attributes("incoming_links", "incoming_links.from_id")
collection.fetch_attributes("incoming_links", "incoming_links.from_id")

if len(collection) != 0:
current_links = self.incoming_links
for entity in self:
links = entity.incoming_links
for _id in collection.id:
if _id not in links.from_id:
entity.incoming_links.create(from_id=_id, to_id=entity.id[0])
for target in collection:
links = entity.incoming_links
if target.id[0] not in links.from_id:
new_link = entity.incoming_links.create(from_id=target.id[0], to_id=entity.id[0])
current_links = current_links.union(new_link)

self.incoming_links = current_links
else:
LOG.warning("The collection you want to link is empty.")

Expand Down

0 comments on commit 6a1ab8e

Please sign in to comment.