forked from openlp/openlp
Fix issue #937 by handling custom verse types correctly
This commit is contained in:
parent
9b1fb4fe9f
commit
35723ed72c
@ -243,7 +243,12 @@ class SongSelectImport(object):
|
||||
verse_type = verse['label']
|
||||
verse_number = 1
|
||||
verse_type = VerseType.from_loose_input(verse_type)
|
||||
verse_number = int(verse_number)
|
||||
try:
|
||||
verse_number = int(verse_number)
|
||||
except ValueError:
|
||||
# Some custom verse types contain multiple words, and this messes with the verse number,
|
||||
# so just default to 1 on ValueError. See https://gitlab.com/openlp/openlp/-/issues/937
|
||||
verse_number = 1
|
||||
song_xml.add_verse_to_lyrics(VerseType.tags[verse_type], verse_number, verse['lyrics'])
|
||||
verse_order.append('{tag}{number}'.format(tag=VerseType.tags[verse_type], number=verse_number))
|
||||
db_song.verse_order = ' '.join(verse_order)
|
||||
|
@ -374,6 +374,8 @@ class TestSongSelectImport(TestCase, TestMixin):
|
||||
<p>verse thing 1<br>line 2</p>
|
||||
<h3>Verse 2</h3>
|
||||
<p>verse thing 2</p>
|
||||
<h3>Spoken Words</h3>
|
||||
<p>completely custom verse type</p>
|
||||
</div>
|
||||
<ul class="copyright">
|
||||
<li>Copy thing</li><li>Copy thing 2</li>
|
||||
@ -396,7 +398,8 @@ class TestSongSelectImport(TestCase, TestMixin):
|
||||
assert result['topics'] == ['theme1', 'theme2']
|
||||
assert result['ccli_number'] == '1234_cclinumber_5678'
|
||||
assert result['verses'] == [{'label': 'Verse 1', 'lyrics': 'verse thing 1\nline 2'},
|
||||
{'label': 'Verse 2', 'lyrics': 'verse thing 2'}]
|
||||
{'label': 'Verse 2', 'lyrics': 'verse thing 2'},
|
||||
{'label': 'Spoken Words', 'lyrics': 'completely custom verse type'}]
|
||||
|
||||
@patch('openlp.plugins.songs.lib.songselect.clean_song')
|
||||
@patch('openlp.plugins.songs.lib.songselect.Topic')
|
||||
|
Loading…
Reference in New Issue
Block a user