From 12e046208dda7a46efc4b02dde9a1cb507a940ba Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 11 Jun 2018 16:04:35 +0300 Subject: [PATCH] Feat(db): Add book.author1 property author1 is just one author from the list if there are more than 1. --- m_librarian.conf.sample | 4 +++- m_librarian/db.py | 4 ++++ m_librarian/download.py | 4 ++-- m_librarian/translations/ru.mo | Bin 1632 -> 1667 bytes m_librarian/translations/ru.po | 2 ++ m_librarian/web/app.py | 2 +- tests/test_format.py | 2 +- 7 files changed, 13 insertions(+), 5 deletions(-) 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 bd67d64a2757706d0e6eafd7b2c2950811c3e9e9..536ad1042f36c58052aef0d20444f76e18487436 100644 GIT binary patch delta 690 zcmXw%F-QV&6vqFZXJ)CCnw6R@E!k2*V+0K?4nadx1kxfzNTOSCk!wqcTYIa~G_mlcK<&y!kYkz}Ns wB}b9uP#~vBmhoJ%bLth6Gn8pkk?C~3vsks&tkoOq_tD6O*ZK70op$u?4}kwM#Q*>R delta 675 zcmXw%J1hiI6o#*vePPC9yw+p46IP+wLZVWLL`9;|Y$=iGBowMC=tMQ4rjW4hG)hs@ zXjGf9g-&!5AtJti_BhFz@1FnOod3+7ISkuD{2b*@9Z@Bx$e_!)8vKEZbI-XVynx;C z8s=bX`i<$gFpqw3`;S&X!4i7Q_zDZu?~p#R`{*p(7nIR2RHK65VPK4)jLT5xDppTJ z8O%X7u0svFX#2~iuNv1)--Jc{U4w-Tx8Oc+y#srw+qm_?HzSfl55e zupi2J7HXh6RG%fN^J_5HXV$mp*0V!0u8{wsMlw;1ka%RlC1s(($H`Gr{|`O0+W}dG lJSWIrQo~G=3Jt<7B*$JDYM4QZM3h{5yJ^*rz2qw2`U9sWF984m 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' -- 2.39.2