← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/trivial into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/trivial into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/trivial/+merge/50459

Hello!

The re-index tool adds 'Author unknown' (or translated) if songs do not have any author.

Cheers
-- 
https://code.launchpad.net/~googol-hush/openlp/trivial/+merge/50459
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py	2011-02-18 01:07:55 +0000
+++ openlp/plugins/songs/songsplugin.py	2011-02-19 18:41:52 +0000
@@ -33,8 +33,9 @@
 from openlp.core.lib.db import Manager
 from openlp.core.lib.ui import UiStrings
 from openlp.plugins.songs.lib import SongMediaItem, SongsTab, SongXML
-from openlp.plugins.songs.lib.db import init_schema, Song
+from openlp.plugins.songs.lib.db import Author, init_schema, Song
 from openlp.plugins.songs.lib.importer import SongFormat
+from openlp.plugins.songs.lib.ui import SongStrings
 
 log = logging.getLogger(__name__)
 
@@ -145,6 +146,16 @@
         counter = 0
         for song in songs:
             counter += 1
+            # The song does not have any author, add one.
+            if not song.authors:
+                name = unicode(SongStrings.AuthorUnknownUnT)
+                author = self.manager.get_object_filtered(Author,
+                    Author.display_name == name)
+                if author is None:
+                    author = Author.populate(
+                        first_name=u' '.join(name.split(u' ', 1)[:-1]),
+                        last_name=name.split(u' ', 1)[-1], display_name=name)
+                song.authors.append(author)
             if song.title is None:
                 song.title = u''
             if song.alternate_title is None:


Follow ups