← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~raoul-snyman/openlp/bug-1559336-2.4 into lp:openlp/2.4

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/bug-1559336-2.4 into lp:openlp/2.4.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1559336 in OpenLP: "Traceback error when attached media (to song) not found"
  https://bugs.launchpad.net/openlp/+bug/1559336

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/bug-1559336-2.4/+merge/293453

Show a message asking the user if they want to remove a file that doesn't exist
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/bug-1559336-2.4 into lp:openlp/2.4.
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2016-01-30 20:41:22 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2016-04-29 21:13:24 +0000
@@ -1054,8 +1054,23 @@
             filename = item.data(QtCore.Qt.UserRole)
             if not filename.startswith(save_path):
                 old_file, filename = filename, os.path.join(save_path, os.path.split(filename)[1])
-                shutil.copyfile(old_file, filename)
+                try:
+                    shutil.copyfile(old_file, filename)
+                except FileNotFoundError:
+                    # show a dialog
+                    button = QtWidgets.QMessageBox.critical(
+                        self,
+                        translate('SongsPlugin.EditSongForm', 'File not found'),
+                        translate('SongsPlugin.EditSongForm', 'Unable to find the following file:\n' +
+                                  '%s\nDo you want to remove the entry from the song?') % old_file,
+                        QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
+                        QtWidgets.QMessageBox.Yes
+                    )
+                    if button == QtWidgets.QMessageBox.Yes:
+                        # If they want the file removed, skip the rest and move onto the next file
+                        continue
             files.append(filename)
+            # Add the file to the media_file table
             media_file = MediaFile()
             media_file.file_name = filename
             media_file.type = 'audio'

=== modified file 'tests/functional/openlp_core_ui/test_firsttimeform.py'
--- tests/functional/openlp_core_ui/test_firsttimeform.py	2015-12-31 22:46:06 +0000
+++ tests/functional/openlp_core_ui/test_firsttimeform.py	2016-04-29 21:13:24 +0000
@@ -78,6 +78,23 @@
         if os.path.isfile(self.tempfile):
             os.remove(self.tempfile)
 
+    @patch('openlp.core.ui.firsttimewizard.is_macosx')
+    def constructor_macosx_test(self, mocked_is_macosx):
+        """
+        Test that the form is resized correctly on OS X
+        """
+        # GIVEN: The platform is OS X
+        mocked_is_macosx.return_value = True
+
+        # WHEN: The wizard is created
+        frw = FirstTimeForm(None)
+
+        # THEN: The form should have been resized
+        size = frw.size()
+        self.assertEqual(634, size.width())
+        self.assertEqual(386, size.height())
+
+
     def initialise_test(self):
         """
         Test if we can intialise the FirstTimeForm


Follow ups