← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~orangeshirt/openlp/bibles_fixes2 into lp:openlp

 

Armin Köhler has proposed merging lp:~orangeshirt/openlp/bibles_fixes2 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~orangeshirt/openlp/bibles_fixes2/+merge/102921

Use localized booknames instead of English in BookNameForm (used by BibleImportWizard and BibleUpgradeWizard)
-- 
https://code.launchpad.net/~orangeshirt/openlp/bibles_fixes2/+merge/102921
Your team OpenLP Core is requested to review the proposed merge of lp:~orangeshirt/openlp/bibles_fixes2 into lp:openlp.
=== modified file 'openlp/plugins/bibles/forms/booknamedialog.py'
--- openlp/plugins/bibles/forms/booknamedialog.py	2012-04-04 07:26:51 +0000
+++ openlp/plugins/bibles/forms/booknamedialog.py	2012-04-20 19:23:01 +0000
@@ -90,7 +90,7 @@
             'Select Book Name'))
         self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog',
             'The following book name cannot be matched up internally. Please '
-            'select the corresponding English name from the list.'))
+            'select the corresponding name from the list.'))
         self.currentLabel.setText(translate('BiblesPlugin.BookNameDialog',
             'Current name:'))
         self.correspondingLabel.setText(translate(

=== modified file 'openlp/plugins/bibles/forms/booknameform.py'
--- openlp/plugins/bibles/forms/booknameform.py	2012-04-04 07:26:51 +0000
+++ openlp/plugins/bibles/forms/booknameform.py	2012-04-20 19:23:01 +0000
@@ -28,6 +28,7 @@
 Module implementing BookNameForm.
 """
 import logging
+import re
 
 from PyQt4.QtGui import QDialog
 from PyQt4 import QtCore
@@ -36,6 +37,7 @@
 from openlp.core.lib.ui import critical_error_message_box
 from openlp.plugins.bibles.forms.booknamedialog import \
     Ui_BookNameDialog
+from openlp.plugins.bibles.lib import BibleStrings
 from openlp.plugins.bibles.lib.db import BiblesResourcesDB
 
 log = logging.getLogger(__name__)
@@ -54,6 +56,8 @@
         QDialog.__init__(self, parent)
         self.setupUi(self)
         self.customSignals()
+        self.booknames = BibleStrings().Booknames
+        self.book_id = False
 
     def customSignals(self):
         """
@@ -97,7 +101,8 @@
                 and item[u'testament_id'] == 3:
                 addBook = False
             if addBook:
-                self.correspondingComboBox.addItem(item[u'name'])
+                self.correspondingComboBox.addItem(
+                    self.booknames[item[u'abbreviation']])
 
     def exec_(self, name, books, maxbooks):
         self.books = books
@@ -120,4 +125,13 @@
             self.correspondingComboBox.setFocus()
             return False
         else:
+            cor_book = unicode(self.correspondingComboBox.currentText())
+            for character in u'\\.^$*+?{}[]()':
+                cor_book = cor_book.replace(character, u'\\' + character)
+            books = filter(lambda key:
+                re.match(cor_book, unicode(self.booknames[key]), re.UNICODE),
+                self.booknames.keys())
+            books = filter(None, map(BiblesResourcesDB.get_book, books))
+            if books:
+                self.book_id = books[0][u'id']
             return QDialog.accept(self)

=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py	2012-04-04 19:34:14 +0000
+++ openlp/plugins/bibles/lib/db.py	2012-04-20 19:23:01 +0000
@@ -332,6 +332,7 @@
     def get_book_ref_id_by_name(self, book, maxbooks, language_id=None):
         log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book,
             language_id)
+        book_id = None
         if BiblesResourcesDB.get_book(book, True):
             book_temp = BiblesResourcesDB.get_book(book, True)
             book_id = book_temp[u'id']
@@ -341,26 +342,13 @@
             book_id = AlternativeBookNamesDB.get_book_reference_id(book)
         else:
             from openlp.plugins.bibles.forms import BookNameForm
-            book_ref = None
             book_name = BookNameForm(self.wizard)
             if book_name.exec_(book, self.get_books(), maxbooks):
-                book_ref = unicode(
-                    book_name.correspondingComboBox.currentText())
-            if not book_ref:
-                return None
-            else:
-                book_temp = BiblesResourcesDB.get_book(book_ref)
-            if book_temp:
-                book_id = book_temp[u'id']
-            else:
-                return None
+                book_id = book_name.book_id
             if book_id:
                 AlternativeBookNamesDB.create_alternative_book_name(
                     book, book_id, language_id)
-        if book_id:
-            return book_id
-        else:
-            return None
+        return book_id
 
     def get_verses(self, reference_list, show_error=True):
         """


Follow ups