* Показывать список найденных книг с разбивкой по авторам и сериям.
+* Конфигурация списка колонок для таблиц авторов и книг.
+
* Файл конфигурации, все секции и все ключи сделаны необязательными.
* В файле конфигурации подставляются переменные окружения в ключах,
* Use filters from config.
+* Configure columns for author and book tables.
+
* Config file, all sections and all key are now completely optional.
* Environment variables are expanded in paths in config file.
)]
authors = search_authors(search_type, case_sensitive, {}, expressions,
orderBy=('surname', 'name', 'misc_name'))
+ columns = get_config().getlist('columns', 'author', ['fullname'])
return {
'authors': list(authors),
'search_authors': value,
'search_type': search_type,
'case_sensitive': case_sensitive,
+ 'columns': columns,
}
@cheetah_view('books_by_author.tmpl')
def books_by_author(id):
use_filters = get_config().getint('filters', 'use_in_books_list', 1)
+ columns = get_config().getlist('columns', 'book', ['title'])
if use_filters:
join_expressions = []
join_expressions.append(Book.j.authors)
return {
'author': Author.get(id),
'books': books,
+ 'columns': columns,
}
else:
return {
'books': Book.select(
Book.j.authors & (Author.q.id == id),
orderBy=['series', 'ser_no', 'title'],
- )
+ ),
+ 'columns': columns,
}
else:
books_by_author = books_by_authors[author] = []
books_by_author.append(book)
+ columns = get_config().getlist('columns', 'book', ['title'])
return {
'books_by_author': books_by_authors,
'search_books': value,
'search_type': search_type,
'case_sensitive': case_sensitive,
+ 'columns': columns,
}
currentTime=time.time
__CHEETAH_version__ = '3.1.0'
__CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
-__CHEETAH_genTime__ = 1528661355.623041
-__CHEETAH_genTimestamp__ = 'Sun Jun 10 23:09:15 2018'
+__CHEETAH_genTime__ = 1528670845.131662
+__CHEETAH_genTimestamp__ = 'Mon Jun 11 01:47:25 2018'
__CHEETAH_src__ = 'books_by_author.tmpl'
-__CHEETAH_srcLastModified__ = 'Sun Jun 10 23:09:14 2018'
+__CHEETAH_srcLastModified__ = 'Mon Jun 11 01:47:23 2018'
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
<table style="width: 100%; height: 90%">
''')
series = None
- for book in VFFSL(SL,"books",True): # generated from line 12, col 3
- if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 13, col 3
+ columns1 = VFFSL(SL,"len",False)(VFFSL(SL,"columns",True))+1
+ for book in VFFSL(SL,"books",True): # generated from line 13, col 3
+ if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 14, col 3
series = VFFSL(SL,"book.series",True)
write(u''' <tr>
- <td colspan=2><b><i>
+ <td colspan="''')
+ _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 17, col 16
+ if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 17, col 16.
+ write(u'''"><b><i>
''')
- if VFFSL(SL,"book.series",True): # generated from line 17, col 3
- _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 18, col 1
- if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 18, col 1.
- else: # generated from line 19, col 3
+ if VFFSL(SL,"book.series",True): # generated from line 18, col 3
+ _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 19, col 1
+ if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 19, col 1.
+ else: # generated from line 20, col 3
write(u'''\u0412\u043d\u0435 \u0441\u0435\u0440\u0438\u0439''')
write(u''' </i></b></td>
</tr>
''')
write(u''' <tr>
<td><input type=checkbox name=books value="''')
- _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 26, col 46
- if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 26, col 46.
+ _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 27, col 46
+ if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 27, col 46.
write(u'''"></td>
- <td>''')
- _v = VFFSL(SL,"book.ser_no",True) # u'$book.ser_no' on line 27, col 7
- if _v is not None: write(_filter(_v, rawExpr=u'$book.ser_no')) # from line 27, col 7.
- write(u''' ''')
- _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"book.title",True)) # u'$cgi.escape($book.title)' on line 27, col 20
- if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($book.title)')) # from line 27, col 20.
- write(u'''</td>
- </tr>
+''')
+ for column in VFFSL(SL,"columns",True): # generated from line 28, col 3
+ write(u''' <td>''')
+ _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(unicode(VFFSL(SL,"getattr",False)(VFFSL(SL,"book",True), VFFSL(SL,"column",True)) or '')) # u"$cgi.escape(unicode($getattr($book, $column) or ''))" on line 29, col 7
+ if _v is not None: write(_filter(_v, rawExpr=u"$cgi.escape(unicode($getattr($book, $column) or ''))")) # from line 29, col 7.
+ write(u'''</td>
+''')
+ write(u''' </tr>
''')
write(u''' <tr>
- <td colspan=2 style="text-align: center"><input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c"></td>
+ <td colspan="''')
+ _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 34, col 16
+ if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 34, col 16.
+ write(u'''" style="text-align: center"><input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c"></td>
</tr>
</table>
</form>
''')
- else: # generated from line 35, col 1
+ else: # generated from line 38, col 1
write(u''' <p>\u041d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438!</p>
''')
<form action="/download/" method="POST" style="height: 80%">
<table style="width: 100%; height: 90%">
#set $series = None
+ #set $columns1 = $len($columns)+1
#for $book in $books
#if $book.series != $series
#set $series = $book.series
<tr>
- <td colspan=2><b><i>
+ <td colspan="$columns1"><b><i>
#if $book.series
$cgi.escape($series, 1)#slurp
#else
#end if
<tr>
<td><input type=checkbox name=books value="$book.id"></td>
- <td>$book.ser_no $cgi.escape($book.title)</td>
+ #for $column in $columns
+ <td>$cgi.escape(unicode($getattr($book, $column) or ''))</td>
+ #end for
</tr>
#end for
<tr>
- <td colspan=2 style="text-align: center"><input type="submit" value="Скачать"></td>
+ <td colspan="$columns1" style="text-align: center"><input type="submit" value="Скачать"></td>
</tr>
</table>
</form>
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers
from Cheetah.compat import unicode
+import cgi
from views.layout import layout
from views.search_authors_form import search_authors_form
currentTime=time.time
__CHEETAH_version__ = '3.1.0'
__CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
-__CHEETAH_genTime__ = 1523134510.111994
-__CHEETAH_genTimestamp__ = 'Sat Apr 7 23:55:10 2018'
+__CHEETAH_genTime__ = 1528670903.492958
+__CHEETAH_genTimestamp__ = 'Mon Jun 11 01:48:23 2018'
__CHEETAH_src__ = 'list_authors.tmpl'
-__CHEETAH_srcLastModified__ = 'Sat Apr 7 23:55:07 2018'
+__CHEETAH_srcLastModified__ = 'Mon Jun 11 01:48:21 2018'
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
- ## CHEETAH: generated from #def body at line 4, col 1.
+ ## CHEETAH: generated from #def body at line 5, col 1.
trans = KWS.get("trans")
if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
trans = self.transaction # is None unless self.awake() was called
write(u'''<h1>\u041f\u043e\u0438\u0441\u043a \u0430\u0432\u0442\u043e\u0440\u043e\u0432</h1>
''')
- _v = VFFSL(SL,"search_authors_form",False)(searchList=VFFSL(SL,"searchList",True)) # u'$search_authors_form(searchList=$searchList)' on line 7, col 1
- if _v is not None: write(_filter(_v, rawExpr=u'$search_authors_form(searchList=$searchList)')) # from line 7, col 1.
+ _v = VFFSL(SL,"search_authors_form",False)(searchList=VFFSL(SL,"searchList",True)) # u'$search_authors_form(searchList=$searchList)' on line 8, col 1
+ if _v is not None: write(_filter(_v, rawExpr=u'$search_authors_form(searchList=$searchList)')) # from line 8, col 1.
write(u'''
<h1>''')
- _v = VFFSL(SL,"title",True) # u'$title' on line 9, col 5
- if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 9, col 5.
+ _v = VFFSL(SL,"title",True) # u'$title' on line 10, col 5
+ if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 10, col 5.
write(u'''</h1>
''')
- if VFFSL(SL,"authors",True): # generated from line 11, col 1
+ if VFFSL(SL,"authors",True): # generated from line 12, col 1
write(u''' <table>
''')
- for author in VFFSL(SL,"authors",True): # generated from line 13, col 3
+ for author in VFFSL(SL,"authors",True): # generated from line 14, col 3
write(u''' <tr>
- <td><a href="/books-by-author/''')
- _v = VFFSL(SL,"author.id",True) # u'$author.id' on line 15, col 35
- if _v is not None: write(_filter(_v, rawExpr=u'$author.id')) # from line 15, col 35.
- write(u'''/">''')
- _v = VFFSL(SL,"author.fullname",True) # u'$author.fullname' on line 15, col 48
- if _v is not None: write(_filter(_v, rawExpr=u'$author.fullname')) # from line 15, col 48.
- write(u'''</a></td>
- </tr>
+''')
+ for column in VFFSL(SL,"columns",True): # generated from line 16, col 3
+ write(u''' <td><a href="/books-by-author/''')
+ _v = VFFSL(SL,"author.id",True) # u'$author.id' on line 17, col 35
+ if _v is not None: write(_filter(_v, rawExpr=u'$author.id')) # from line 17, col 35.
+ write(u'''/">
+ ''')
+ _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(unicode(VFFSL(SL,"getattr",False)(VFFSL(SL,"author",True), VFFSL(SL,"column",True)) or '')) # u"$cgi.escape(unicode($getattr($author, $column) or ''))" on line 18, col 5
+ if _v is not None: write(_filter(_v, rawExpr=u"$cgi.escape(unicode($getattr($author, $column) or ''))")) # from line 18, col 5.
+ write(u'''
+ </a></td>
+''')
+ write(u''' </tr>
''')
write(u''' </table>
''')
- else: # generated from line 19, col 1
+ else: # generated from line 24, col 1
write(u''' <p>\u041d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u0440\u0430!</p>
''')
#encoding utf-8
+#import cgi
#extends views.layout
#attr $title = 'Список авторов'
#def body
<table>
#for $author in $authors
<tr>
- <td><a href="/books-by-author/$author.id/">$author.fullname</a></td>
+ #for $column in $columns
+ <td><a href="/books-by-author/$author.id/">
+ $cgi.escape(unicode($getattr($author, $column) or ''))
+ </a></td>
+ #end for
</tr>
#end for
</table>
currentTime=time.time
__CHEETAH_version__ = '3.1.0'
__CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
-__CHEETAH_genTime__ = 1528661355.731921
-__CHEETAH_genTimestamp__ = 'Sun Jun 10 23:09:15 2018'
+__CHEETAH_genTime__ = 1528670845.332275
+__CHEETAH_genTimestamp__ = 'Mon Jun 11 01:47:25 2018'
__CHEETAH_src__ = 'list_books.tmpl'
-__CHEETAH_srcLastModified__ = 'Sun Jun 10 23:09:01 2018'
+__CHEETAH_srcLastModified__ = 'Mon Jun 11 01:46:57 2018'
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
<table style="width: 100%; height: 90%">
''')
series = None
- for author in VFFSL(SL,"sorted",False)(VFFSL(SL,"books_by_author",True)): # generated from line 12, col 3
+ columns1 = VFFSL(SL,"len",False)(VFFSL(SL,"columns",True))+1
+ for author in VFFSL(SL,"sorted",False)(VFFSL(SL,"books_by_author",True)): # generated from line 13, col 3
books = VFFSL(SL,"books_by_author",True)[VFFSL(SL,"author",True)]
- for book in VFFSL(SL,"books",True): # generated from line 14, col 5
- if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 15, col 5
+ for book in VFFSL(SL,"books",True): # generated from line 15, col 5
+ if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 16, col 5
series = VFFSL(SL,"book.series",True)
write(u''' <tr>
- <td colspan=2><b>
+ <td colspan="''')
+ _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 19, col 16
+ if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 19, col 16.
+ write(u'''"><b>
''')
- _v = VFFSL(SL,"author",True) # u'$author' on line 19, col 3
- if _v is not None: write(_filter(_v, rawExpr=u'$author')) # from line 19, col 3.
+ _v = VFFSL(SL,"author",True) # u'$author' on line 20, col 3
+ if _v is not None: write(_filter(_v, rawExpr=u'$author')) # from line 20, col 3.
write(u''' \u2014 <i>
''')
- if VFFSL(SL,"book.series",True): # generated from line 20, col 3
- _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 21, col 1
- if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 21, col 1.
- else: # generated from line 22, col 3
+ if VFFSL(SL,"book.series",True): # generated from line 21, col 3
+ _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 22, col 1
+ if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 22, col 1.
+ else: # generated from line 23, col 3
write(u'''\u0412\u043d\u0435 \u0441\u0435\u0440\u0438\u0439''')
write(u''' </i></b></td>
</tr>
''')
write(u''' <tr>
<td><input type=checkbox name=books value="''')
- _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 29, col 46
- if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 29, col 46.
+ _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 30, col 46
+ if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 30, col 46.
write(u'''"></td>
- <td>''')
- _v = VFFSL(SL,"book.ser_no",True) # u'$book.ser_no' on line 30, col 7
- if _v is not None: write(_filter(_v, rawExpr=u'$book.ser_no')) # from line 30, col 7.
- write(u''' ''')
- _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"book.title",True)) # u'$cgi.escape($book.title)' on line 30, col 20
- if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($book.title)')) # from line 30, col 20.
- write(u'''</td>
- </tr>
+''')
+ for column in VFFSL(SL,"columns",True): # generated from line 31, col 3
+ write(u''' <td>''')
+ _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(unicode(VFFSL(SL,"getattr",False)(VFFSL(SL,"book",True), VFFSL(SL,"column",True)) or '')) # u"$cgi.escape(unicode($getattr($book, $column) or ''))" on line 32, col 7
+ if _v is not None: write(_filter(_v, rawExpr=u"$cgi.escape(unicode($getattr($book, $column) or ''))")) # from line 32, col 7.
+ write(u'''</td>
+''')
+ write(u''' </tr>
''')
write(u''' <tr>
- <td colspan=2 style="text-align: center"><input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c"></td>
+ <td colspan="''')
+ _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 38, col 16
+ if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 38, col 16.
+ write(u'''" style="text-align: center"><input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c"></td>
</tr>
</table>
</form>
''')
- else: # generated from line 39, col 1
+ else: # generated from line 42, col 1
write(u''' <p>\u041d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438!</p>
''')
<form action="/download/" method="POST" style="height: 80%">
<table style="width: 100%; height: 90%">
#set $series = None
+ #set $columns1 = $len($columns)+1
#for $author in $sorted($books_by_author)
#set $books = $books_by_author[$author]
#for $book in $books
#if $book.series != $series
#set $series = $book.series
<tr>
- <td colspan=2><b>
+ <td colspan="$columns1"><b>
$author — <i>
#if $book.series
$cgi.escape($series, 1)#slurp
#end if
<tr>
<td><input type=checkbox name=books value="$book.id"></td>
- <td>$book.ser_no $cgi.escape($book.title)</td>
+ #for $column in $columns
+ <td>$cgi.escape(unicode($getattr($book, $column) or ''))</td>
+ #end for
</tr>
#end for
#end for
<tr>
- <td colspan=2 style="text-align: center"><input type="submit" value="Скачать"></td>
+ <td colspan="$columns1" style="text-align: center"><input type="submit" value="Скачать"></td>
</tr>
</table>
</form>
# Use filters in lists of books
use_in_books_list = 1
+[columns]
+# Full list of author columns:
+# columns = surname name misc_name fullname count
+# Default column is fullname
+author = fullname count
+# Full list of book columns:
+# columns = title series ser_no archive file size lib_id deleted date
+# Default column is just title
+book = ser_no title
+
[download]
# Download formats:
# %a - author (one of)