This commit is contained in:
Tim Bentley 2017-01-23 19:28:41 +00:00
commit 8486205ee5
47 changed files with 7813 additions and 6690 deletions

View File

@ -59,6 +59,13 @@ class UiStrings(object):
self.Automatic = translate('OpenLP.Ui', 'Automatic')
self.BackgroundColor = translate('OpenLP.Ui', 'Background Color')
self.BackgroundColorColon = translate('OpenLP.Ui', 'Background color:')
self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short')
self.BibleShortSearch = translate('OpenLP.Ui', '<strong>The search you have entered is empty or shorter '
'than 3 characters long.</strong><br><br>Please try again with '
'a longer search.')
self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available')
self.BibleNoBibles = translate('OpenLP.Ui', '<strong>There are no Bibles currently installed.</strong><br><br>'
'Please use the Import Wizard to install one or more Bibles.')
self.Bottom = translate('OpenLP.Ui', 'Bottom')
self.Browse = translate('OpenLP.Ui', 'Browse...')
self.Cancel = translate('OpenLP.Ui', 'Cancel')
@ -118,6 +125,8 @@ class UiStrings(object):
self.OLPV2x = "{name} {version}".format(name=self.OLP, version="2.4")
self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?')
self.OpenService = translate('OpenLP.Ui', 'Open service.')
self.OptionalShowInFooter = translate('OpenLP.Ui', 'Optional, this will be displayed in footer.')
self.OptionalHideInFooter = translate('OpenLP.Ui', 'Optional, this won\'t be displayed in footer.')
self.PlaySlidesInLoop = translate('OpenLP.Ui', 'Play Slides in Loop')
self.PlaySlidesToEnd = translate('OpenLP.Ui', 'Play Slides to End')
self.Preview = translate('OpenLP.Ui', 'Preview')
@ -131,6 +140,7 @@ class UiStrings(object):
'player is disabled.')
self.ResetBG = translate('OpenLP.Ui', 'Reset Background')
self.ResetLiveBG = translate('OpenLP.Ui', 'Reset live background.')
self.RequiredShowInFooter = translate('OpenLP.Ui', 'Required, this will be displayed in footer.')
self.Seconds = translate('OpenLP.Ui', 's', 'The abbreviated unit for seconds')
self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview')
self.Search = translate('OpenLP.Ui', 'Search')
@ -159,13 +169,6 @@ class UiStrings(object):
self.View = translate('OpenLP.Ui', 'View')
self.ViewMode = translate('OpenLP.Ui', 'View Mode')
self.Video = translate('OpenLP.Ui', 'Video')
self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short')
self.BibleShortSearch = translate('OpenLP.Ui', '<strong>The search you have entered is empty or shorter '
'than 3 characters long.</strong><br><br>Please try again with '
'a longer search.')
self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available')
self.BibleNoBibles = translate('OpenLP.Ui', '<strong>There are no Bibles currently installed.</strong><br><br>'
'Please use the Import Wizard to install one or more Bibles.')
book_chapter = translate('OpenLP.Ui', 'Book Chapter')
chapter = translate('OpenLP.Ui', 'Chapter')
verse = translate('OpenLP.Ui', 'Verse')

View File

