From: Oleg Broytman Date: Mon, 11 Jun 2018 13:21:05 +0000 (+0300) Subject: Feat(db): Add book.genre_list_* properties X-Git-Tag: 0.1.4~2 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=924bbc89d4f1ffa35e747ca4a5d63601275c8760;p=m_librarian.git Feat(db): Add book.genre_list_* properties Comma-separated names and titles. --- diff --git a/m_librarian.conf.sample b/m_librarian.conf.sample index d8d707c..4b68519 100644 --- a/m_librarian.conf.sample +++ b/m_librarian.conf.sample @@ -33,8 +33,10 @@ author = fullname count # Full list of book columns: # book = title series ser_no archive file size lib_id deleted date # author1 author_list +# genre1name genre1title genre_name_list genre_title_list # author1 is just one author from the list if there are more than 1 # author_list is a comma-separated list of full names +# genre1*/genre_*_list is a (one of/list of) genres (names or titles) # Default column is just title book = ser_no title @@ -46,6 +48,8 @@ book = ser_no title # %f - file name in archive # %G - genre (one of), name # %g - genre (one of), title +# %J - genres (comma-separated names) +# %j - genres (comma-separated titles) # %l - language # %n - series number (or 0) # %s - series diff --git a/m_librarian/db.py b/m_librarian/db.py index 0350aae..88b0b11 100755 --- a/m_librarian/db.py +++ b/m_librarian/db.py @@ -80,6 +80,22 @@ class Book(SQLObject): def author_list(self): return u', '.join([a.fullname for a in self.authors]) + @property + def genre1name(self): + return self.genres[0].name + + @property + def genre1title(self): + return self.genres[0].title + + @property + def genre_name_list(self): + return u', '.join([g.name for g in self.genres]) + + @property + def genre_title_list(self): + return u', '.join([g.title for g in self.genres]) + class BookGenre(SQLObject): class sqlmeta: diff --git a/m_librarian/download.py b/m_librarian/download.py index 4cbf35b..281efca 100755 --- a/m_librarian/download.py +++ b/m_librarian/download.py @@ -47,6 +47,10 @@ def _compile_format(): new_format = u'%(gname)s' elif c == 'g': new_format = u'%(gtitle)s' + elif c == 'J': + new_format = u'%(gname_list)s' + elif c == 'j': + new_format = u'%(gtitle_list)s' elif c == 'l': new_format = u'%(language)s' elif c == 'n': @@ -88,6 +92,8 @@ def download(book, dest_path=None, lib_path=None, a_format=None): genre = book.genres[0] bdict['gname'] = genre.name bdict['gtitle'] = genre.title + bdict['gname_list'] = book.genre_name_list + bdict['gtitle_list'] = book.genre_title_list bdict['language'] = book.language.name bdict['ser_no'] = book.ser_no or 0 bdict['series'] = book.series diff --git a/m_librarian/translations/ru.mo b/m_librarian/translations/ru.mo index 8e5cee0..5794760 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 aff9316..4a70714 100644 --- a/m_librarian/translations/ru.po +++ b/m_librarian/translations/ru.po @@ -108,3 +108,15 @@ msgstr "Автор" msgid "author_list" msgstr "Авторы" + +msgid "genre1name" +msgstr "Жанр" + +msgid "genre1title" +msgstr "Жанр" + +msgid "genre_name_list" +msgstr "Список жанров" + +msgid "genre_title_list" +msgstr "Список жанров"