Merge branch 'michaelweghorn/fix_author_search' into 'master'

Fix song search by author

Closes #1588

See merge request openlp/openlp!627
This commit is contained in:
Tomas Groth 2023-07-13 16:43:48 +00:00
commit 41887bbafb
2 changed files with 10 additions and 4 deletions

View File

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

View File

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