]> git.phdru.name Git - m_librarian.git/commitdiff
Feat(db): Add book.author1 property
authorOleg Broytman <phd@phdru.name>
Mon, 11 Jun 2018 13:04:35 +0000 (16:04 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 11 Jun 2018 13:54:59 +0000 (16:54 +0300)
author1 is just one author from the list if there are more than 1.

m_librarian.conf.sample
m_librarian/db.py
m_librarian/download.py
m_librarian/translations/ru.mo
m_librarian/translations/ru.po
m_librarian/web/app.py
tests/test_format.py

index 1377cf3e5c95d3269f08f2c46af82b24ede6bc25..000e680212dfc9f272f660ce7829b3764ad73682 100644 (file)
@@ -32,12 +32,14 @@ use_in_books_list = 1
 author = fullname count
 # Full list of book columns:
 # book = title series ser_no archive file size lib_id deleted date
+#        author1
+# author1 is just one author from the list if there are more than 1
 # Default column is just title
 book = ser_no title
 
 [download]
 # Download formats:
-# %a - author (one of)
+# %a - author1 (one of)
 # %e - file extension
 # %f - file name in archive
 # %G - genre (one of), name
index 0c41d4b7c9e70eb675bce95661576509688eab83..9081a422e0389b0da6f60c7cb94487b8ca3ed061 100755 (executable)
@@ -72,6 +72,10 @@ class Book(SQLObject):
     date_idx = DatabaseIndex(date)
     language_idx = DatabaseIndex(language)
 
+    @property
+    def author1(self):
+        return self.authors[0].fullname
+
 
 class BookGenre(SQLObject):
     class sqlmeta:
index f1a41c76d40243908f8f975557696d246f902b1a..744e1a0273c35f06c5d1489b53796cba9556cf43 100755 (executable)
@@ -36,7 +36,7 @@ def _compile_format():
             if got_percent:
                 got_percent = False
                 if c == 'a':
-                    new_format = u'%(author)s'
+                    new_format = u'%(author1)s'
                 elif c == 'e':
                     new_format = u'%(extension)s'
                 elif c == 'f':
@@ -79,7 +79,7 @@ def download(book, dest_path=None, lib_path=None, a_format=None):
     if compiled_format[-1] in ('\0', '\\', '/'):
         raise ValueError('Bad format: "%s"' % compiled_format)
     bdict = {}
-    bdict['author'] = book.authors[0].fullname
+    bdict['author1'] = book.author1
     bdict['extension'] = book.extension.name
     bdict['file'] = book.file
     genre = book.genres[0]
index bd67d64a2757706d0e6eafd7b2c2950811c3e9e9..536ad1042f36c58052aef0d20444f76e18487436 100644 (file)
Binary files a/m_librarian/translations/ru.mo and b/m_librarian/translations/ru.mo differ
index 9ccb0697b134232f10469cb9b1d9aec4a38b2f85..f332a28236b44c9004847ddaee3d69ffd31623d2 100644 (file)
@@ -103,3 +103,5 @@ msgstr "Удалена"
 msgid "date"
 msgstr "Дата"
 
+msgid "author1"
+msgstr "Автор"
index 5d9285e2254912b1f01404d9afaa4cebb41f6489..d34b9df64f83fc6b8521af7364e5b5b19927a67b 100644 (file)
@@ -156,7 +156,7 @@ def search_books_post():
                          orderBy=('title',), use_filters=use_filters)
     books_by_authors = {}
     for book in books:
-        author = book.authors[0].fullname
+        author = book.author1
         if author in books_by_authors:
             books_by_author = books_by_authors[author]
         else:
index 6b3aa363f3d440421b5657d09b9821dbe46a5e75..8d46e679e305c19c5d4f2cc524927bf44aa3b7dc 100644 (file)
@@ -12,4 +12,4 @@ def test_compile_format():
     ml_conf.set('download', 'format', '%a/%s/%n %t')
     download._compile_format()
     assert download.compiled_format == \
-        u'%(author)s/%(series)s/%(ser_no)d %(title)s'
+        u'%(author1)s/%(series)s/%(ser_no)d %(title)s'