Fix song edit form to clear previous used fields

bzr-revno: 2288
This commit is contained in:
Raoul Snyman 2013-08-31 09:56:21 +01:00 committed by Tim Bentley
commit 4a86d55a00
6 changed files with 83 additions and 7 deletions

View File

@ -221,6 +221,7 @@ def update_reference_separators():
u'(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$' \
% dict(REFERENCE_SEPARATORS.items() + [(u'range_regex', range_regex)]), re.UNICODE)
def get_reference_separator(separator_type):
"""
Provides separators for parsing and formatting scripture references.
@ -232,6 +233,7 @@ def get_reference_separator(separator_type):
update_reference_separators()
return REFERENCE_SEPARATORS[separator_type]
def get_reference_match(match_type):
"""
Provides matches for parsing scripture references strings.
@ -243,6 +245,7 @@ def get_reference_match(match_type):
update_reference_separators()
return REFERENCE_MATCHES[match_type]
def parse_reference(reference, bible, language_selection, book_ref_id=False):
"""
This is the next generation über-awesome function that takes a person's typed in string and converts it to a list
@ -402,7 +405,7 @@ class SearchResults(object):
"""
Encapsulate a set of search results. This is Bible-type independent.
"""
def __init__(self, book, chapter, verselist):
def __init__(self, book, chapter, verse_list):
"""
Create the search result object.
@ -412,19 +415,19 @@ class SearchResults(object):
``chapter``
The chapter of the book.
``verselist``
``verse_list``
The list of verses for this reading.
"""
self.book = book
self.chapter = chapter
self.verselist = verselist
self.verse_list = verse_list
def has_verselist(self):
def has_verse_list(self):
"""
Returns whether or not the verse list contains verses.
"""
return len(self.verselist) > 0
return len(self.verse_list) > 0
from versereferencelist import VerseReferenceList

View File

@ -618,7 +618,7 @@ class HTTPBible(BibleDB):
if BibleDB.get_verse_count(self, book_id, reference[1]) == 0:
self.application.set_busy_cursor()
search_results = self.get_chapter(book, reference[1])
if search_results and search_results.has_verselist():
if search_results and search_results.has_verse_list():
## We have found a book of the bible lets check to see
## if it was there. By reusing the returned book name
## we get a correct book. For example it is possible
@ -627,7 +627,7 @@ class HTTPBible(BibleDB):
self.application.process_events()
# Check to see if book/chapter exists.
db_book = self.get_book(book_name)
self.create_chapter(db_book.id, search_results.chapter, search_results.verselist)
self.create_chapter(db_book.id, search_results.chapter, search_results.verse_list)
self.application.process_events()
self.application.set_normal_cursor()
self.application.process_events()

View File

@ -350,6 +350,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.load_topics()
self.load_books()
self.load_media_files()
self.theme_combo_box.setEditText(u'')
self.theme_combo_box.setCurrentIndex(0)
# it's a new song to preview is not possible
self.preview_button.setVisible(False)
@ -378,8 +379,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if self.song.song_book_id != 0:
book_name = self.manager.get_object(Book, self.song.song_book_id)
find_and_set_in_combo_box(self.song_book_combo_box, unicode(book_name.name))
else:
self.song_book_combo_box.setEditText(u'')
self.song_book_combo_box.setCurrentIndex(0)
if self.song.theme_name:
find_and_set_in_combo_box(self.theme_combo_box, unicode(self.song.theme_name))
else:
# Clear the theme combo box in case it was previously set (bug #1212801)
self.theme_combo_box.setEditText(u'')
self.theme_combo_box.setCurrentIndex(0)
self.copyright_edit.setText(self.song.copyright if self.song.copyright else u'')
self.comments_edit.setPlainText(self.song.comments if self.song.comments else u'')
self.ccli_number_edit.setText(self.song.ccli_number if self.song.ccli_number else u'')

View File

@ -0,0 +1,3 @@
"""
Tests for the Bibles plugin
"""

View File

@ -0,0 +1,59 @@
"""
This module contains tests for the lib submodule of the Bibles plugin.
"""
from unittest import TestCase
from openlp.plugins.bibles.lib import SearchResults
class TestLib(TestCase):
"""
Test the functions in the :mod:`lib` module.
"""
def search_results_creation_test(self):
"""
Test the creation and construction of the SearchResults class
"""
# GIVEN: A book, chapter and a verse list
book = u'Genesis'
chapter = 1
verse_list = {
1: u'In the beginning God created the heavens and the earth.',
2: u'The earth was without form and void, and darkness was over the face of the deep. And the Spirit of '
u'God was hovering over the face of the waters.'
}
# WHEN: We create the search results object
search_results = SearchResults(book, chapter, verse_list)
# THEN: It should have a book, a chapter and a verse list
self.assertIsNotNone(search_results, u'The search_results object should not be None')
self.assertEqual(search_results.book, book, u'The book should be "Genesis"')
self.assertEqual(search_results.chapter, chapter, u'The chapter should be 1')
self.assertDictEqual(search_results.verse_list, verse_list, u'The verse lists should be identical')
def search_results_has_verse_list_test(self):
"""
Test that a SearchResults object with a valid verse list returns True when checking ``has_verse_list()``
"""
# GIVEN: A valid SearchResults object with a proper verse list
search_results = SearchResults(u'Genesis', 1, {1: u'In the beginning God created the heavens and the earth.'})
# WHEN: We check that the SearchResults object has a verse list
has_verse_list = search_results.has_verse_list()
# THEN: It should be True
self.assertTrue(has_verse_list, u'The SearchResults object should have a verse list')
def search_results_has_no_verse_list_test(self):
"""
Test that a SearchResults object with an empty verse list returns False when checking ``has_verse_list()``
"""
# GIVEN: A valid SearchResults object with an empty verse list
search_results = SearchResults(u'Genesis', 1, {})
# WHEN: We check that the SearchResults object has a verse list
has_verse_list = search_results.has_verse_list()
# THEN: It should be False
self.assertFalse(has_verse_list, u'The SearchResults object should have a verse list')

View File

@ -0,0 +1,3 @@
"""
Tests for the Songs plugin
"""