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
28 from m_librarian.translations import translations
29 from views.layout import layout
31 ##################################################
33 VFFSL=valueFromFrameOrSearchList
34 VFSL=valueFromSearchList
37 __CHEETAH_version__ = '3.3.1'
38 __CHEETAH_versionTuple__ = (3, 3, 1, 'final', 0)
39 __CHEETAH_genTime__ = 1718725757.733093
40 __CHEETAH_genTimestamp__ = 'Tue Jun 18 18:49:17 2024'
41 __CHEETAH_src__ = 'list_books.tmpl'
42 __CHEETAH_srcLastModified__ = 'Tue Jun 18 18:49:15 2024'
43 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
45 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
47 'This template was compiled with Cheetah version'
48 ' %s. Templates compiled before version %s must be recompiled.'%(
49 __CHEETAH_version__, RequiredCheetahVersion))
51 ##################################################
54 class list_books(layout):
56 ##################################################
57 ## CHEETAH GENERATED METHODS
60 def __init__(self, *args, **KWs):
62 super(list_books, self).__init__(*args, **KWs)
63 if not self._CHEETAH__instanceInitialized:
65 allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
66 for k,v in KWs.items():
67 if k in allowedKWs: cheetahKWArgs[k] = v
68 self._initCheetahInstance(**cheetahKWArgs)
71 def body(self, **KWS):
75 ## CHEETAH: generated from #def body at line 5, col 1.
76 trans = KWS.get("trans")
77 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
78 trans = self.transaction # is None unless self.awake() was called
80 trans = DummyTransaction()
82 else: _dummyTrans = False
83 write = trans.response().write
84 SL = self._CHEETAH__searchList
85 _filter = self._CHEETAH__currentFilter
87 ########################################
88 ## START - generated method body
91 _v = VFFSL(SL,"title",True) # u'$title' on line 6, col 5
92 if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 6, col 5.
95 <script type="text/javascript" language="Javascript">
97 function toggleBooks(selector, value) {
98 cboxes = document.querySelectorAll(selector);
99 for (var i = 0; i < cboxes.length; i++) {
100 cboxes[i].checked = value;
104 function toggleAll(value) {
105 toggleBooks(\'input[type=checkbox]\', value);
108 function toggleAuthor(name, value) {
109 toggleBooks(\'input[type=checkbox][name^=\' + name + \']\', value);
112 function toggleSeries(name, value) {
113 toggleBooks(\'input[type=checkbox][name^=\' + name + \'_book]\', value);
119 if VFFSL(SL,"books_by_author",True): # generated from line 31, col 1
120 _orig_filter_17563757 = _filter
121 filterName = u'WebSafe'
122 if "WebSafe" in self._CHEETAH__filters:
123 _filter = self._CHEETAH__currentFilter = self._CHEETAH__filters[filterName]
125 _filter = self._CHEETAH__currentFilter = \
126 self._CHEETAH__filters[filterName] = getattr(self._CHEETAH__filtersLib, filterName)(self).filter
127 write(u''' <form action="/download/" method="POST" style="height: 80%">
128 <table style="width: 100%; height: 90%">
130 <td><input type=checkbox name="_toggleAll"
131 onClick="toggleAll(this.checked)"></td>
135 _ = VFFSL(SL,"getattr",False)(VFFSL(SL,"translations",True), 'ugettext', None) or VFFSL(SL,"translations.gettext",True)
136 for column in VFFSL(SL,"columns",True): # generated from line 39, col 3
137 write(u''' <td style="text-align: center">''')
139 _(VFFSL(SL,"column",True))
140 _v = VFFSL(SL,"_",False)(VFFSL(SL,"column",True)) # u'$_($column)' on line 40, col 36
141 if _v is not None: write(_filter(_v, rawExpr=u'$_($column)')) # from line 40, col 36.
146 columns1 = VFFSL(SL,"len",False)(VFFSL(SL,"columns",True))+1
147 for anum, author in VFFSL(SL,"enumerate",False)(VFFSL(SL,"sorted",False)(VFFSL(SL,"books_by_author",True))): # generated from line 44, col 3
150 books = VFFSL(SL,"books_by_author",True)[VFFSL(SL,"author",True)]
152 <td><input type=checkbox name="a''')
153 _v = VFFSL(SL,"anum",True)+1 # u'${anum+1}' on line 49, col 35
154 if _v is not None: write(_filter(_v, rawExpr=u'${anum+1}')) # from line 49, col 35.
156 onClick="toggleAuthor(this.name, this.checked)"></td>
158 _v = VFFSL(SL,"columns1",True)-1 # u'${columns1-1}' on line 51, col 16
159 if _v is not None: write(_filter(_v, rawExpr=u'${columns1-1}')) # from line 51, col 16.
161 _v = VFFSL(SL,"author",True) # u'$author' on line 51, col 34
162 if _v is not None: write(_filter(_v, rawExpr=u'$author')) # from line 51, col 34.
166 for book in VFFSL(SL,"books",True): # generated from line 53, col 5
167 if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 54, col 5
168 series = VFFSL(SL,"book.series",True)
171 <td><input type=checkbox name="a''')
172 _v = VFFSL(SL,"anum",True)+1 # u'${anum+1}' on line 58, col 35
173 if _v is not None: write(_filter(_v, rawExpr=u'${anum+1}')) # from line 58, col 35.
175 _v = VFFSL(SL,"snum",True) # u'${snum}' on line 58, col 46
176 if _v is not None: write(_filter(_v, rawExpr=u'${snum}')) # from line 58, col 46.
178 onClick="toggleSeries(this.name, this.checked)"></td>
180 _v = VFFSL(SL,"columns1",True)-1 # u'${columns1-1}' on line 60, col 16
181 if _v is not None: write(_filter(_v, rawExpr=u'${columns1-1}')) # from line 60, col 16.
184 _v = VFFSL(SL,"author",True) # u'$author' on line 61, col 3
185 if _v is not None: write(_filter(_v, rawExpr=u'$author')) # from line 61, col 3.
186 write(u''' \u2014 <i>
188 if VFFSL(SL,"book.series",True): # generated from line 62, col 3
189 _v = VFFSL(SL,"series",True) # u'$series' on line 63, col 1
190 if _v is not None: write(_filter(_v, rawExpr=u'$series')) # from line 63, col 1.
192 else: # generated from line 64, col 3
193 write(u'''\u0412\u043d\u0435 \u0441\u0435\u0440\u0438\u0439''')
194 write(u''' </i></b></td>
198 <td><input type=checkbox name="a''')
199 _v = VFFSL(SL,"anum",True)+1 # u'${anum+1}' on line 71, col 35
200 if _v is not None: write(_filter(_v, rawExpr=u'${anum+1}')) # from line 71, col 35.
202 _v = VFFSL(SL,"snum",True) # u'${snum}' on line 71, col 46
203 if _v is not None: write(_filter(_v, rawExpr=u'${snum}')) # from line 71, col 46.
204 write(u'''_books" value="''')
205 _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 71, col 68
206 if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 71, col 68.
209 for column in VFFSL(SL,"columns",True): # generated from line 72, col 3
210 if VFFSL(SL,"column",True) in ('ser_no', 'size'): # generated from line 73, col 3
211 style = ' style="text-align: right; width: 5ex"'
212 else: # generated from line 75, col 3
215 _v = VFFSL(SL,"style",True) # u'$style' on line 78, col 6
216 if _v is not None: write(_filter(_v, rawExpr=u'$style')) # from line 78, col 6.
218 _v = VFFSL(SL,"unicode",False)(VFFSL(SL,"getattr",False)(VFFSL(SL,"book",True), VFFSL(SL,"column",True)) or '') # u"$unicode($getattr($book, $column) or '')" on line 78, col 13
219 if _v is not None: write(_filter(_v, rawExpr=u"$unicode($getattr($book, $column) or '')")) # from line 78, col 13.
226 _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 84, col 16
227 if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 84, col 16.
228 write(u'''" style="text-align: center"><input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c"></td>
233 _filter = self._CHEETAH__currentFilter = _orig_filter_17563757
234 else: # generated from line 89, col 1
235 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>
238 ########################################
239 ## END - generated method body
241 return _dummyTrans and trans.response().getvalue() or ""
244 def writeBody(self, **KWS):
248 ## CHEETAH: main method generated for this template
249 trans = KWS.get("trans")
250 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
251 trans = self.transaction # is None unless self.awake() was called
253 trans = DummyTransaction()
255 else: _dummyTrans = False
256 write = trans.response().write
257 SL = self._CHEETAH__searchList
258 _filter = self._CHEETAH__currentFilter
260 ########################################
261 ## START - generated method body
264 ########################################
265 ## END - generated method body
267 return _dummyTrans and trans.response().getvalue() or ""
269 ##################################################
270 ## CHEETAH GENERATED ATTRIBUTES
273 _CHEETAH__instanceInitialized = False
275 _CHEETAH_version = __CHEETAH_version__
277 _CHEETAH_versionTuple = __CHEETAH_versionTuple__
279 _CHEETAH_genTime = __CHEETAH_genTime__
281 _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
283 _CHEETAH_src = __CHEETAH_src__
285 _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
287 title = 'Список книг'
289 _mainCheetahMethod_for_list_books = 'writeBody'
291 ## END CLASS DEFINITION
293 if not hasattr(list_books, '_initCheetahAttributes'):
294 templateAPIClass = getattr(list_books,
295 '_CHEETAH_templateClass',
297 templateAPIClass._addCheetahPlumbingCodeToClass(list_books)
300 # CHEETAH was developed by Tavis Rudd and Mike Orr
301 # with code, advice and input from many other volunteers.
302 # For more information visit https://cheetahtemplate.org/
304 ##################################################
305 ## if run from command line:
306 if __name__ == '__main__':
307 from Cheetah.TemplateCmdLineIface import CmdLineIface
308 CmdLineIface(templateObj=list_books()).run()