openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #23435
[Merge] lp:~sam92/openlp/display-songbook into lp:openlp
Samuel Mehrbrodt has proposed merging lp:~sam92/openlp/display-songbook into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~sam92/openlp/display-songbook/+merge/218185
Add an option to display the songbook in the footer
lp:~sam92/openlp/display-songbook (revision 2351)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/426/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/382/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/327/
[SUCCESS] http://ci.openlp.org/job/Branch-04-Windows_Tests/288/
[SUCCESS] http://ci.openlp.org/job/Branch-05a-Code_Analysis/194/
[SUCCESS] http://ci.openlp.org/job/Branch-05b-Test_Coverage/69/
--
https://code.launchpad.net/~sam92/openlp/display-songbook/+merge/218185
Your team OpenLP Core is requested to review the proposed merge of lp:~sam92/openlp/display-songbook into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2014-05-01 17:06:47 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2014-05-03 10:46:44 +0000
@@ -36,8 +36,8 @@
from sqlalchemy.sql import or_
from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists, UiStrings, translate
-from openlp.core.lib import MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, check_item_selected, \
- create_separated_list
+from openlp.core.lib import MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItem, ServiceItemContext, \
+ check_item_selected, create_separated_list
from openlp.core.lib.ui import create_widget_action
from openlp.plugins.songs.forms.editsongform import EditSongForm
from openlp.plugins.songs.forms.songmaintenanceform import SongMaintenanceForm
@@ -124,7 +124,8 @@
log.debug('config_updated')
self.search_as_you_type = Settings().value(self.settings_section + '/search as type')
self.update_service_on_edit = Settings().value(self.settings_section + '/update service on edit')
- self.add_song_from_service = Settings().value(self.settings_section + '/add song from service',)
+ self.add_song_from_service = Settings().value(self.settings_section + '/add song from service')
+ self.display_songbook = Settings().value(self.settings_section + '/display songbook')
def retranslateUi(self):
self.search_text_label.setText('%s:' % UiStrings().Search)
@@ -460,7 +461,7 @@
service_item.background_audio = [m.file_name for m in song.media_files]
return True
- def generate_footer(self, item, song):
+ def generate_footer(self, item: ServiceItem, song: Song):
"""
Generates the song footer based on a song and adds details to a service item.
@@ -506,6 +507,8 @@
item.raw_footer.append("%s: %s" % (AuthorType.Types[AuthorType.Translation],
create_separated_list(authors_translation)))
item.raw_footer.append(song.copyright)
+ if self.display_songbook and song.book:
+ item.raw_footer.append("%s #%s" % (song.book.name, song.song_number))
if Settings().value('core/ccli number'):
item.raw_footer.append(translate('SongsPlugin.MediaItem',
'CCLI License: ') + Settings().value('core/ccli number'))
=== modified file 'openlp/plugins/songs/lib/songstab.py'
--- openlp/plugins/songs/lib/songstab.py 2014-03-08 19:58:58 +0000
+++ openlp/plugins/songs/lib/songstab.py 2014-05-03 10:46:44 +0000
@@ -59,6 +59,9 @@
self.add_from_service_check_box = QtGui.QCheckBox(self.mode_group_box)
self.add_from_service_check_box.setObjectName('add_from_service_check_box')
self.mode_layout.addWidget(self.add_from_service_check_box)
+ self.display_songbook_check_box = QtGui.QCheckBox(self.mode_group_box)
+ self.display_songbook_check_box.setObjectName('songbook_check_box')
+ self.mode_layout.addWidget(self.display_songbook_check_box)
self.left_layout.addWidget(self.mode_group_box)
self.left_layout.addStretch()
self.right_layout.addStretch()
@@ -66,6 +69,7 @@
self.tool_bar_active_check_box.stateChanged.connect(self.on_tool_bar_active_check_box_changed)
self.update_on_edit_check_box.stateChanged.connect(self.on_update_on_edit_check_box_changed)
self.add_from_service_check_box.stateChanged.connect(self.on_add_from_service_check_box_changed)
+ self.display_songbook_check_box.stateChanged.connect(self.on_songbook_check_box_changed)
def retranslateUi(self):
self.mode_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Songs Mode'))
@@ -75,6 +79,7 @@
self.update_on_edit_check_box.setText(translate('SongsPlugin.SongsTab', 'Update service from song edit'))
self.add_from_service_check_box.setText(translate('SongsPlugin.SongsTab',
'Import missing songs from service files'))
+ self.display_songbook_check_box.setText(translate('SongsPlugin.SongsTab', 'Display songbook in footer'))
def on_search_as_type_check_box_changed(self, check_state):
self.song_search = (check_state == QtCore.Qt.Checked)
@@ -88,6 +93,9 @@
def on_add_from_service_check_box_changed(self, check_state):
self.update_load = (check_state == QtCore.Qt.Checked)
+ def on_songbook_check_box_changed(self, check_state):
+ self.display_songbook = (check_state == QtCore.Qt.Checked)
+
def load(self):
settings = Settings()
settings.beginGroup(self.settings_section)
@@ -95,10 +103,12 @@
self.tool_bar = settings.value('display songbar')
self.update_edit = settings.value('update service on edit')
self.update_load = settings.value('add song from service')
+ self.display_songbook = settings.value('display songbook')
self.search_as_type_check_box.setChecked(self.song_search)
self.tool_bar_active_check_box.setChecked(self.tool_bar)
self.update_on_edit_check_box.setChecked(self.update_edit)
self.add_from_service_check_box.setChecked(self.update_load)
+ self.display_songbook_check_box.setChecked(self.display_songbook)
settings.endGroup()
def save(self):
@@ -108,6 +118,7 @@
settings.setValue('display songbar', self.tool_bar)
settings.setValue('update service on edit', self.update_edit)
settings.setValue('add song from service', self.update_load)
+ settings.setValue('display songbook', self.display_songbook)
settings.endGroup()
if self.tab_visited:
self.settings_form.register_post_process('songs_config_updated')
=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py 2014-04-12 20:19:22 +0000
+++ openlp/plugins/songs/songsplugin.py 2014-05-03 10:46:44 +0000
@@ -63,6 +63,7 @@
'songs/search as type': False,
'songs/add song from service': True,
'songs/display songbar': True,
+ 'songs/display songbook': False,
'songs/last directory import': '',
'songs/last directory export': '',
'songs/songselect username': '',
=== modified file 'tests/functional/openlp_plugins/songs/test_mediaitem.py'
--- tests/functional/openlp_plugins/songs/test_mediaitem.py 2014-04-21 10:06:17 +0000
+++ tests/functional/openlp_plugins/songs/test_mediaitem.py 2014-05-03 10:46:44 +0000
@@ -1,8 +1,6 @@
"""
This module contains tests for the lib submodule of the Songs plugin.
"""
-import os
-from tempfile import mkstemp
from unittest import TestCase
from PyQt4 import QtCore, QtGui
@@ -29,6 +27,7 @@
with patch('openlp.core.lib.mediamanageritem.MediaManagerItem._setup'), \
patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__'):
self.media_item = SongMediaItem(None, MagicMock())
+ self.media_item.display_songbook = False
self.get_application()
self.build_settings()
QtCore.QLocale.setDefault(QtCore.QLocale('en_GB'))
@@ -128,3 +127,29 @@
# THEN: I would get an amended footer string
self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 4321'],
'The array should be returned correctly with a song, an author, copyright and amended ccli')
+
+ def build_song_footer_base_songbook_test(self):
+ """
+ Test build songs footer with basic song and a songbook
+ """
+ # GIVEN: A Song and a Service Item and a configured CCLI license
+ mock_song = MagicMock()
+ mock_song.title = 'My Song'
+ mock_song.copyright = 'My copyright'
+ mock_song.book = MagicMock()
+ mock_song.book.name = "My songbook"
+ mock_song.song_number = 12
+ service_item = ServiceItem(None)
+
+ # WHEN: I generate the Footer with default settings
+ self.media_item.generate_footer(service_item, mock_song)
+
+ # THEN: The songbook should not be in the footer
+ self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright'])
+
+ # WHEN: I activate the "display songbook" option
+ self.media_item.display_songbook = True
+ self.media_item.generate_footer(service_item, mock_song)
+
+ # THEN: The songbook should be in the footer
+ self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'My songbook #12'])