2 # -*- coding: utf-8 -*-
7 ##################################################
13 import builtins as builtin
15 import __builtin__ as builtin
16 from os.path import getmtime, exists
19 from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
20 from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
21 from Cheetah.Template import Template
22 from Cheetah.DummyTransaction import *
23 from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
24 from Cheetah.CacheRegion import CacheRegion
25 import Cheetah.Filters as Filters
26 import Cheetah.ErrorCatchers as ErrorCatchers
27 from Cheetah.compat import unicode
29 from m_librarian.translations import translations
30 from views.layout import layout
32 ##################################################
34 VFFSL=valueFromFrameOrSearchList
35 VFSL=valueFromSearchList
38 __CHEETAH_version__ = '3.2.6'
39 __CHEETAH_versionTuple__ = (3, 2, 6, 'final', 0)
40 __CHEETAH_genTime__ = 1671305208.723562
41 __CHEETAH_genTimestamp__ = 'Sat Dec 17 22:26:48 2022'
42 __CHEETAH_src__ = 'list_books.tmpl'
43 __CHEETAH_srcLastModified__ = 'Sat Dec 17 22:26:46 2022'
44 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
46 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
48 'This template was compiled with Cheetah version'
49 ' %s. Templates compiled before version %s must be recompiled.'%(
50 __CHEETAH_version__, RequiredCheetahVersion))
52 ##################################################
55 class list_books(layout):
57 ##################################################
58 ## CHEETAH GENERATED METHODS
61 def __init__(self, *args, **KWs):
63 super(list_books, self).__init__(*args, **KWs)
64 if not self._CHEETAH__instanceInitialized:
66 allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
67 for k,v in KWs.items():
68 if k in allowedKWs: cheetahKWArgs[k] = v
69 self._initCheetahInstance(**cheetahKWArgs)
72 def body(self, **KWS):
76 ## CHEETAH: generated from #def body at line 6, col 1.
77 trans = KWS.get("trans")
78 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
79 trans = self.transaction # is None unless self.awake() was called
81 trans = DummyTransaction()
83 else: _dummyTrans = False
84 write = trans.response().write
85 SL = self._CHEETAH__searchList
86 _filter = self._CHEETAH__currentFilter
88 ########################################
89 ## START - generated method body
92 _v = VFFSL(SL,"title",True) # u'$title' on line 7, col 5
93 if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 7, col 5.
96 <script type="text/javascript" language="Javascript">
98 function toggleBooks(selector, value) {
99 cboxes = document.querySelectorAll(selector);
100 for (var i = 0; i < cboxes.length; i++) {
101 cboxes[i].checked = value;
105 function toggleAuthor(name, value) {
106 toggleBooks(\'input[type=checkbox][name^=\' + name + \']\', value);
109 function toggleSeries(name, value) {
110 toggleBooks(\'input[type=checkbox][name^=\' + name + \'_book]\', value);
116 if VFFSL(SL,"books_by_author",True): # generated from line 28, col 1
117 write(u''' <form action="/download/" method="POST" style="height: 80%">
118 <table style="width: 100%; height: 90%">
124 _ = VFFSL(SL,"getattr",False)(VFFSL(SL,"translations",True), 'ugettext', None) or VFFSL(SL,"translations.gettext",True)
125 for column in VFFSL(SL,"columns",True): # generated from line 34, col 3
126 write(u''' <td style="text-align: center">''')
128 _(VFFSL(SL,"column",True))
129 _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"_",False)(VFFSL(SL,"column",True))) # u'$cgi.escape($_($column))' on line 35, col 36
130 if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($_($column))')) # from line 35, col 36.
135 columns1 = VFFSL(SL,"len",False)(VFFSL(SL,"columns",True))+1
136 for anum, author in VFFSL(SL,"enumerate",False)(VFFSL(SL,"sorted",False)(VFFSL(SL,"books_by_author",True))): # generated from line 39, col 3
139 books = VFFSL(SL,"books_by_author",True)[VFFSL(SL,"author",True)]
141 <td><input type=checkbox name="a''')
142 _v = VFFSL(SL,"anum",True)+1 # u'${anum+1}' on line 44, col 35
143 if _v is not None: write(_filter(_v, rawExpr=u'${anum+1}')) # from line 44, col 35.
145 onClick="toggleAuthor(this.name, this.checked)"></td>
147 _v = VFFSL(SL,"columns1",True)-1 # u'${columns1-1}' on line 46, col 16
148 if _v is not None: write(_filter(_v, rawExpr=u'${columns1-1}')) # from line 46, col 16.
150 _v = VFFSL(SL,"author",True) # u'$author' on line 46, col 34
151 if _v is not None: write(_filter(_v, rawExpr=u'$author')) # from line 46, col 34.
155 for book in VFFSL(SL,"books",True): # generated from line 48, col 5
156 if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 49, col 5
157 series = VFFSL(SL,"book.series",True)
160 <td><input type=checkbox name="a''')
161 _v = VFFSL(SL,"anum",True)+1 # u'${anum+1}' on line 53, col 35
162 if _v is not None: write(_filter(_v, rawExpr=u'${anum+1}')) # from line 53, col 35.
164 _v = VFFSL(SL,"snum",True) # u'${snum}' on line 53, col 46
165 if _v is not None: write(_filter(_v, rawExpr=u'${snum}')) # from line 53, col 46.
167 onClick="toggleSeries(this.name, this.checked)"></td>
169 _v = VFFSL(SL,"columns1",True)-1 # u'${columns1-1}' on line 55, col 16
170 if _v is not None: write(_filter(_v, rawExpr=u'${columns1-1}')) # from line 55, col 16.
173 _v = VFFSL(SL,"author",True) # u'$author' on line 56, col 3
174 if _v is not None: write(_filter(_v, rawExpr=u'$author')) # from line 56, col 3.
175 write(u''' \u2014 <i>
177 if VFFSL(SL,"book.series",True): # generated from line 57, col 3
178 _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 58, col 1
179 if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 58, col 1.
180 else: # generated from line 59, col 3
181 write(u'''\u0412\u043d\u0435 \u0441\u0435\u0440\u0438\u0439''')
182 write(u''' </i></b></td>
186 <td><input type=checkbox name="a''')
187 _v = VFFSL(SL,"anum",True)+1 # u'${anum+1}' on line 66, col 35
188 if _v is not None: write(_filter(_v, rawExpr=u'${anum+1}')) # from line 66, col 35.
190 _v = VFFSL(SL,"snum",True) # u'${snum}' on line 66, col 46
191 if _v is not None: write(_filter(_v, rawExpr=u'${snum}')) # from line 66, col 46.
192 write(u'''_books" value="''')
193 _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 66, col 68
194 if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 66, col 68.
197 for column in VFFSL(SL,"columns",True): # generated from line 67, col 3
198 if VFFSL(SL,"column",True) in ('ser_no', 'size'): # generated from line 68, col 3
199 style = ' style="text-align: right; width: 5ex"'
200 else: # generated from line 70, col 3
203 _v = VFFSL(SL,"style",True) # u'$style' on line 73, col 6
204 if _v is not None: write(_filter(_v, rawExpr=u'$style')) # from line 73, col 6.
206 _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 73, col 13
207 if _v is not None: write(_filter(_v, rawExpr=u"$cgi.escape(unicode($getattr($book, $column) or ''))")) # from line 73, col 13.
214 _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 79, col 16
215 if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 79, col 16.
216 write(u'''" style="text-align: center"><input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c"></td>
221 else: # generated from line 83, col 1
222 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>
225 ########################################
226 ## END - generated method body
228 return _dummyTrans and trans.response().getvalue() or ""
231 def writeBody(self, **KWS):
235 ## CHEETAH: main method generated for this template
236 trans = KWS.get("trans")
237 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
238 trans = self.transaction # is None unless self.awake() was called
240 trans = DummyTransaction()
242 else: _dummyTrans = False
243 write = trans.response().write
244 SL = self._CHEETAH__searchList
245 _filter = self._CHEETAH__currentFilter
247 ########################################
248 ## START - generated method body
251 ########################################
252 ## END - generated method body
254 return _dummyTrans and trans.response().getvalue() or ""
256 ##################################################
257 ## CHEETAH GENERATED ATTRIBUTES
260 _CHEETAH__instanceInitialized = False
262 _CHEETAH_version = __CHEETAH_version__
264 _CHEETAH_versionTuple = __CHEETAH_versionTuple__
266 _CHEETAH_genTime = __CHEETAH_genTime__
268 _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
270 _CHEETAH_src = __CHEETAH_src__
272 _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
274 title = 'Список книг'
276 _mainCheetahMethod_for_list_books = 'writeBody'
278 ## END CLASS DEFINITION
280 if not hasattr(list_books, '_initCheetahAttributes'):
281 templateAPIClass = getattr(list_books,
282 '_CHEETAH_templateClass',
284 templateAPIClass._addCheetahPlumbingCodeToClass(list_books)
287 # CHEETAH was developed by Tavis Rudd and Mike Orr
288 # with code, advice and input from many other volunteers.
289 # For more information visit https://cheetahtemplate.org/
291 ##################################################
292 ## if run from command line:
293 if __name__ == '__main__':
294 from Cheetah.TemplateCmdLineIface import CmdLineIface
295 CmdLineIface(templateObj=list_books()).run()