@ -408,6 +408,12 @@ class BibleImportForm(OpenLPWizard):
self.permissions_edit = QtWidgets.QLineEdit(self.license_details_page)
self.permissions_edit.setObjectName('PermissionsEdit')
self.license_details_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.permissions_edit)
self.full_license_label = QtWidgets.QLabel(self.license_details_page)
self.full_license_label.setObjectName('FullLicenseLabel')
self.license_details_layout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.full_license_label)
self.full_license_edit = QtWidgets.QPlainTextEdit(self.license_details_page)
self.full_license_edit.setObjectName('FullLicenseEdit')
self.license_details_layout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.full_license_edit)
self.addPage(self.license_details_page)
def retranslateUi(self):
@ -480,6 +486,7 @@ class BibleImportForm(OpenLPWizard):
self.version_name_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
self.copyright_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
self.permissions_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
self.full_license_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Full license:'))
self.progress_page.setTitle(WizardStrings.Importing)
self.progress_page.setSubTitle(translate('BiblesPlugin.ImportWizardForm',
'Please wait while your Bible is imported.'))
@ -504,6 +511,7 @@ class BibleImportForm(OpenLPWizard):
elif self.currentPage() == self.select_page:
self.version_name_edit.clear()
self.permissions_edit.clear()
self.full_license_edit.clear()
self.copyright_edit.clear()
if self.field('source_format') == BibleFormat.OSIS:
if not self.field('osis_location'):
@ -763,6 +771,7 @@ class BibleImportForm(OpenLPWizard):
self.license_details_page.registerField('license_version', self.version_name_edit)
self.license_details_page.registerField('license_copyright', self.copyright_edit)
self.license_details_page.registerField('license_permissions', self.permissions_edit)
self.license_details_page.registerField("license_full_license", self.full_license_edit, 'plainText')
def set_defaults(self):
"""
@ -787,8 +796,13 @@ class BibleImportForm(OpenLPWizard):
self.setField('proxy_username', settings.value('proxy username'))
self.setField('proxy_password', settings.value('proxy password'))
self.setField('license_version', self.version_name_edit.text())
self.version_name_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
self.setField('license_copyright', self.copyright_edit.text())
self.copyright_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
self.setField('license_permissions', self.permissions_edit.text())
self.permissions_edit.setPlaceholderText(UiStrings().OptionalShowInFooter)
self.setField('license_full_license', self.full_license_edit.toPlainText())
self.full_license_edit.setPlaceholderText(UiStrings().OptionalHideInFooter)
self.on_web_source_combo_box_index_changed(WebDownload.Crosswalk)
settings.endGroup()
@ -812,6 +826,7 @@ class BibleImportForm(OpenLPWizard):
license_version = self.field('license_version')
license_copyright = self.field('license_copyright')
license_permissions = self.field('license_permissions')
license_full_license = self.field('license_full_license')
importer = None
if bible_type == BibleFormat.OSIS:
# Import an OSIS bible.
@ -861,10 +876,10 @@ class BibleImportForm(OpenLPWizard):
sword_path=self.field('sword_zip_path'),
sword_key=self.sword_zipbible_combo_box.itemData(
self.sword_zipbible_combo_box.currentIndex()))
try:
if importer.do_import(license_version) and not importer.stop_import_flag:
self.manager.save_meta_data(license_version, license_version, license_copyright, license_permissions)
self.manager.save_meta_data(license_version, license_version,
license_copyright, license_permissions, license_full_license)
self.manager.reload_bibles()
if bible_type == BibleFormat.WebDownload:
self.progress_label.setText(

View File

@ -68,6 +68,12 @@ class Ui_EditBibleDialog(object):
self.permissions_edit.setObjectName('permissions_edit')
self.permissions_label.setBuddy(self.permissions_edit)
self.license_details_layout.addRow(self.permissions_label, self.permissions_edit)
self.full_license_label = QtWidgets.QLabel(self.license_details_group_box)
self.full_license_label.setObjectName('full_license_label')
self.full_license_edit = QtWidgets.QPlainTextEdit(self.license_details_group_box)
self.full_license_edit.setObjectName('full_license_edit')
self.full_license_label.setBuddy(self.full_license_edit)
self.license_details_layout.addRow(self.full_license_label, self.full_license_edit)
self.meta_tab_layout.addWidget(self.license_details_group_box)
self.language_selection_group_box = QtWidgets.QGroupBox(self.meta_tab)
self.language_selection_group_box.setObjectName('language_selection_group_box')
@ -132,6 +138,7 @@ class Ui_EditBibleDialog(object):
self.version_name_label.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:'))
self.copyright_label.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:'))
self.permissions_label.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:'))
self.full_license_label.setText(translate('BiblesPlugin.EditBibleForm', 'Full license:'))
self.language_selection_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language'))
self.language_selection_label.setText(
translate('BiblesPlugin.EditBibleForm', 'Book name language in search field, search results and '

View File

@ -61,10 +61,28 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties):
"""
log.debug('Load Bible')
self.bible = bible
self.version_name_edit.setText(self.manager.get_meta_data(self.bible, 'name').value)
self.copyright_edit.setText(self.manager.get_meta_data(self.bible, 'copyright').value)
self.permissions_edit.setText(self.manager.get_meta_data(self.bible, 'permissions').value)
book_name_language = self.manager.get_meta_data(self.bible, 'book_name_language')
"""
Try loading the metadata, if the field does not exist in the metadata, continue executing the code,
missing fields will be created on "self.accept" (save).
"""
meta = self.manager.get_meta_data(self.bible, 'name')
copyright = self.manager.get_meta_data(self.bible, 'copyright')
permission = self.manager.get_meta_data(self.bible, 'permissions')
full_license = self.manager.get_meta_data(self.bible, 'full_license')
if meta:
self.version_name_edit.setText(meta.value)
if copyright:
self.copyright_edit.setText(copyright.value)
if permission:
self.permissions_edit.setText(permission.value)
if full_license:
self.full_license_edit.setPlainText(full_license.value)
# Set placeholder texts for the fields.
self.version_name_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
self.copyright_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
self.permissions_edit.setPlaceholderText(UiStrings().OptionalShowInFooter)
self.full_license_edit.setPlaceholderText(UiStrings().OptionalHideInFooter)
if book_name_language and book_name_language.value != 'None':
self.language_selection_combo_box.setCurrentIndex(int(book_name_language.value) + 1)
self.books = {}
@ -107,6 +125,7 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties):
version = self.version_name_edit.text()
copyright = self.copyright_edit.text()
permissions = self.permissions_edit.text()
full_license = self.full_license_edit.toPlainText()
book_name_language = self.language_selection_combo_box.currentIndex() - 1
if book_name_language == -1:
book_name_language = None
@ -121,7 +140,7 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties):
if not self.validate_book(custom_names[abbr], abbr):
return
self.application.set_busy_cursor()
self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language)
self.manager.save_meta_data(self.bible, version, copyright, permissions, full_license, book_name_language)
if not self.web_bible:
for abbr, book in self.books.items():
if book:

