← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/trivial into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/trivial into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


Hello

I changed "songmanager" to "manager". Also I fixed a traceback (which occurs when you click on "Save & Preview" a second time):

Traceback (most recent call last):
  File "/home/andreas/Projekte/openlp/trunk/openlp/plugins/songs/forms/editsongform.py", line 601, in onPreview
    if unicode(button.objectName()) == u'previewButton' and self.saveSong():
  File "/home/andreas/Projekte/openlp/trunk/openlp/plugins/songs/forms/editsongform.py", line 634, in saveSong
    self.song.title = unicode(self.TitleEditItem.text())
AttributeError: 'NoneType' object has no attribute 'title'

-- 
https://code.launchpad.net/~googol-hush/openlp/trivial/+merge/40001
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/trivial into lp:openlp.
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2010-10-10 12:14:12 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2010-11-03 18:36:26 +0000
@@ -43,7 +43,7 @@
     """
     log.info(u'%s EditSongForm loaded', __name__)
 
-    def __init__(self, parent, songmanager):
+    def __init__(self, parent, manager):
         """
         Constructor
         """
@@ -100,7 +100,7 @@
         QtCore.QObject.connect(self.ButtonBox,
             QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
         # Create other objects and forms
-        self.songmanager = songmanager
+        self.manager = manager
         self.verse_form = EditVerseForm(self)
         self.initialise()
         self.AuthorsListView.setSortingEnabled(False)
@@ -116,7 +116,7 @@
         self.TopicRemoveButton.setEnabled(False)
 
     def loadAuthors(self):
-        authors = self.songmanager.get_all_objects(Author,
+        authors = self.manager.get_all_objects(Author,
             order_by_ref=Author.display_name)
         self.AuthorsSelectionComboItem.clear()
         self.AuthorsSelectionComboItem.addItem(u'')
@@ -127,8 +127,7 @@
                 row, QtCore.QVariant(author.id))
 
     def loadTopics(self):
-        topics = self.songmanager.get_all_objects(Topic,
-            order_by_ref=Topic.name)
+        topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name)
         self.SongTopicCombo.clear()
         self.SongTopicCombo.addItem(u'')
         for topic in topics:
@@ -137,7 +136,7 @@
             self.SongTopicCombo.setItemData(row, QtCore.QVariant(topic.id))
 
     def loadBooks(self):
-        books = self.songmanager.get_all_objects(Book, order_by_ref=Book.name)
+        books = self.manager.get_all_objects(Book, order_by_ref=Book.name)
         self.SongbookCombo.clear()
         self.SongbookCombo.addItem(u'')
         for book in books:
@@ -177,15 +176,14 @@
         self.loadAuthors()
         self.loadTopics()
         self.loadBooks()
-        self.song = self.songmanager.get_object(Song, id)
+        self.song = self.manager.get_object(Song, id)
         self.TitleEditItem.setText(self.song.title)
         if self.song.alternate_title:
             self.AlternativeEdit.setText(self.song.alternate_title)
         else:
             self.AlternativeEdit.setText(u'')
         if self.song.song_book_id != 0:
-            book_name = self.songmanager.get_object(Book,
-                self.song.song_book_id)
+            book_name = self.manager.get_object(Book, self.song.song_book_id)
             id = self.SongbookCombo.findText(
                 unicode(book_name.name), QtCore.Qt.MatchExactly)
             if id == -1:
@@ -299,7 +297,7 @@
                 else:
                     author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
                         last_name=text.rsplit(u' ', 1)[1], display_name=text)
-                self.songmanager.save_object(author)
+                self.manager.save_object(author)
                 author_item = QtGui.QListWidgetItem(
                     unicode(author.display_name))
                 author_item.setData(QtCore.Qt.UserRole,
@@ -311,7 +309,7 @@
                 return
         elif item > 0:
             item_id = (self.AuthorsSelectionComboItem.itemData(item)).toInt()[0]
-            author = self.songmanager.get_object(Author, item_id)
+            author = self.manager.get_object(Author, item_id)
             if self.AuthorsListView.findItems(unicode(author.display_name),
                 QtCore.Qt.MatchExactly):
                 QtGui.QMessageBox.warning(self,
@@ -354,7 +352,7 @@
                 QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
                 QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
                 topic = Topic.populate(name=text)
-                self.songmanager.save_object(topic)
+                self.manager.save_object(topic)
                 topic_item = QtGui.QListWidgetItem(unicode(topic.name))
                 topic_item.setData(QtCore.Qt.UserRole,
                     QtCore.QVariant(topic.id))
@@ -365,7 +363,7 @@
                 return
         elif item > 0:
             item_id = (self.SongTopicCombo.itemData(item)).toInt()[0]
-            topic = self.songmanager.get_object(Topic, item_id)
+            topic = self.manager.get_object(Topic, item_id)
             if self.TopicsListView.findItems(unicode(topic.name),
                 QtCore.Qt.MatchExactly):
                 QtGui.QMessageBox.warning(self,
@@ -598,7 +596,8 @@
         The Song is valid so as the plugin to add it to preview to see.
         """
         log.debug(u'onPreview')
