Azaziah has proposed merging lp:~suutari-olli/openlp/add-bible-license-field 
into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1557579 in OpenLP: "Make the song-footer text "Written by" optional"
  https://bugs.launchpad.net/openlp/+bug/1557579
  Bug #1623631 in OpenLP: "Add "Full License" field for Bibles"
  https://bugs.launchpad.net/openlp/+bug/1623631

For more details, see:
https://code.launchpad.net/~suutari-olli/openlp/add-bible-license-field/+merge/306048

In this branch:
- Added "Full License" field for Bibles (1623631)
- Added a setting for controlling visibility of "Written by:" (1557579)
- Added placeholder texts for Bible metadata fields
- Re-organized uistrings to alphabetical order


lp:~suutari-olli/openlp/add-bible-license-field (revision 2707)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1777/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1688/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1626/
[SUCCESS] 
https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1382/
[SUCCESS] 
https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/972/
[SUCCESS] https://ci.openlp.io/job/Branch-05a-Code_Analysis/1040/
[SUCCESS] https://ci.openlp.io/job/Branch-05b-Test_Coverage/908/
[SUCCESS] https://ci.openlp.io/job/Branch-05c-Code_Analysis2/71/
-- 
Your team OpenLP Core is requested to review the proposed merge of 
lp:~suutari-olli/openlp/add-bible-license-field into lp:openlp.
=== modified file 'openlp/core/common/uistrings.py'
--- openlp/core/common/uistrings.py	2016-08-10 18:31:33 +0000
+++ openlp/core/common/uistrings.py	2016-09-18 20:29:10 +0000
@@ -59,6 +59,13 @@
         self.Automatic = translate('OpenLP.Ui', 'Automatic')
         self.BackgroundColor = translate('OpenLP.Ui', 'Background Color')
         self.BackgroundColorColon = translate('OpenLP.Ui', 'Background color:')
+        self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short')
+        self.BibleShortSearch = translate('OpenLP.Ui', '<strong>The search you have entered is empty or shorter '
+                                                       'than 3 characters long.</strong><br><br>Please try again with '
+                                                       'a longer search.')
+        self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available')
+        self.BibleNoBibles = translate('OpenLP.Ui', '<strong>There are no Bibles currently installed.</strong><br><br>'
+                                                    'Please use the Import Wizard to install one or more Bibles.')
         self.Bottom = translate('OpenLP.Ui', 'Bottom')
         self.Browse = translate('OpenLP.Ui', 'Browse...')
         self.Cancel = translate('OpenLP.Ui', 'Cancel')
@@ -117,6 +124,8 @@
         self.OLPV2x = "{name} {version}".format(name=self.OLP, version="2.4")
         self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?')
         self.OpenService = translate('OpenLP.Ui', 'Open service.')
+        self.OptionalShowInFooter = translate('OpenLP.Ui', 'Optional, this will be displayed in footer.')
+        self.OptionalHideInFooter = translate('OpenLP.Ui', 'Optional, this won\'t be displayed in footer.')
         self.PlaySlidesInLoop = translate('OpenLP.Ui', 'Play Slides in Loop')
         self.PlaySlidesToEnd = translate('OpenLP.Ui', 'Play Slides to End')
         self.Preview = translate('OpenLP.Ui', 'Preview')
@@ -130,6 +139,7 @@
                                                             'player is disabled.')
         self.ResetBG = translate('OpenLP.Ui', 'Reset Background')
         self.ResetLiveBG = translate('OpenLP.Ui', 'Reset live background.')
+        self.RequiredShowInFooter = translate('OpenLP.Ui', 'Required, this will be displayed in footer.')
         self.Seconds = translate('OpenLP.Ui', 's', 'The abbreviated unit for seconds')
         self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview')
         self.Search = translate('OpenLP.Ui', 'Search')
@@ -157,13 +167,6 @@
         self.View = translate('OpenLP.Ui', 'View')
         self.ViewMode = translate('OpenLP.Ui', 'View Mode')
         self.Video = translate('OpenLP.Ui', 'Video')