View File

@ -380,17 +380,17 @@ class BibleManager(OpenLPMixin, RegistryProperties):
else:
return None
def save_meta_data(self, bible, version, copyright, permissions, book_name_language=None):
def save_meta_data(self, bible, version, copyright, permissions, full_license, book_name_language=None):
"""
Saves the bibles meta data.
"""
log.debug('save_meta data {bible}, {version}, {copyright}, {perms}'.format(bible=bible,
version=version,
copyright=copyright,
perms=permissions))
log.debug('save_meta data {bible}, {version}, {copyright},'
' {perms}, {full_license}'.format(bible=bible, version=version, copyright=copyright,
perms=permissions, full_license=full_license))
self.db_cache[bible].save_meta('name', version)
self.db_cache[bible].save_meta('copyright', copyright)
self.db_cache[bible].save_meta('permissions', permissions)
self.db_cache[bible].save_meta('full_license', full_license)
self.db_cache[bible].save_meta('book_name_language', book_name_language)
def get_meta_data(self, bible, key):

View File

@ -30,7 +30,7 @@ import re
from PyQt5 import QtWidgets
from openlp.core.common import AppLocation, CONTROL_CHARS
from openlp.core.lib import translate
from openlp.core.lib import translate, clean_tags
from openlp.plugins.songs.lib.db import Author, MediaFile, Song, Topic
from openlp.plugins.songs.lib.ui import SongStrings
@ -380,7 +380,7 @@ def clean_song(manager, song):
if isinstance(song.lyrics, bytes):
song.lyrics = str(song.lyrics, encoding='utf8')
verses = SongXML().get_verses(song.lyrics)
song.search_lyrics = ' '.join([clean_string(verse[1]) for verse in verses])
song.search_lyrics = ' '.join([clean_string(clean_tags(verse[1])) for verse in verses])
# The song does not have any author, add one.
if not song.authors_songs:
name = SongStrings.AuthorUnknown

View File

