From: Oleg Broytman Date: Mon, 11 Jun 2018 13:04:35 +0000 (+0300) Subject: Feat(db): Add book.author1 property X-Git-Tag: 0.1.4~4 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=12e046208dda7a46efc4b02dde9a1cb507a940ba;p=m_librarian.git Feat(db): Add book.author1 property author1 is just one author from the list if there are more than 1. --- diff --git a/m_librarian.conf.sample b/m_librarian.conf.sample index 1377cf3..000e680 100644 --- a/m_librarian.conf.sample +++ b/m_librarian.conf.sample @@ -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 diff --git a/m_librarian/db.py b/m_librarian/db.py index 0c41d4b..9081a42 100755 --- a/m_librarian/db.py +++ b/m_librarian/db.py @@ -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: diff --git a/m_librarian/download.py b/m_librarian/download.py index f1a41c7..744e1a0 100755 --- a/m_librarian/download.py +++ b/m_librarian/download.py @@ -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] diff --git a/m_librarian/translations/ru.mo b/m_librarian/translations/ru.mo index bd67d64..536ad10 100644 Binary files a/m_librarian/translations/ru.mo and b/m_librarian/translations/ru.mo differ diff --git a/m_librarian/translations/ru.po b/m_librarian/translations/ru.po index 9ccb069..f332a28 100644 --- a/m_librarian/translations/ru.po +++ b/m_librarian/translations/ru.po @@ -103,3 +103,5 @@ msgstr "Удалена" msgid "date" msgstr "Дата" +msgid "author1" +msgstr "Автор" diff --git a/m_librarian/web/app.py b/m_librarian/web/app.py index 5d9285e..d34b9df 100644 --- a/m_librarian/web/app.py +++ b/m_librarian/web/app.py @@ -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: diff --git a/tests/test_format.py b/tests/test_format.py index 6b3aa36..8d46e67 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -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'