forked from openlp/openlp
commit
ee4802735d
@ -135,16 +135,20 @@ class Manager(object):
|
||||
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()
|
||||
|
@ -290,7 +290,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
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))
|
||||
@ -350,7 +350,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user