@ -180,7 +180,7 @@ class EasySlidesImport(SongImport):
reg = default_region
verses[reg] = {}
# instance differentiates occurrences of same verse tag
vt = 'V'
vt = 'v'
vn = '1'
inst = 1
for line in lines:
@ -193,14 +193,14 @@ class EasySlidesImport(SongImport):
inst += 1
else:
# separators are not used, so empty line starts a new verse
vt = 'V'
vt = 'v'
vn = len(verses[reg].get(vt, {})) + 1
inst = 1
elif line[0:7] == '[region':
reg = self._extract_region(line)
verses.setdefault(reg, {})
if not regions_in_verses:
vt = 'V'
vt = 'v'
vn = '1'
inst = 1
elif line[0] == '[':
@ -213,7 +213,7 @@ class EasySlidesImport(SongImport):
if match:
marker = match.group(1).strip()
vn = match.group(2)
vt = MarkTypes.get(marker, 'O') if marker else 'V'
vt = MarkTypes.get(marker, 'o') if marker else 'v'
if regions_in_verses:
region = default_region
inst = 1
@ -238,13 +238,13 @@ class EasySlidesImport(SongImport):
lines = '\n'.join(verses[reg][vt][vn][inst])
self.add_verse(lines, versetag)
SeqTypes = {
'p': 'P1',
'q': 'P2',
'c': 'C1',
't': 'C2',
'b': 'B1',
'w': 'B2',
'e': 'E1'}
'p': 'p1',
'q': 'p2',
'c': 'c1',
't': 'c2',
'b': 'b1',
'w': 'b2',
'e': 'e1'}
# Make use of Sequence data, determining the order of verses
try:
order = str(song.Sequence).strip().split(',')
@ -252,7 +252,7 @@ class EasySlidesImport(SongImport):
if not tag:
continue
elif tag[0].isdigit():
tag = 'V' + tag
tag = 'v' + tag
elif tag.lower() in SeqTypes:
tag = SeqTypes[tag.lower()]
else:

View File

@ -28,6 +28,7 @@ import logging
import os
import re
from openlp.core.common import get_file_encoding
from openlp.plugins.songs.lib import VerseType
from openlp.plugins.songs.lib.importers.songimport import SongImport
@ -113,13 +114,15 @@ class SongBeamerImport(SongImport):
read_verses = False
file_name = os.path.split(import_file)[1]
if os.path.isfile(import_file):
# First open in binary mode to detect the encoding
detect_file = open(import_file, 'rb')
details = chardet.detect(detect_file.read())
detect_file.close()
infile = codecs.open(import_file, 'r', details['encoding'])
# Detect the encoding
self.input_file_encoding = get_file_encoding(import_file)['encoding']
# The encoding should only be ANSI (cp1252), UTF-8, Unicode, Big-Endian-Unicode.
# So if it doesn't start with 'u' we default to cp1252. See:
# https://forum.songbeamer.com/viewtopic.php?p=419&sid=ca4814924e37c11e4438b7272a98b6f2
if self.input_file_encoding.lower().startswith('u'):
self.input_file_encoding = 'cp1252'
infile = open(import_file, 'rt', encoding=self.input_file_encoding)
song_data = infile.readlines()
infile.close()
else:
continue
self.title = file_name.split('.sng')[0]

View File

@ -65,8 +65,8 @@ class VideoPsalmImport(SongImport):
if c == '\n':
if inside_quotes:
processed_content += '\\n'
# Put keys in quotes
elif c.isalnum() and not inside_quotes:
# Put keys in quotes. The '-' is for handling nagative numbers
elif (c.isalnum() or c == '-') and not inside_quotes:
processed_content += '"' + c
c = next(file_content_it)
while c.isalnum():
@ -121,6 +121,8 @@ class VideoPsalmImport(SongImport):
if 'Memo3' in song:
self.add_comment(song['Memo3'])
for verse in song['Verses']:
if 'Text' not in verse:
continue
self.add_verse(verse['Text'], 'v')
if not self.finish():
self.log_error('Could not import {title}'.format(title=self.title))

View File

