← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~meths/openlp/trivialfixes into lp:openlp

 

Jon Tibble has proposed merging lp:~meths/openlp/trivialfixes into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


Allow multiple new authors/topics to be created while creating a new song.
-- 
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/30424
Your team OpenLP Core is requested to review the proposed merge of lp:~meths/openlp/trivialfixes into lp:openlp.
=== modified file 'openlp/core/lib/db.py'
--- openlp/core/lib/db.py	2010-07-05 11:39:48 +0000
+++ openlp/core/lib/db.py	2010-07-20 15:24:47 +0000
@@ -135,16 +135,20 @@
         settings.endGroup()
         self.session = init_schema(self.db_url)
 
-    def save_object(self, object_instance):
+    def save_object(self, object_instance, commit=True):
         """
         Save an object to the database
 
         ``object_instance``
             The object to save
+
+        ``commit``
+            Commit the session with this object
         """
         try:
             self.session.add(object_instance)
-            self.session.commit()
+            if commit:
+                self.session.commit()
             return True
         except InvalidRequestError:
             self.session.rollback()

=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2010-07-20 11:02:03 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2010-07-20 15:24:47 +0000
@@ -290,7 +290,7 @@
                 QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
                 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.songmanager.save_object(author, False)
                 self.song.authors.append(author)
                 author_item = QtGui.QListWidgetItem(
                     unicode(author.display_name))
@@ -342,7 +342,7 @@
                 QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
                 QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
                 topic = Topic.populate(name=text)
-                self.songmanager.save_object(topic)
+                self.songmanager.save_object(topic, False)
                 self.song.topics.append(topic)
                 topic_item = QtGui.QListWidgetItem(unicode(topic.name))
                 topic_item.setData(QtCore.Qt.UserRole,


Follow ups