-        self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short')
-        self.BibleShortSearch = translate('OpenLP.Ui', '<strong>The search you have entered is empty or shorter '
-                                                       'than 3 characters long.</strong><br><br>Please try again with '
-                                                       'a longer search.')
-        self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available')
-        self.BibleNoBibles = translate('OpenLP.Ui', '<strong>There are no Bibles currently installed.</strong><br><br>'
-                                                    'Please use the Import Wizard to install one or more Bibles.')
         book_chapter = translate('OpenLP.Ui', 'Book Chapter')
         chapter = translate('OpenLP.Ui', 'Chapter')
         verse = translate('OpenLP.Ui', 'Verse')

=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
--- openlp/plugins/bibles/forms/bibleimportform.py	2016-08-29 16:11:09 +0000
+++ openlp/plugins/bibles/forms/bibleimportform.py	2016-09-18 20:29:10 +0000
@@ -380,6 +380,12 @@
         self.permissions_edit = QtWidgets.QLineEdit(self.license_details_page)
         self.permissions_edit.setObjectName('PermissionsEdit')
         self.license_details_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.permissions_edit)
+        self.full_license_label = QtWidgets.QLabel(self.license_details_page)
+        self.full_license_label.setObjectName('FullLicenseLabel')
+        self.license_details_layout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.full_license_label)
+        self.full_license_edit = QtWidgets.QPlainTextEdit(self.license_details_page)
+        self.full_license_edit.setObjectName('FullLicenseEdit')
+        self.license_details_layout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.full_license_edit)
         self.addPage(self.license_details_page)
 
     def retranslateUi(self):
@@ -450,6 +456,7 @@
         self.version_name_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
         self.copyright_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
         self.permissions_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
+        self.full_license_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Full license:'))
         self.progress_page.setTitle(WizardStrings.Importing)
         self.progress_page.setSubTitle(translate('BiblesPlugin.ImportWizardForm',
                                                  'Please wait while your Bible is imported.'))
@@ -473,6 +480,7 @@
         elif self.currentPage() == self.select_page:
             self.version_name_edit.clear()
             self.permissions_edit.clear()
+            self.full_license_edit.clear()
             self.copyright_edit.clear()
             if self.field('source_format') == BibleFormat.OSIS:
                 if not self.field('osis_location'):
@@ -717,6 +725,7 @@
         self.license_details_page.registerField('license_version', self.version_name_edit)
         self.license_details_page.registerField('license_copyright', self.copyright_edit)
         self.license_details_page.registerField('license_permissions', self.permissions_edit)
