From 924bbc89d4f1ffa35e747ca4a5d63601275c8760 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 11 Jun 2018 16:21:05 +0300 Subject: [PATCH] Feat(db): Add book.genre_list_* properties Comma-separated names and titles. --- m_librarian.conf.sample | 4 ++++ m_librarian/db.py | 16 ++++++++++++++++ m_librarian/download.py | 6 ++++++ m_librarian/translations/ru.mo | Bin 1716 -> 1946 bytes m_librarian/translations/ru.po | 12 ++++++++++++ 5 files changed, 38 insertions(+) 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 8e5cee0cf805db4600b43a084744050744d6241f..5794760e7ef0daf1131438c8addd748e7d9c085b 100644 GIT binary patch delta 963 zcmZ{i&r6hH5XYxo+se`{w>10Z=8s!Yn?wp8LQ(SO#Y+fl!Xl#Xp;ibXHlvFjx=0>6 z2%Q2?lCnr>(m}*aJQCO?5(2OO3EJno?}Y22fq6gAcV^$2dFI`fnh(k1@4Bk@hPC21 z@UBy458zOY2X-%Rb_QnPIoJuSV2{Tidwc+%CjP|p!>)7iEb(z?0VdEdA$5xOCOX(G zRHJv!d3YYZ09AO=x#TQC4YCIH-Z$6VPz}GsYWNeX&L5bB2k;_1gbDgvk}A4cJygLo z4^7zSyyNk9s74)713iLMY^x8d(Hg;8xCJ%9uIoK`8GQg%H_k)(YFJBuOL4dWn>}$C zs$hr5dmue*z~h6?Vb7046@1~GfhqJ`*9%aCeR5s${01!Q#UGyd1sl=(&Lh}>Zsgip zSq2iaZg>^;Lk&6tb%9B!M$=HgpM@;QZsN+Twl<-^7Tedm#d4wRh+DX<31?F$>>BEJ zMWm+UtO501brG5V#C5p7xvT}(=ha~UOxt8OtljJis4t7?cAC5yPvfolCA`v7bDOcn zhoiatvs@^gRn@tN=!o1$s(~x6NAMdOp=R4ED}RW8k3}n!6dZg-X2cw`JVH0@Asbj-FuR{N(L|K*s)Ax^JOT(6)2%KsKGbAzwPzCkb&8OH>yw@)u04V;RdI12HVN=6g%MxWSL)l^5{>I8a|3vXOIZ*&9o2PnZO=Ns%H|M2_=YOpx!x-SdW zFTg%H1-sxp(^b 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 "Список жанров" -- 2.39.5