@ -126,6 +126,7 @@ class SongMediaItem(MediaManagerItem):
self.update_service_on_edit = Settings().value(self.settings_section + '/update service on edit')
self.add_song_from_service = Settings().value(self.settings_section + '/add song from service')
self.display_songbook = Settings().value(self.settings_section + '/display songbook')
self.display_written_by_text = Settings().value(self.settings_section + '/display written by')
self.display_copyright_symbol = Settings().value(self.settings_section + '/display copyright symbol')
def retranslateUi(self):
@ -640,8 +641,12 @@ class SongMediaItem(MediaManagerItem):
item.raw_footer = []
item.raw_footer.append(song.title)
if authors_none:
item.raw_footer.append("{text}: {authors}".format(text=translate('OpenLP.Ui', 'Written by'),
authors=create_separated_list(authors_none)))
# If the setting for showing "Written by:" is enabled, show it before unspecified authors.
if Settings().value('songs/display written by'):
item.raw_footer.append("{text}: {authors}".format(text=translate('OpenLP.Ui', 'Written by'),
authors=create_separated_list(authors_none)))
else:
item.raw_footer.append("{authors}".format(authors=create_separated_list(authors_none)))
if authors_words_music:
item.raw_footer.append("{text}: {authors}".format(text=AuthorType.Types[AuthorType.WordsAndMusic],
authors=create_separated_list(authors_words_music)))

View File

@ -53,6 +53,9 @@ class SongsTab(SettingsTab):
self.display_songbook_check_box = QtWidgets.QCheckBox(self.mode_group_box)
self.display_songbook_check_box.setObjectName('songbook_check_box')
self.mode_layout.addWidget(self.display_songbook_check_box)
self.display_written_by_check_box = QtWidgets.QCheckBox(self.mode_group_box)
self.display_written_by_check_box.setObjectName('written_by_check_box')
self.mode_layout.addWidget(self.display_written_by_check_box)
self.display_copyright_check_box = QtWidgets.QCheckBox(self.mode_group_box)
self.display_copyright_check_box.setObjectName('copyright_check_box')
self.mode_layout.addWidget(self.display_copyright_check_box)
@ -63,16 +66,19 @@ class SongsTab(SettingsTab):
self.update_on_edit_check_box.stateChanged.connect(self.on_update_on_edit_check_box_changed)
self.add_from_service_check_box.stateChanged.connect(self.on_add_from_service_check_box_changed)
self.display_songbook_check_box.stateChanged.connect(self.on_songbook_check_box_changed)
self.display_written_by_check_box.stateChanged.connect(self.on_written_by_check_box_changed)
self.display_copyright_check_box.stateChanged.connect(self.on_copyright_check_box_changed)
def retranslateUi(self):
self.mode_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Songs Mode'))
self.mode_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Song related settings'))
self.tool_bar_active_check_box.setText(translate('SongsPlugin.SongsTab',
'Enable "Go to verse" button in Live panel'))
self.update_on_edit_check_box.setText(translate('SongsPlugin.SongsTab', 'Update service from song edit'))
self.add_from_service_check_box.setText(translate('SongsPlugin.SongsTab',
'Import missing songs from Service files'))
self.display_songbook_check_box.setText(translate('SongsPlugin.SongsTab', 'Display songbook in footer'))
self.display_written_by_check_box.setText(translate(
'SongsPlugin.SongsTab', 'Show "Written by:" in footer for unspecified authors'))
self.display_copyright_check_box.setText(translate('SongsPlugin.SongsTab',
'Display "{symbol}" symbol before copyright '
'info').format(symbol=SongStrings.CopyrightSymbol))
@ -92,6 +98,9 @@ class SongsTab(SettingsTab):
def on_songbook_check_box_changed(self, check_state):
self.display_songbook = (check_state == QtCore.Qt.Checked)
def on_written_by_check_box_changed(self, check_state):
self.display_written_by = (check_state == QtCore.Qt.Checked)
def on_copyright_check_box_changed(self, check_state):
self.display_copyright_symbol = (check_state == QtCore.Qt.Checked)
@ -102,11 +111,13 @@ class SongsTab(SettingsTab):
self.update_edit = settings.value('update service on edit')
self.update_load = settings.value('add song from service')
self.display_songbook = settings.value('display songbook')
self.display_written_by = settings.value('display written by')
self.display_copyright_symbol = settings.value('display copyright symbol')
self.tool_bar_active_check_box.setChecked(self.tool_bar)
self.update_on_edit_check_box.setChecked(self.update_edit)
self.add_from_service_check_box.setChecked(self.update_load)
self.display_songbook_check_box.setChecked(self.display_songbook)
self.display_written_by_check_box.setChecked(self.display_written_by)
self.display_copyright_check_box.setChecked(self.display_copyright_symbol)
settings.endGroup()
@ -117,6 +128,7 @@ class SongsTab(SettingsTab):
settings.setValue('update service on edit', self.update_edit)
settings.setValue('add song from service', self.update_load)
settings.setValue('display songbook', self.display_songbook)
settings.setValue('display written by', self.display_written_by)
settings.setValue('display copyright symbol', self.display_copyright_symbol)
settings.endGroup()
if self.tab_visited:

View File

@ -60,6 +60,7 @@ __default_settings__ = {
'songs/add song from service': True,
'songs/display songbar': True,
'songs/display songbook': False,
'songs/display written by': True,
'songs/display copyright symbol': False,
'songs/last directory import': '',
'songs/last directory export': '',

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -43,3 +43,5 @@ class TestEasySlidesFileImport(SongImportTestHelper):
"""
self.file_import(os.path.join(TEST_PATH, 'amazing-grace.xml'),
self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
self.file_import(os.path.join(TEST_PATH, 'Export_2017-01-12_BB.xml'),
self.load_external_result_data(os.path.join(TEST_PATH, 'Export_2017-01-12_BB.json')))

View File

@ -295,11 +295,18 @@ class TestMediaItem(TestCase, TestMixin):
mock_qlist_widget.setData.assert_called_once_with(MockedUserRole, mock_song.id)
self.media_item.list_view.addItem.assert_called_once_with(mock_qlist_widget)
def test_build_song_footer_one_author(self):
@patch(u'openlp.plugins.songs.lib.mediaitem.Settings')
def test_build_song_footer_one_author_show_written_by(self, MockedSettings):
"""
Test build songs footer with basic song and one author
"""
# GIVEN: A Song and a Service Item
# GIVEN: A Song and a Service Item, mocked settings: True for 'songs/display written by'
# and False for 'core/ccli number' (ccli will cause traceback if true)
mocked_settings = MagicMock()
mocked_settings.value.side_effect = [True, False]
MockedSettings.return_value = mocked_settings
mock_song = MagicMock()
mock_song.title = 'My Song'
mock_song.authors_songs = []
@ -320,6 +327,39 @@ class TestMediaItem(TestCase, TestMixin):
self.assertEqual(author_list, ['my author'],
'The author list should be returned correctly with one author')
@patch(u'openlp.plugins.songs.lib.mediaitem.Settings')
def test_build_song_footer_one_author_hide_written_by(self, MockedSettings):
"""
Test build songs footer with basic song and one author
"""
# GIVEN: A Song and a Service Item, mocked settings: False for 'songs/display written by'
# and False for 'core/ccli number' (ccli will cause traceback if true)
mocked_settings = MagicMock()
mocked_settings.value.side_effect = [False, False]
MockedSettings.return_value = mocked_settings
mock_song = MagicMock()
mock_song.title = 'My Song'
mock_song.authors_songs = []
mock_author = MagicMock()
mock_author.display_name = 'my author'
mock_author_song = MagicMock()
mock_author_song.author = mock_author
mock_song.authors_songs.append(mock_author_song)
mock_song.copyright = 'My copyright'
service_item = ServiceItem(None)
# WHEN: I generate the Footer with default settings
author_list = self.media_item.generate_footer(service_item, mock_song)
# THEN: I get the following Array returned
self.assertEqual(service_item.raw_footer, ['My Song', 'my author', 'My copyright'],
'The array should be returned correctly with a song, one author and copyright,'
'text Written by should not be part of the text.')
self.assertEqual(author_list, ['my author'],
'The author list should be returned correctly with one author')
def test_build_song_footer_two_authors(self):
"""
Test build songs footer with basic song and two authors

View File

@ -6,27 +6,27 @@
"verses": [
[
"Amazing grace! How sweet the sound\nThat saved a wretch like me;\nI once was lost, but now am found,\nWas blind, but now I see.",
"V1"
"v1"
],
[
"'Twas grace that taught my heart to fear,\nAnd grace my fears relieved;\nHow precious did that grace appear,\nThe hour I first believed!",
"V2"
"v2"
],
[
"Through many dangers, toils and snares\nI have already come;\n'Tis grace that brought me safe thus far,\nAnd grace will lead me home.",
"V3"
"v3"
],
[
"The Lord has promised good to me,\nHis word my hope secures;\nHe will my shield and portion be\nAs long as life endures.",
"V4"
"v4"
],
[
"Yes, when this heart and flesh shall fail,\nAnd mortal life shall cease,\nI shall possess within the veil\nA life of joy and peace.",
"V5"
"v5"
],
[
"When we've been there a thousand years,\nBright shining as the sun,\nWe've no less days to sing God's praise\nThan when we first begun.",
"V6"
"v6"
]
]
}