+        self.license_details_page.registerField("license_full_license", self.full_license_edit, "plainText")
 
     def set_defaults(self):
         """
@@ -741,8 +750,13 @@
         self.setField('proxy_username', settings.value('proxy username'))
         self.setField('proxy_password', settings.value('proxy password'))
         self.setField('license_version', self.version_name_edit.text())
+        self.version_name_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
         self.setField('license_copyright', self.copyright_edit.text())
+        self.copyright_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
         self.setField('license_permissions', self.permissions_edit.text())
+        self.permissions_edit.setPlaceholderText(UiStrings().OptionalShowInFooter)
+        self.setField('license_full_license', self.full_license_edit.toPlainText())
+        self.full_license_edit.setPlaceholderText(UiStrings().OptionalHideInFooter)
         self.on_web_source_combo_box_index_changed(WebDownload.Crosswalk)
         settings.endGroup()
 
@@ -766,6 +780,7 @@
         license_version = self.field('license_version')
         license_copyright = self.field('license_copyright')
         license_permissions = self.field('license_permissions')
+        license_full_license = self.field('license_full_license')
         importer = None
         if bible_type == BibleFormat.OSIS:
             # Import an OSIS bible.
@@ -811,10 +826,10 @@
                                                      sword_path=self.field('sword_zip_path'),
                                                      sword_key=self.sword_zipbible_combo_box.itemData(
                                                          self.sword_zipbible_combo_box.currentIndex()))
-
         try:
             if importer.do_import(license_version) and not importer.stop_import_flag:
-                self.manager.save_meta_data(license_version, license_version, license_copyright, license_permissions)
+                self.manager.save_meta_data(license_version, license_version,
+                                            license_copyright, license_permissions, license_full_license)
                 self.manager.reload_bibles()
                 if bible_type == BibleFormat.WebDownload:
                     self.progress_label.setText(

=== modified file 'openlp/plugins/bibles/forms/editbibledialog.py'
--- openlp/plugins/bibles/forms/editbibledialog.py	2016-06-08 20:26:01 +0000
+++ openlp/plugins/bibles/forms/editbibledialog.py	2016-09-18 20:29:10 +0000
@@ -68,6 +68,12 @@
         self.permissions_edit.setObjectName('permissions_edit')
         self.permissions_label.setBuddy(self.permissions_edit)
         self.license_details_layout.addRow(self.permissions_label, self.permissions_edit)
+        self.full_license_label = QtWidgets.QLabel(self.license_details_group_box)
+        self.full_license_label.setObjectName('full_license_label')
+        self.full_license_edit = QtWidgets.QPlainTextEdit(self.license_details_group_box)
+        self.full_license_edit.setObjectName('full_license_edit')
+        self.full_license_label.setBuddy(self.full_license_edit)
+        self.license_details_layout.addRow(self.full_license_label, self.full_license_edit)
         self.meta_tab_layout.addWidget(self.license_details_group_box)
         self.language_selection_group_box = QtWidgets.QGroupBox(self.meta_tab)
         self.language_selection_group_box.setObjectName('language_selection_group_box')
@@ -132,6 +138,7 @@
         self.version_name_label.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:'))
         self.copyright_label.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:'))
         self.permissions_label.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:'))
+        self.full_license_label.setText(translate('BiblesPlugin.EditBibleForm', 'Full license:'))
         self.language_selection_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language'))
         self.language_selection_label.setText(
             translate('BiblesPlugin.EditBibleForm', 'Book name language in search field, search results and '

=== modified file 'openlp/plugins/bibles/forms/editbibleform.py'
--- openlp/plugins/bibles/forms/editbibleform.py	2016-05-21 08:31:24 +0000
+++ openlp/plugins/bibles/forms/editbibleform.py	2016-09-18 20:29:10 +0000
@@ -61,10 +61,24 @@
         """
         log.debug('Load Bible')
         self.bible = bible
-        self.version_name_edit.setText(self.manager.get_meta_data(self.bible, 'name').value)
-        self.copyright_edit.setText(self.manager.get_meta_data(self.bible, 'copyright').value)
-        self.permissions_edit.setText(self.manager.get_meta_data(self.bible, 'permissions').value)
-        book_name_language = self.manager.get_meta_data(self.bible, 'book_name_language')
+        """
+        Try loading the metadata, if the field does not exist in the metadata, continue executing the code,
+        missing fields will be created on "self.accept" (save). Also set "book_name_language",
+        there would otherwise be a traceback for reference before assignment.
+        """
+        try:
+            self.version_name_edit.setText(self.manager.get_meta_data(self.bible, 'name').value)
+            self.version_name_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
+            self.copyright_edit.setText(self.manager.get_meta_data(self.bible, 'copyright').value)
+            self.copyright_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
+            self.permissions_edit.setText(self.manager.get_meta_data(self.bible, 'permissions').value)
+            self.permissions_edit.setPlaceholderText(UiStrings().OptionalShowInFooter)
+            self.full_license_edit.setPlainText(self.manager.get_meta_data(self.bible, 'full_license').value)
+            self.full_license_edit.setPlaceholderText(UiStrings().OptionalHideInFooter)
+            book_name_language = self.manager.get_meta_data(self.bible, 'book_name_language')
+        except AttributeError:
+            book_name_language = self.manager.get_meta_data(self.bible, 'book_name_language')
+            pass
         if book_name_language and book_name_language.value != 'None':
             self.language_selection_combo_box.setCurrentIndex(int(book_name_language.value) + 1)
         self.books = {}
