diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index c42f312fb..3cde9cbdd 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -297,8 +297,9 @@ class SongMediaItem(MediaManagerItem): self.list_view.clear() search_results.sort(key=get_author_key) for author in search_results: - author.songs.sort(key=get_song_key) - for song in author.songs: + songs = [author_song.song for author_song in author.authors_songs] + songs.sort(key=get_song_key) + for song in songs: # Do not display temporary songs if song.temporary: continue diff --git a/tests/openlp_plugins/songs/test_mediaitem.py b/tests/openlp_plugins/songs/test_mediaitem.py index 58a77ca25..4dd9e75a9 100644 --- a/tests/openlp_plugins/songs/test_mediaitem.py +++ b/tests/openlp_plugins/songs/test_mediaitem.py @@ -177,12 +177,17 @@ def test_display_results_author(media_item): mock_song.title = 'My Song' mock_song.sort_key = 'My Song' mock_song.temporary = False + mock_author_song = MagicMock() + mock_author_song.author = mock_author + mock_author_song.song = mock_song mock_song_temp.id = 2 mock_song_temp.title = 'My Temporary' mock_song_temp.sort_key = 'My Temporary' mock_song_temp.temporary = True - mock_author.songs.append(mock_song) - mock_author.songs.append(mock_song_temp) + mock_author_song_temp = MagicMock() + mock_author_song_temp.author = mock_author + mock_author_song_temp.song = mock_song_temp + mock_author.authors_songs = [mock_author_song, mock_author_song_temp] mock_search_results.append(mock_author) mock_qlist_widget = MagicMock() MockedQListWidgetItem.return_value = mock_qlist_widget