From 3aef267608babf0b6f9d0a558dcfa18622bb7c2c Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Fri, 12 Apr 2024 14:33:33 +0200 Subject: [PATCH] fix: albums are now also contained in the child song collection album attributes --- music_kraken/objects/collection.py | 4 ++-- music_kraken/objects/song.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/music_kraken/objects/collection.py b/music_kraken/objects/collection.py index 5e078fb..ad2890a 100644 --- a/music_kraken/objects/collection.py +++ b/music_kraken/objects/collection.py @@ -58,7 +58,7 @@ class Collection(Generic[T]): self._indexed_values[name].add(value) self._indexed_to_objects[value].append(__object) - if not from_map: + if not from_map or True: for attribute, new_object in self.contain_given_in_attribute.items(): __object.__getattribute__(attribute).contain_collection_inside(new_object) @@ -110,7 +110,7 @@ class Collection(Generic[T]): if self._contained_in_self(__object): return [self] - for collection in self.children: + for collection in (*self.children, *self.parents): results.extend(collection._contained_in_sub(__object, break_at_first=break_at_first)) if break_at_first: diff --git a/music_kraken/objects/song.py b/music_kraken/objects/song.py index 93bd9a2..716694c 100644 --- a/music_kraken/objects/song.py +++ b/music_kraken/objects/song.py @@ -244,6 +244,9 @@ class Album(Base): self.song_collection.contain_attribute_in_given = { "main_artist_collection": self.artist_collection } + self.song_collection.append_object_to_attribute = { + "album_collection": self + } def _add_other_db_objects(self, object_type: Type[OuterProxy], object_list: List[OuterProxy]): if object_type is Song: