diff --git a/src/palace/manager/api/admin/controller/custom_lists.py b/src/palace/manager/api/admin/controller/custom_lists.py index 33a535e16..25510b77f 100644 --- a/src/palace/manager/api/admin/controller/custom_lists.py +++ b/src/palace/manager/api/admin/controller/custom_lists.py @@ -114,7 +114,7 @@ def _get_work_from_urn(self, library: Library, urn: str | None) -> Work | None: .join(LicensePool, LicensePool.work_id == Work.id) .join(Collection, LicensePool.collection_id == Collection.id) .filter(LicensePool.identifier_id == identifier.id) - .filter(Collection.id.in_([c.id for c in library.all_collections])) + .filter(Collection.id.in_([c.id for c in library.collections])) ) work = query.one() return work diff --git a/src/palace/manager/api/admin/dashboard_stats.py b/src/palace/manager/api/admin/dashboard_stats.py index 09af9d3a2..18fad5520 100644 --- a/src/palace/manager/api/admin/dashboard_stats.py +++ b/src/palace/manager/api/admin/dashboard_stats.py @@ -129,9 +129,7 @@ def _authorized_collections( all_collections = self._all_collections() for library in authorized_libraries: - library_collections = { - all_collections[c.id] for c in library.all_collections - } + library_collections = {all_collections[c.id] for c in library.collections} authorized_collections_by_library[library.short_name] = sorted( library_collections, key=lambda c: c.id ) diff --git a/src/palace/manager/sqlalchemy/model/library.py b/src/palace/manager/sqlalchemy/model/library.py index d4b8b1c0e..e8136a9c1 100644 --- a/src/palace/manager/sqlalchemy/model/library.py +++ b/src/palace/manager/sqlalchemy/model/library.py @@ -310,12 +310,6 @@ def update_settings(self, new_settings: LibrarySettings) -> None: self._settings = None integration_settings_update(LibrarySettings, self, new_settings, merge=True) - @property - def all_collections(self) -> Generator[Collection]: - for collection in self.collections: - yield collection - yield from collection.parents - @property def entrypoints(self) -> Generator[type[EntryPoint] | None]: """The EntryPoints enabled for this library.""" @@ -394,7 +388,7 @@ def restrict_to_ready_deliverable_works( from palace.manager.sqlalchemy.model.collection import Collection collection_ids = collection_ids or [ - x.id for x in self.all_collections if x.id is not None + x.id for x in self.collections if x.id is not None ] return Collection.restrict_to_ready_deliverable_works( query, diff --git a/tests/manager/sqlalchemy/model/test_library.py b/tests/manager/sqlalchemy/model/test_library.py index e4a8bca76..1963aa180 100644 --- a/tests/manager/sqlalchemy/model/test_library.py +++ b/tests/manager/sqlalchemy/model/test_library.py @@ -98,14 +98,13 @@ def test_has_root_lanes(self, db: DatabaseTransactionFixture): db.session.flush() assert False == library.has_root_lanes - def test_all_collections(self, db: DatabaseTransactionFixture): + def test_collections(self, db: DatabaseTransactionFixture): library = db.default_library() parent = db.collection() db.default_collection().parent_id = parent.id assert [db.default_collection()] == library.collections - assert {db.default_collection(), parent} == set(library.all_collections) def test_estimated_holdings_by_language(self, db: DatabaseTransactionFixture): library = db.default_library()