forked from openlp/openlp
Change upgrade of bibles: bibleupgradeform now trys to upgrade existing verses from webbibles.
This commit is contained in:
parent
d7c668c948
commit
877ea4e13d
@ -671,8 +671,25 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
bible_failed = True
|
||||
break
|
||||
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
||||
self.newbibles[number].create_book(book, book_ref_id,
|
||||
book_details[u'testament_id'])
|
||||
db_book = self.newbibles[number].create_book(book,
|
||||
book_ref_id, book_details[u'testament_id'])
|
||||
# Try to import still downloaded verses
|
||||
oldbook = oldbible.get_book(book)
|
||||
if oldbook:
|
||||
verses = oldbible.get_verses(oldbook[u'id'])
|
||||
if not verses:
|
||||
log.exception(u'No verses found to import for book '
|
||||
u'"%s"', book)
|
||||
continue
|
||||
for verse in verses:
|
||||
if self.stop_import_flag:
|
||||
bible_failed = True
|
||||
break
|
||||
self.newbibles[number].create_verse(db_book.id,
|
||||
int(verse[u'chapter']),
|
||||
int(verse[u'verse']), unicode(verse[u'text']))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
self.newbibles[number].session.commit()
|
||||
else:
|
||||
language_id = self.newbibles[number].get_object(BibleMeta,
|
||||
u'language_id')
|
||||
|
@ -1043,6 +1043,28 @@ class OldBibleDB(QtCore.QObject, Manager):
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_book(self, name):
|
||||
"""
|
||||
Return a book by name or abbreviation.
|
||||
|
||||
``name``
|
||||
The name or abbreviation of the book.
|
||||
"""
|
||||
if not isinstance(name, unicode):
|
||||
name = unicode(name)
|
||||
books = self.run_sql(u'SELECT id, testament_id, name, '
|
||||
u'abbreviation FROM book WHERE LOWER(name) = ? OR '
|
||||
u'LOWER(abbreviation) = ?', (name.lower(), name.lower()))
|
||||
if books:
|
||||
return {
|
||||
u'id': books[0][0],
|
||||
u'testament_id': books[0][1],
|
||||
u'name': unicode(books[0][2]),
|
||||
u'abbreviation': unicode(books[0][3])
|
||||
}
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_books(self):
|
||||
"""
|
||||
Returns the books of the Bible.
|
||||
|
Loading…
Reference in New Issue
Block a user