From fd1673328f8a7998363a339efa8f1d48573b6f3f Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 19 Mar 2017 18:48:41 -0700 Subject: [PATCH] Add PDBAlbumMixin.get_root_albums to simplify elsewhere --- etiquette/photodb.py | 5 +++++ etiquette_site.py | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index dc9a05c..9f523d6 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -272,6 +272,11 @@ class PDBAlbumMixin: def get_albums(self): yield from self.get_things(thing_type='album') + def get_root_albums(self): + for album in self.get_albums(): + if album.parent() is None: + yield album + def new_album( self, title=None, diff --git a/etiquette_site.py b/etiquette_site.py index 8a1f839..3de03af 100644 --- a/etiquette_site.py +++ b/etiquette_site.py @@ -351,8 +351,7 @@ def get_album_zip(albumid): def get_albums_core(): - albums = P.get_albums() - albums = [a for a in albums if a.parent() is None] + albums = list(P.get_root_albums()) albums.sort(key=lambda x: x.display_name.lower()) return albums