Always display copyright symbol in footer

This commit is contained in:
Samuel Mehrbrodt 2014-07-04 13:18:14 +02:00
parent 046f661d37
commit 60f11d9173
5 changed files with 28 additions and 27 deletions

View File

@ -218,12 +218,12 @@ class Ui_EditSongDialog(object):
self.rights_layout.setObjectName('rights_layout')
self.copyright_layout = QtGui.QHBoxLayout()
self.copyright_layout.setObjectName('copyright_layout')
self.copyright_label = QtGui.QLabel(self.rights_group_box)
self.copyright_label.setObjectName('copyright_label')
self.copyright_layout.addWidget(self.copyright_label)
self.copyright_edit = QtGui.QLineEdit(self.rights_group_box)
self.copyright_edit.setObjectName('copyright_edit')
self.copyright_layout.addWidget(self.copyright_edit)
self.copyright_insert_button = QtGui.QToolButton(self.rights_group_box)
self.copyright_insert_button.setObjectName('copyright_insert_button')
self.copyright_layout.addWidget(self.copyright_insert_button)
self.rights_layout.addLayout(self.copyright_layout)
self.ccli_layout = QtGui.QHBoxLayout()
self.ccli_layout.setObjectName('ccli_layout')
@ -318,7 +318,7 @@ class Ui_EditSongDialog(object):
self.theme_group_box.setTitle(UiStrings().Theme)
self.theme_add_button.setText(translate('SongsPlugin.EditSongForm', 'New &Theme'))
self.rights_group_box.setTitle(translate('SongsPlugin.EditSongForm', 'Copyright Information'))
self.copyright_insert_button.setText(SongStrings.CopyrightSymbol)
self.copyright_label.setText(translate('SongsPlugin.EditSongForm', 'Copyright:'))
self.ccli_label.setText(UiStrings().CCLINumberLabel)
self.comments_group_box.setTitle(translate('SongsPlugin.EditSongForm', 'Comments'))
self.song_tab_widget.setTabText(self.song_tab_widget.indexOf(self.theme_tab),

View File

@ -75,7 +75,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties):
self.topic_add_button.clicked.connect(self.on_topic_add_button_clicked)
self.topic_remove_button.clicked.connect(self.on_topic_remove_button_clicked)
self.topics_list_view.itemClicked.connect(self.on_topic_list_view_clicked)
self.copyright_insert_button.clicked.connect(self.on_copyright_insert_button_triggered)
self.verse_add_button.clicked.connect(self.on_verse_add_button_clicked)
self.verse_list_widget.doubleClicked.connect(self.on_verse_edit_button_clicked)
self.verse_edit_button.clicked.connect(self.on_verse_edit_button_clicked)
@ -796,18 +795,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties):
label_text = self.not_all_verses_used_warning
self.warning_label.setText(label_text)
def on_copyright_insert_button_triggered(self):
"""
Copyright insert button pressed
"""
text = self.copyright_edit.text()
pos = self.copyright_edit.cursorPosition()
sign = SongStrings.CopyrightSymbol
text = text[:pos] + sign + text[pos:]
self.copyright_edit.setText(text)
self.copyright_edit.setFocus()
self.copyright_edit.setCursorPosition(pos + len(sign))
def on_maintenance_button_clicked(self):
"""
Maintenance button pressed

View File

@ -506,7 +506,8 @@ class SongMediaItem(MediaManagerItem):
if authors_translation:
item.raw_footer.append("%s: %s" % (AuthorType.Types[AuthorType.Translation],
create_separated_list(authors_translation)))
item.raw_footer.append(song.copyright)
if song.copyright:
item.raw_footer.append('%s %s' % (SongStrings.CopyrightSymbol, song.copyright))
if self.display_songbook and song.book:
item.raw_footer.append("%s #%s" % (song.book.name, song.song_number))
if Settings().value('core/ccli number'):

View File

@ -27,8 +27,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`upgrade` module provides a way for the database and schema that is the
backend for the Songs plugin
The :mod:`upgrade` module provides a way for the database and schema that is the backend for the Songs plugin
"""
import logging
@ -39,7 +38,7 @@ from sqlalchemy.sql.expression import func, false, null, text
from openlp.core.lib.db import get_upgrade_op
log = logging.getLogger(__name__)
__version__ = 4
__version__ = 5
def upgrade_1(session, metadata):
@ -119,3 +118,17 @@ def upgrade_4(session, metadata):
op.rename_table('authors_songs_tmp', 'authors_songs')
except OperationalError:
log.info('Upgrade 4 has already been run')
def upgrade_5(session, metadata):
"""
Version 5 upgrade
This upgrade removes all hard-coded copyright symbols from the copyright field in the songs.
The copyright symbol is now being added directly in the footer.
"""
try:
op = get_upgrade_op(session)
op.execute('UPDATE songs SET copyright=TRIM(REPLACE(copyright, "©", ""))')
except OperationalError:
log.info('Upgrade 5 has already been run')

View File

@ -58,7 +58,7 @@ class TestMediaItem(TestCase, TestMixin):
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', 'Written by: my author', 'My copyright'],
self.assertEqual(service_item.raw_footer, ['My Song', 'Written by: my author', '© My copyright'],
'The array should be returned correctly with a song, one author and copyright')
self.assertEqual(author_list, ['my author'],
'The author list should be returned correctly with one author')
@ -97,7 +97,7 @@ class TestMediaItem(TestCase, TestMixin):
# THEN: I get the following Array returned
self.assertEqual(service_item.raw_footer, ['My Song', 'Words: another author', 'Music: my author',
'Translation: translator', 'My copyright'],
'Translation: translator', '© My copyright'],
'The array should be returned correctly with a song, two authors and copyright')
self.assertEqual(author_list, ['another author', 'my author', 'translator'],
'The author list should be returned correctly with two authors')
@ -117,7 +117,7 @@ class TestMediaItem(TestCase, TestMixin):
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 copyright', 'CCLI License: 1234'],
self.assertEqual(service_item.raw_footer, ['My Song', '© My copyright', 'CCLI License: 1234'],
'The array should be returned correctly with a song, an author, copyright and ccli')
# WHEN: I amend the CCLI value
@ -125,7 +125,7 @@ class TestMediaItem(TestCase, TestMixin):
self.media_item.generate_footer(service_item, mock_song)
# THEN: I would get an amended footer string
self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 4321'],
self.assertEqual(service_item.raw_footer, ['My Song', '© My copyright', 'CCLI License: 4321'],
'The array should be returned correctly with a song, an author, copyright and amended ccli')
def build_song_footer_base_songbook_test(self):
@ -145,14 +145,14 @@ class TestMediaItem(TestCase, TestMixin):
self.media_item.generate_footer(service_item, mock_song)
# THEN: The songbook should not be in the footer
self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright'])
self.assertEqual(service_item.raw_footer, ['My Song', '© My copyright'])
# WHEN: I activate the "display songbook" option
self.media_item.display_songbook = True
self.media_item.generate_footer(service_item, mock_song)
# THEN: The songbook should be in the footer
self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'My songbook #12'])
self.assertEqual(service_item.raw_footer, ['My Song', '© My copyright', 'My songbook #12'])
def authors_match_test(self):
"""