@@ -107,6 +121,7 @@
         version = self.version_name_edit.text()
         copyright = self.copyright_edit.text()
         permissions = self.permissions_edit.text()
+        full_license = self.full_license_edit.toPlainText()
         book_name_language = self.language_selection_combo_box.currentIndex() - 1
         if book_name_language == -1:
             book_name_language = None
@@ -121,7 +136,7 @@
                         if not self.validate_book(custom_names[abbr], abbr):
                             return
         self.application.set_busy_cursor()
-        self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language)
+        self.manager.save_meta_data(self.bible, version, copyright, permissions, full_license, book_name_language)
         if not self.web_bible:
             for abbr, book in self.books.items():
                 if book:

=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py	2016-09-04 16:15:57 +0000
+++ openlp/plugins/bibles/lib/manager.py	2016-09-18 20:29:10 +0000
@@ -376,17 +376,17 @@
         else:
             return None
 
-    def save_meta_data(self, bible, version, copyright, permissions, book_name_language=None):
+    def save_meta_data(self, bible, version, copyright, permissions, full_license, book_name_language=None):
         """
         Saves the bibles meta data.
         """
-        log.debug('save_meta data {bible}, {version}, {copyright}, {perms}'.format(bible=bible,
-                                                                                   version=version,
-                                                                                   copyright=copyright,
-                                                                                   perms=permissions))
+        log.debug('save_meta data {bible}, {version}, {copyright},'
+                  ' {perms}, {full_license}'.format(bible=bible, version=version, copyright=copyright,
+                                                    perms=permissions, full_license=full_license))
         self.db_cache[bible].save_meta('name', version)
         self.db_cache[bible].save_meta('copyright', copyright)
         self.db_cache[bible].save_meta('permissions', permissions)
+        self.db_cache[bible].save_meta('full_license', full_license)
         self.db_cache[bible].save_meta('book_name_language', book_name_language)
 
     def get_meta_data(self, bible, key):

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2016-06-08 20:26:01 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2016-09-18 20:29:10 +0000
@@ -126,6 +126,7 @@
         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.display_songbook = Settings().value(self.settings_section + '/display songbook')
+        self.display_written_by_text = Settings().value(self.settings_section + '/display written by')
         self.display_copyright_symbol = Settings().value(self.settings_section + '/display copyright symbol')
 
     def retranslateUi(self):
@@ -646,8 +647,12 @@
         item.raw_footer = []
         item.raw_footer.append(song.title)
         if authors_none:
-            item.raw_footer.append("{text}: {authors}".format(text=translate('OpenLP.Ui', 'Written by'),
-                                                              authors=create_separated_list(authors_none)))
+            # If the setting for showing "Written by:" is enabled, show it before unspecified authors.
+            if Settings().value('songs/display written by'):
+                item.raw_footer.append("{text}: {authors}".format(text=translate('OpenLP.Ui', 'Written by'),
+                                                                  authors=create_separated_list(authors_none)))
+            else:
+                item.raw_footer.append("{authors}".format(authors=create_separated_list(authors_none)))
         if authors_words_music:
             item.raw_footer.append("{text}: {authors}".format(text=AuthorType.Types[AuthorType.WordsAndMusic],
                                                               authors=create_separated_list(authors_words_music)))

=== modified file 'openlp/plugins/songs/lib/songstab.py'
--- openlp/plugins/songs/lib/songstab.py	2016-07-24 20:20:25 +0000
+++ openlp/plugins/songs/lib/songstab.py	2016-09-18 20:29:10 +0000
@@ -53,6 +53,9 @@
         self.display_songbook_check_box = QtWidgets.QCheckBox(self.mode_group_box)
         self.display_songbook_check_box.setObjectName('songbook_check_box')
         self.mode_layout.addWidget(self.display_songbook_check_box)
