forked from openlp/openlp
Fix up song migration code so we only have 1 author
Fix up Songedit dialog to refesh lists on entry Fix up meta data bug
This commit is contained in:
parent
37b05517f1
commit
eb47246f18
@ -137,8 +137,7 @@ class MigrateSongs():
|
||||
self.db_url = u'sqlite:///' + self.data_path + u'/songs.sqlite'
|
||||
print self.db_url
|
||||
self.session = init_models(self.db_url)
|
||||
if not songs_table.exists():
|
||||
metadata.create_all()
|
||||
metadata.create_all(checkfirst=True)
|
||||
results = self.session.query(TSong).order_by(TSong.songid).all()
|
||||
for songs_temp in results:
|
||||
song = Song()
|
||||
@ -151,18 +150,21 @@ class MigrateSongs():
|
||||
aa = self.session.execute(u'select * from songauthors_temp where songid =' + unicode(songs_temp.songid) )
|
||||
for row in aa:
|
||||
a = row['authorid']
|
||||
author = Author()
|
||||
authors_temp = self.session.query(TAuthor).get(a)
|
||||
author.display_name = authors_temp.authorname
|
||||
author.first_name = u''
|
||||
author.last_name = u''
|
||||
bb = self.session.execute(u'select * from authors where display_name = \"%s\"' % unicode(authors_temp.authorname) ).fetchone()
|
||||
if bb is None:
|
||||
author = Author()
|
||||
author.display_name = authors_temp.authorname
|
||||
else:
|
||||
id = int(bb[0])
|
||||
author = self.session.query(Author).get(bb[0])
|
||||
song.authors.append(author)
|
||||
try:
|
||||
self.session.add(song)
|
||||
self.session.commit()
|
||||
except:
|
||||
self.session.rollback()
|
||||
print u'Errow thrown = ', sys.exc_info()[1]
|
||||
try:
|
||||
self.session.add(song)
|
||||
self.session.commit()
|
||||
except:
|
||||
self.session.rollback()
|
||||
print u'Errow thrown = ', sys.exc_info()[1]
|
||||
|
||||
def _v1_9_0_cleanup(self, database):
|
||||
self.display.sub_output(u'Update Internal Data ' + database)
|
||||
@ -184,5 +186,4 @@ class MigrateSongs():
|
||||
conn.execute(u'drop table songauthors_temp;')
|
||||
conn.commit()
|
||||
conn.execute(u'drop table settings;')
|
||||
|
||||
conn.commit()
|
||||
|
@ -86,9 +86,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.TopicsListView.setAlternatingRowColors(True)
|
||||
|
||||
def initialise(self):
|
||||
self.loadAuthors()
|
||||
self.loadTopics()
|
||||
self.loadBooks()
|
||||
self.EditButton.setEnabled(False)
|
||||
self.DeleteButton.setEnabled(False)
|
||||
self.AuthorRemoveItem.setEnabled(False)
|
||||
@ -140,9 +137,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.TopicsListView.clear()
|
||||
self.title_change = False
|
||||
self.TitleEditItem.setFocus(QtCore.Qt.OtherFocusReason)
|
||||
self.loadAuthors()
|
||||
self.loadTopics()
|
||||
self.loadBooks()
|
||||
|
||||
def loadSong(self, id):
|
||||
log.debug(u'Load Song')
|
||||
self.loadAuthors()
|
||||
self.loadTopics()
|
||||
self.loadBooks()
|
||||
self.song = self.songmanager.get_song(id)
|
||||
self.TitleEditItem.setText(self.song.title)
|
||||
title = self.song.search_title.split(u'@')
|
||||
@ -304,7 +307,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.verse_form.setVerse(item.text())
|
||||
self.verse_form.exec_()
|
||||
item.setText(self.verse_form.getVerse())
|
||||
self.VerseListWidget.update()
|
||||
self.VerseListWidget.repaint()
|
||||
self.EditButton.setEnabled(False)
|
||||
self.DeleteButton.setEnabled(False)
|
||||
|
||||
|
@ -55,13 +55,9 @@ class SongManager():
|
||||
self.config.get_config(u'db hostname') + u'/' + \
|
||||
self.config.get_config(u'db database')
|
||||
self.session = init_models(self.db_url)
|
||||
if not songs_table.exists():
|
||||
metadata.create_all()
|
||||
metadata.create_all(checkfirst=True)
|
||||
log.debug(u'Song Initialised')
|
||||
|
||||
# def process_dialog(self, dialogobject):
|
||||
# self.dialogobject = dialogobject
|
||||
|
||||
def get_songs(self):
|
||||
"""
|
||||
Returns the details of a song
|
||||
|
Loading…
Reference in New Issue
Block a user