Add PDBAlbumMixin.get_root_albums to simplify elsewhere

This commit is contained in:
voussoir 2017-03-19 18:48:41 -07:00
parent 97400a448b
commit fd1673328f
2 changed files with 6 additions and 2 deletions

View file

@ -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,

View file

@ -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