From 6ef78ef39d1a76c6e41a7fefece1ed4a32770c1c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 6 Mar 2011 16:28:26 +0000 Subject: [PATCH] Fix song import duplication by removing training space on the search title. Fixed up all locations field was made and the reindex code. Only tested with reindex! Fixes: https://launchpad.net/bugs/712252 --- openlp/plugins/songs/forms/editsongform.py | 2 +- openlp/plugins/songs/lib/foilpresenterimport.py | 2 +- openlp/plugins/songs/lib/olpimport.py | 2 +- openlp/plugins/songs/lib/songimport.py | 1 + openlp/plugins/songs/lib/xml.py | 2 +- openlp/plugins/songs/songsplugin.py | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0e874c3d5..0d9121c45 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -810,4 +810,4 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): # This method must only be run after the self.song = Song() assignment. log.debug(u'processTitle') self.song.search_title = re.sub(r'[\'"`,;:(){}?]+', u'', - unicode(self.song.search_title)).lower() + unicode(self.song.search_title)).lower().strip() diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 0d81e6f41..a26d1c05a 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -540,7 +540,7 @@ class FoilPresenter(object): song.alternate_title = self._child(titelstring) song.search_title += u'@' + song.alternate_title song.search_title = re.sub(r'[\'"`,;:(){}?]+', u'', - unicode(song.search_title)).lower() + unicode(song.search_title)).lower().strip() def _process_topics(self, foilpresenterfolie, song): """ diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index fe010b501..11170f9a0 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -167,7 +167,7 @@ class OpenLPSongImport(SongImport): new_song.alternate_title = old_titles[1] else: new_song.alternate_title = u'' - new_song.search_title = song.search_title + new_song.search_title = song.search_title.strip() new_song.song_number = song.song_number new_song.lyrics = song.lyrics new_song.search_lyrics = song.search_lyrics diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 5bfba9b77..fc78b5033 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -276,6 +276,7 @@ class SongImport(QtCore.QObject): song.alternate_title = self.alternate_title song.search_title = self.remove_punctuation(self.title).lower() \ + '@' + self.remove_punctuation(self.alternate_title).lower() + song.search_title = song.search_title.strip() song.song_number = self.song_number song.search_lyrics = u'' verses_changed_to_other = {} diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index a2a73ec97..bd22ea4b2 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -536,7 +536,7 @@ class OpenLyrics(object): song.alternate_title = self._text(title) song.search_title += u'@' + song.alternate_title song.search_title = re.sub(r'[\'"`,;:(){}?]+', u'', - unicode(song.search_title)).lower() + unicode(song.search_title)).lower().strip() def _process_topics(self, properties, song): """ diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 0335b3a6e..bfd5c4eea 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -154,7 +154,7 @@ class SongsPlugin(Plugin): if song.alternate_title is None: song.alternate_title = u'' song.search_title = self.whitespace.sub(u' ', song.title.lower() + - u' ' + song.alternate_title.lower()) + u' ' + song.alternate_title.lower()).strip() # Remove the "language" attribute from lyrics tag. This is not very # important, but this keeps the database clean. This can be removed # when everybody has run the reindex tool once.