View File

@ -0,0 +1,44 @@
{
"title": "BBBBBBBBB",
"authors": [
"John Newton (1725-1807)"
],
"verses": [
[
"V1V1V1V1V1V1\nV1V1V1V1V1V1",
"v1"
],
[
"V2V2V2V2V2V2\nV2V2V2V2V2V2",
"v2"
],
[
"C1C1C1C1C1C1\nC1C1C1C1C1C1",
"c1"
],
[
"C2C2C2C2C2C2\nC2C2C2C2C2C2",
"c2"
],
[
"B1B1B1B1B1B1\nB1B1B1B1B1B1",
"b1"
],
[
"B2B2B2B2B2B2\nB2B2B2B2B2B2",
"b2"
],
[
"PRE1PRE1PRE1\nPRE1PRE1PRE1",
"p1"
],
[
"PRE2PRE2PRE2\nPRE2PRE2PRE2",
"p2"
],
[
"ENDENDENDEND\nENDENDENDEND",
"e1"
]
]
}

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<EasiSlides>
<Item>
<Title1>BBBBBBBBB</Title1>
<Title2 />
<Folder>NAGY</Folder>
<SongNumber>0</SongNumber>
<Contents>[1]
V1V1V1V1V1V1
V1V1V1V1V1V1
[2]
V2V2V2V2V2V2
V2V2V2V2V2V2
[chorus]
C1C1C1C1C1C1
C1C1C1C1C1C1
[chorus 2]
C2C2C2C2C2C2
C2C2C2C2C2C2
[bridge]
B1B1B1B1B1B1
B1B1B1B1B1B1
[bridge 2]
B2B2B2B2B2B2
B2B2B2B2B2B2
[prechorus]
PRE1PRE1PRE1
PRE1PRE1PRE1
[prechorus 2]
PRE2PRE2PRE2
PRE2PRE2PRE2
[ending]
ENDENDENDEND
ENDENDENDEND</Contents>
<Notations />
<Sequence>1,2,c,t,b,w,p,q,e</Sequence>
<Writer />
<Copyright />
<Category />
<Timing />
<MusicKey />
<Capo>-1</Capo>
<LicenceAdmin1 />
<LicenceAdmin2 />
<BookReference />
<UserReference />
<FormatData />
<Settings>10=&gt;</Settings>
</Item>
</EasiSlides>

View File

@ -1,4 +1,4 @@
{Abbreviation:"SB1",Copyright:"Public domain",Songs:[{ID:3,Composer:"Unknown",Author:"Martin Luther",Copyright:"Public
{Abbreviation:"SB1",Copyright:"Public domain",Songs:[{ID:3,Composer:"Unknown",Author:"Martin Luther",Capo:-1,Copyright:"Public
Domain",Theme:"tema1
tema2",CCLI:"12345",Alias:"A safe stronghold",Memo1:"This is
the first comment