-        if unicode(button.objectName()) == u'previewButton' and self.saveSong():
+        if unicode(button.objectName()) == u'previewButton' and \
+            self.saveSong(True):
             Receiver.send_message(u'songs_preview')
 
     def closePressed(self):
@@ -619,17 +618,20 @@
                 QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
                 QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
                 book = Book.populate(name=text, publisher=u'')
-                self.songmanager.save_object(book)
+                self.manager.save_object(book)
             else:
                 return
         if self.saveSong():
             Receiver.send_message(u'songs_load_list')
             self.close()
 
-    def saveSong(self):
+    def saveSong(self, preview=False):
         """
         Get all the data from the widgets on the form, and then save it to the
         database.
+
+        ``preview`` 
+            Should be True if song is also previewed.
         """
         self.song.title = unicode(self.TitleEditItem.text())
         self.song.alternate_title = unicode(self.AlternativeEdit.text())
@@ -642,7 +644,7 @@
         self.song.song_number = unicode(self.songBookNumberEdit.text())
         book_name = unicode(self.SongbookCombo.currentText())
         if book_name:
-            self.song.book = self.songmanager.get_object_filtered(Book,
+            self.song.book = self.manager.get_object_filtered(Book,
                 Book.name == book_name)
         else:
             self.song.book = None
@@ -653,16 +655,16 @@
             for row in range(self.AuthorsListView.count()):
                 item = self.AuthorsListView.item(row)
                 authorId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
-                self.song.authors.append(self.songmanager.get_object(Author,
+                self.song.authors.append(self.manager.get_object(Author,
                     authorId))
             self.song.topics = []
             for row in range(self.TopicsListView.count()):
                 item = self.TopicsListView.item(row)
                 topicId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
-                self.song.topics.append(self.songmanager.get_object(Topic,
-                    topicId))
-            self.songmanager.save_object(self.song)
-            self.song = None
+                self.song.topics.append(self.manager.get_object(Topic, topicId))
+            self.manager.save_object(self.song)
+            if not preview:
+                self.song = None
             return True
         return False
 

=== modified file 'openlp/plugins/songs/forms/songmaintenanceform.py'
--- openlp/plugins/songs/forms/songmaintenanceform.py	2010-09-19 08:47:00 +0000
+++ openlp/plugins/songs/forms/songmaintenanceform.py	2010-11-03 18:36:26 +0000
@@ -36,13 +36,13 @@
     """
     Class documentation goes here.
     """
-    def __init__(self, songmanager, parent=None):
+    def __init__(self, manager, parent=None):
         """
         Constructor
         """
         QtGui.QDialog.__init__(self, parent)
         self.setupUi(self)
-        self.songmanager = songmanager
+        self.manager = manager
         self.authorform = AuthorsForm(self)
         self.topicform = TopicsForm(self)
         self.bookform = SongBookForm(self)
@@ -85,12 +85,12 @@
         del_text, err_text, sel_text):
         item_id = self._getCurrentItemId(list_widget)
         if item_id != -1:
-            item = self.songmanager.get_object(item_class, item_id)
+            item = self.manager.get_object(item_class, item_id)
             if item and len(item.songs) == 0:
                 if QtGui.QMessageBox.warning(self, dlg_title, del_text,
                     QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
                     QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
-                    self.songmanager.delete_object(item_class, item.id)
+                    self.manager.delete_object(item_class, item.id)
                     reset_func()
             else:
                 QtGui.QMessageBox.critical(self, dlg_title, err_text)
@@ -102,7 +102,7 @@
         Reloads the Authors list.
         """
         self.AuthorsListWidget.clear()
-        authors = self.songmanager.get_all_objects(Author,
+        authors = self.manager.get_all_objects(Author,
             order_by_ref=Author.display_name)
         for author in authors:
             if author.display_name:
@@ -124,8 +124,7 @@
         Reloads the Topics list.
         """
         self.TopicsListWidget.clear()
-        topics = self.songmanager.get_all_objects(Topic,
-            order_by_ref=Topic.name)
+        topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name)
         for topic in topics:
             topic_name = QtGui.QListWidgetItem(topic.name)
             topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
@@ -142,7 +141,7 @@
         Reloads the Books list.
         """
         self.BooksListWidget.clear()
-        books = self.songmanager.get_all_objects(Book, order_by_ref=Book.name)
+        books = self.manager.get_all_objects(Book, order_by_ref=Book.name)
         for book in books:
             book_name = QtGui.QListWidgetItem(u'%s (%s)' % (book.name,
                 book.publisher))
@@ -160,7 +159,7 @@
         Returns False if the given Author is already in the list otherwise
         True.
         """
-        authors = self.songmanager.get_all_objects(Author,
+        authors = self.manager.get_all_objects(Author,
             and_(Author.first_name == new_author.first_name,
                 Author.last_name == new_author.last_name,
                 Author.display_name == new_author.display_name))
@@ -182,7 +181,7 @@
         """
         Returns False if the given Topic is already in the list otherwise True.
         """
-        topics = self.songmanager.get_all_objects(Topic,
+        topics = self.manager.get_all_objects(Topic,
             Topic.name == new_topic.name)
         if len(topics) > 0:
             # If we edit an existing Topic, we need to make sure that we do
@@ -202,7 +201,7 @@
         """
         Returns False if the given Book is already in the list otherwise True.
         """
-        books = self.songmanager.get_all_objects(Book,
+        books = self.manager.get_all_objects(Book,
             and_(Book.name == new_book.name,
                 Book.publisher == new_book.publisher))
         if len(books) > 0:
@@ -227,7 +226,7 @@
                 last_name=unicode(self.authorform.LastNameEdit.text()),
                 display_name=unicode(self.authorform.DisplayEdit.text()))
             if self.checkAuthor(author):
-                if self.songmanager.save_object(author):
+                if self.manager.save_object(author):
                     self.resetAuthors()
                 else:
                     QtGui.QMessageBox.critical(self,
@@ -244,7 +243,7 @@
         if self.topicform.exec_():
             topic = Topic.populate(name=unicode(self.topicform.NameEdit.text()))
             if self.checkTopic(topic):
-                if self.songmanager.save_object(topic):
+                if self.manager.save_object(topic):
                     self.resetTopics()
                 else:
                     QtGui.QMessageBox.critical(self,
@@ -262,7 +261,7 @@
             book = Book.populate(name=unicode(self.bookform.NameEdit.text()),
                 publisher=unicode(self.bookform.PublisherEdit.text()))
             if self.checkBook(book):
-                if self.songmanager.save_object(book):
+                if self.manager.save_object(book):
                     self.resetBooks()
                 else:
                     QtGui.QMessageBox.critical(self,
@@ -278,7 +277,7 @@
     def onAuthorEditButtonClick(self):
         author_id = self._getCurrentItemId(self.AuthorsListWidget)
         if author_id != -1:
-            author = self.songmanager.get_object(Author, author_id)
+            author = self.manager.get_object(Author, author_id)
             self.authorform.setAutoDisplayName(False)
             self.authorform.FirstNameEdit.setText(author.first_name)
             self.authorform.LastNameEdit.setText(author.last_name)
@@ -295,7 +294,7 @@
                 author.display_name = unicode(
                     self.authorform.DisplayEdit.text())
                 if self.checkAuthor(author, True):
-                    if self.songmanager.save_object(author):
+                    if self.manager.save_object(author):
                         self.resetAuthors()
                         Receiver.send_message(u'songs_load_list')
                     else:
@@ -330,14 +329,14 @@
     def onTopicEditButtonClick(self):
         topic_id = self._getCurrentItemId(self.TopicsListWidget)
         if topic_id != -1:
-            topic = self.songmanager.get_object(Topic, topic_id)
+            topic = self.manager.get_object(Topic, topic_id)
             self.topicform.NameEdit.setText(topic.name)
             # Save the topic's name for the case that he has to be restored.
             temp_name = topic.name
             if self.topicform.exec_(False):
                 topic.name = unicode(self.topicform.NameEdit.text())
                 if self.checkTopic(topic, True):
-                    if self.songmanager.save_object(topic):
+                    if self.manager.save_object(topic):
                         self.resetTopics()
                     else:
                         QtGui.QMessageBox.critical(self,
@@ -367,7 +366,7 @@
     def onBookEditButtonClick(self):
         book_id = self._getCurrentItemId(self.BooksListWidget)
         if book_id != -1:
-            book = self.songmanager.get_object(Book, book_id)
+            book = self.manager.get_object(Book, book_id)
             if book.publisher is None:
                 book.publisher = u''
             self.bookform.NameEdit.setText(book.name)
@@ -380,7 +379,7 @@
                 book.name = unicode(self.bookform.NameEdit.text())
                 book.publisher = unicode(self.bookform.PublisherEdit.text())
                 if self.checkBook(book, True):
-                    if self.songmanager.save_object(book):
+                    if self.manager.save_object(book):
                         self.resetBooks()
                     else:
                         QtGui.QMessageBox.critical(self,
@@ -410,11 +409,11 @@
         ``old_author``
             The author which will be deleted afterwards.
         """
-        existing_author = self.songmanager.get_object_filtered(Author,
+        existing_author = self.manager.get_object_filtered(Author,
             and_(Author.first_name == old_author.first_name,
                 Author.last_name == old_author.last_name, 
                 Author.display_name == old_author.display_name))
-        songs = self.songmanager.get_all_objects(Song,
+        songs = self.manager.get_all_objects(Song,
             Song.authors.contains(old_author))
         for song in songs:
             # We check if the song has already existing_author as author. If
@@ -422,8 +421,8 @@
             if existing_author not in song.authors:
                 song.authors.append(existing_author)
             song.authors.remove(old_author)
-            self.songmanager.save_object(song)
-        self.songmanager.delete_object(Author, old_author.id)
+            self.manager.save_object(song)
+        self.manager.delete_object(Author, old_author.id)
 
     def mergeTopics(self, old_topic):
         """
@@ -432,9 +431,9 @@
         ``old_topic``
             The topic which will be deleted afterwards.
         """
-        existing_topic = self.songmanager.get_object_filtered(Topic,
+        existing_topic = self.manager.get_object_filtered(Topic,
             Topic.name == old_topic.name)
-        songs = self.songmanager.get_all_objects(Song,
+        songs = self.manager.get_all_objects(Song,
             Song.topics.contains(old_topic))
         for song in songs:
             # We check if the song has already existing_topic as topic. If that
@@ -442,8 +441,8 @@
             if existing_topic not in song.topics:
                 song.topics.append(existing_topic)
             song.topics.remove(old_topic)
-            self.songmanager.save_object(song)
-        self.songmanager.delete_object(Topic, old_topic.id)
+            self.manager.save_object(song)
+        self.manager.delete_object(Topic, old_topic.id)
 
     def mergeBooks(self, old_book):
         """
@@ -452,15 +451,15 @@
         ``old_book``
             The book which will be deleted afterwards.
         """
-        existing_book = self.songmanager.get_object_filtered(Book,
+        existing_book = self.manager.get_object_filtered(Book,
             and_(Book.name == old_book.name,
                 Book.publisher == old_book.publisher))
-        songs = self.songmanager.get_all_objects(Song,
+        songs = self.manager.get_all_objects(Song,
             Song.song_book_id == old_book.id)
         for song in songs:
             song.song_book_id = existing_book.id
-            self.songmanager.save_object(song)
-        self.songmanager.delete_object(Book, old_book.id)
+            self.manager.save_object(song)
+        self.manager.delete_object(Book, old_book.id)
 
     def onAuthorDeleteButtonClick(self):
         """

=== modified file 'openlp/plugins/songs/lib/songimport.py'
--- openlp/plugins/songs/lib/songimport.py	2010-09-27 18:34:40 +0000
+++ openlp/plugins/songs/lib/songimport.py	2010-11-03 18:36:26 +0000
@@ -47,8 +47,9 @@
         """
         Initialise and create defaults for properties
 
-        song_manager is an instance of a SongManager, through which all
-        database access is performed
+        ``manager``
+            An instance of a SongManager, through which all database access is
+            performed.
         """
         self.manager = manager
         self.stop_import_flag = False


Follow ups