+        self.display_written_by_check_box = QtWidgets.QCheckBox(self.mode_group_box)
+        self.display_written_by_check_box.setObjectName('written_by_check_box')
+        self.mode_layout.addWidget(self.display_written_by_check_box)
         self.display_copyright_check_box = QtWidgets.QCheckBox(self.mode_group_box)
         self.display_copyright_check_box.setObjectName('copyright_check_box')
         self.mode_layout.addWidget(self.display_copyright_check_box)
@@ -63,16 +66,19 @@
         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)
+        self.display_written_by_check_box.stateChanged.connect(self.on_written_by_check_box_changed)
         self.display_copyright_check_box.stateChanged.connect(self.on_copyright_check_box_changed)
 
     def retranslateUi(self):
-        self.mode_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Songs Mode'))
+        self.mode_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Song related settings'))
         self.tool_bar_active_check_box.setText(translate('SongsPlugin.SongsTab',
                                                          'Enable "Go to verse" button in Live panel'))
         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'))
+        self.display_written_by_check_box.setText(translate(
+            'SongsPlugin.SongsTab', 'Show "Written by:" in footer for unspecified authors'))
         self.display_copyright_check_box.setText(translate('SongsPlugin.SongsTab',
                                                            'Display "{symbol}" symbol before copyright '
                                                            'info').format(symbol=SongStrings.CopyrightSymbol))
@@ -92,6 +98,9 @@
     def on_songbook_check_box_changed(self, check_state):
         self.display_songbook = (check_state == QtCore.Qt.Checked)
 
+    def on_written_by_check_box_changed(self, check_state):
+        self.display_written_by = (check_state == QtCore.Qt.Checked)
+
     def on_copyright_check_box_changed(self, check_state):
         self.display_copyright_symbol = (check_state == QtCore.Qt.Checked)
 
@@ -102,11 +111,13 @@
         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.display_written_by = settings.value('display written by')
         self.display_copyright_symbol = settings.value('display copyright symbol')
         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)
+        self.display_written_by_check_box.setChecked(self.display_written_by)
         self.display_copyright_check_box.setChecked(self.display_copyright_symbol)
         settings.endGroup()
 
@@ -117,6 +128,7 @@
         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.setValue('display written by', self.display_written_by)
         settings.setValue('display copyright symbol', self.display_copyright_symbol)
         settings.endGroup()
         if self.tab_visited:

=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py	2016-03-31 16:34:22 +0000
+++ openlp/plugins/songs/songsplugin.py	2016-09-18 20:29:10 +0000
@@ -59,6 +59,7 @@
     'songs/add song from service': True,
     'songs/display songbar': True,
     'songs/display songbook': False,
+    'songs/display written by': False,
     'songs/display copyright symbol': False,
     'songs/last directory import': '',
     'songs/last directory export': '',

=== modified file 'tests/functional/openlp_plugins/songs/test_mediaitem.py'
--- tests/functional/openlp_plugins/songs/test_mediaitem.py	2016-05-31 21:40:13 +0000
+++ tests/functional/openlp_plugins/songs/test_mediaitem.py	2016-09-18 20:29:10 +0000
@@ -295,11 +295,18 @@
             mock_qlist_widget.setData.assert_called_once_with(MockedUserRole, mock_song.id)
             self.media_item.list_view.addItem.assert_called_once_with(mock_qlist_widget)
 
-    def test_build_song_footer_one_author(self):
+    @patch(u'openlp.plugins.songs.lib.mediaitem.Settings')
+    def test_build_song_footer_one_author_show_written_by(self, MockedSettings):
         """
         Test build songs footer with basic song and one author
         """
-        # GIVEN: A Song and a Service Item
+        # GIVEN: A Song and a Service Item, mocked settings: True for 'songs/display written by'
+        # and False for 'core/ccli number' (ccli will cause traceback if true)
+
+        mocked_settings = MagicMock()
+        mocked_settings.value.side_effect = [True, False]
+        MockedSettings.return_value = mocked_settings
+
         mock_song = MagicMock()
         mock_song.title = 'My Song'
         mock_song.authors_songs = []

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to