forked from openlp/openlp
commit
ee4802735d
@ -135,15 +135,19 @@ class Manager(object):
|
|||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
self.session = init_schema(self.db_url)
|
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
|
Save an object to the database
|
||||||
|
|
||||||
``object_instance``
|
``object_instance``
|
||||||
The object to save
|
The object to save
|
||||||
|
|
||||||
|
``commit``
|
||||||
|
Commit the session with this object
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.session.add(object_instance)
|
self.session.add(object_instance)
|
||||||
|
if commit:
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
return True
|
return True
|
||||||
except InvalidRequestError:
|
except InvalidRequestError:
|
||||||
|
@ -290,7 +290,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||||
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
|
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
|
||||||
last_name=text.rsplit(u' ', 1)[1], display_name=text)
|
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)
|
self.song.authors.append(author)
|
||||||
author_item = QtGui.QListWidgetItem(
|
author_item = QtGui.QListWidgetItem(
|
||||||
unicode(author.display_name))
|
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.No,
|
||||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||||
topic = Topic.populate(name=text)
|
topic = Topic.populate(name=text)
|
||||||
self.songmanager.save_object(topic)
|
self.songmanager.save_object(topic, False)
|
||||||
self.song.topics.append(topic)
|
self.song.topics.append(topic)
|
||||||
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
||||||
topic_item.setData(QtCore.Qt.UserRole,
|
topic_item.setData(QtCore.Qt.UserRole,
|
||||||
|
Loading…
Reference in New Issue
Block a user