]> git.phdru.name Git - m_librarian.git/blob - m_librarian/web/views/list_books.py
90e74436b9d4d3173641d4def0fd38217088638e
[m_librarian.git] / m_librarian / web / views / list_books.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4
5
6
7 ##################################################
8 ## DEPENDENCIES
9 import sys
10 import os
11 import os.path
12 try:
13     import builtins as builtin
14 except ImportError:
15     import __builtin__ as builtin
16 from os.path import getmtime, exists
17 import time
18 import types
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 import cgi
29 from m_librarian.translations import translations
30 from views.layout import layout
31
32 ##################################################
33 ## MODULE CONSTANTS
34 VFFSL=valueFromFrameOrSearchList
35 VFSL=valueFromSearchList
36 VFN=valueForName
37 currentTime=time.time
38 __CHEETAH_version__ = '3.2.6'
39 __CHEETAH_versionTuple__ = (3, 2, 6, 'final', 0)
40 __CHEETAH_genTime__ = 1671291191.270126
41 __CHEETAH_genTimestamp__ = 'Sat Dec 17 18:33:11 2022'
42 __CHEETAH_src__ = 'list_books.tmpl'
43 __CHEETAH_srcLastModified__ = 'Sat Dec 17 18:33:09 2022'
44 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
45
46 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
47     raise AssertionError(
48       'This template was compiled with Cheetah version'
49       ' %s. Templates compiled before version %s must be recompiled.'%(
50          __CHEETAH_version__, RequiredCheetahVersion))
51
52 ##################################################
53 ## CLASSES
54
55 class list_books(layout):
56
57     ##################################################
58     ## CHEETAH GENERATED METHODS
59
60
61     def __init__(self, *args, **KWs):
62
63         super(list_books, self).__init__(*args, **KWs)
64         if not self._CHEETAH__instanceInitialized:
65             cheetahKWArgs = {}
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)
70         
71
72     def body(self, **KWS):
73
74
75
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
80         if not trans:
81             trans = DummyTransaction()
82             _dummyTrans = True
83         else: _dummyTrans = False
84         write = trans.response().write
85         SL = self._CHEETAH__searchList
86         _filter = self._CHEETAH__currentFilter
87         
88         ########################################
89         ## START - generated method body
90         
91         write(u'''<h1>''')
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.
94         write(u'''</h1>
95
96 ''')
97         if VFFSL(SL,"books_by_author",True): # generated from line 9, col 1
98             write(u'''  <form action="/download/" method="POST" style="height: 80%">
99   <table style="width: 100%; height: 90%">
100   <tr>
101   <td>&nbsp;</td>
102   ''')
103             if False:
104                 _
105             _ = VFFSL(SL,"getattr",False)(VFFSL(SL,"translations",True), 'ugettext', None) or VFFSL(SL,"translations.gettext",True)
106             for column in VFFSL(SL,"columns",True): # generated from line 15, col 3
107                 write(u'''    <td style="text-align: center">''')
108                 if False:
109                     _(VFFSL(SL,"column",True))
110                 _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"_",False)(VFFSL(SL,"column",True))) # u'$cgi.escape($_($column))' on line 16, col 36
111                 if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($_($column))')) # from line 16, col 36.
112                 write(u'''</td>
113 ''')
114             write(u'''  </tr>
115 ''')
116             columns1 = VFFSL(SL,"len",False)(VFFSL(SL,"columns",True))+1
117             for anum, author in VFFSL(SL,"enumerate",False)(VFFSL(SL,"sorted",False)(VFFSL(SL,"books_by_author",True))): # generated from line 20, col 3
118                 series = None
119                 snum = 0
120                 books = VFFSL(SL,"books_by_author",True)[VFFSL(SL,"author",True)]
121                 for book in VFFSL(SL,"books",True): # generated from line 24, col 5
122                     if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 25, col 5
123                         series = VFFSL(SL,"book.series",True)
124                         snum += 1
125                         write(u'''  <tr>
126   <td colspan="''')
127                         _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 29, col 16
128                         if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 29, col 16.
129                         write(u'''"><b>
130   ''')
131                         _v = VFFSL(SL,"author",True) # u'$author' on line 30, col 3
132                         if _v is not None: write(_filter(_v, rawExpr=u'$author')) # from line 30, col 3.
133                         write(u''' \u2014 <i>
134 ''')
135                         if VFFSL(SL,"book.series",True): # generated from line 31, col 3
136                             _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 32, col 1
137                             if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 32, col 1.
138                         else: # generated from line 33, col 3
139                             write(u'''\u0412\u043d\u0435 \u0441\u0435\u0440\u0438\u0439''')
140                         write(u'''  </i></b></td>
141   </tr>
142 ''')
143                     write(u'''  <tr>
144   <td><input type=checkbox name="a''')
145                     _v = VFFSL(SL,"anum",True)+1 # u'${anum+1}' on line 40, col 35
146                     if _v is not None: write(_filter(_v, rawExpr=u'${anum+1}')) # from line 40, col 35.
147                     write(u'''_s''')
148                     _v = VFFSL(SL,"snum",True) # u'${snum}' on line 40, col 46
149                     if _v is not None: write(_filter(_v, rawExpr=u'${snum}')) # from line 40, col 46.
150                     write(u'''_books" value="''')
151                     _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 40, col 68
152                     if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 40, col 68.
153                     write(u'''"></td>
154 ''')
155                     for column in VFFSL(SL,"columns",True): # generated from line 41, col 3
156                         if VFFSL(SL,"column",True) in ('ser_no', 'size'): # generated from line 42, col 3
157                             style = ' style="text-align: right; width: 5ex"'
158                         else: # generated from line 44, col 3
159                             style = ''
160                         write(u'''  <td''')
161                         _v = VFFSL(SL,"style",True) # u'$style' on line 47, col 6
162                         if _v is not None: write(_filter(_v, rawExpr=u'$style')) # from line 47, col 6.
163                         write(u'''>''')
164                         _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 47, col 13
165                         if _v is not None: write(_filter(_v, rawExpr=u"$cgi.escape(unicode($getattr($book, $column) or ''))")) # from line 47, col 13.
166                         write(u'''</td>
167 ''')
168                     write(u'''  </tr>
169 ''')
170             write(u'''  <tr>
171   <td colspan="''')
172             _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 53, col 16
173             if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 53, col 16.
174             write(u'''" style="text-align: center"><input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c"></td>
175   </tr>
176   </table>
177   </form>
178 ''')
179         else: # generated from line 57, col 1
180             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>
181 ''')
182         
183         ########################################
184         ## END - generated method body
185         
186         return _dummyTrans and trans.response().getvalue() or ""
187         
188
189     def writeBody(self, **KWS):
190
191
192
193         ## CHEETAH: main method generated for this template
194         trans = KWS.get("trans")
195         if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
196             trans = self.transaction # is None unless self.awake() was called
197         if not trans:
198             trans = DummyTransaction()
199             _dummyTrans = True
200         else: _dummyTrans = False
201         write = trans.response().write
202         SL = self._CHEETAH__searchList
203         _filter = self._CHEETAH__currentFilter
204         
205         ########################################
206         ## START - generated method body
207         
208         
209         ########################################
210         ## END - generated method body
211         
212         return _dummyTrans and trans.response().getvalue() or ""
213         
214     ##################################################
215     ## CHEETAH GENERATED ATTRIBUTES
216
217
218     _CHEETAH__instanceInitialized = False
219
220     _CHEETAH_version = __CHEETAH_version__
221
222     _CHEETAH_versionTuple = __CHEETAH_versionTuple__
223
224     _CHEETAH_genTime = __CHEETAH_genTime__
225
226     _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
227
228     _CHEETAH_src = __CHEETAH_src__
229
230     _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
231
232     title = 'Список книг'
233
234     _mainCheetahMethod_for_list_books = 'writeBody'
235
236 ## END CLASS DEFINITION
237
238 if not hasattr(list_books, '_initCheetahAttributes'):
239     templateAPIClass = getattr(list_books,
240                                '_CHEETAH_templateClass',
241                                Template)
242     templateAPIClass._addCheetahPlumbingCodeToClass(list_books)
243
244
245 # CHEETAH was developed by Tavis Rudd and Mike Orr
246 # with code, advice and input from many other volunteers.
247 # For more information visit https://cheetahtemplate.org/
248
249 ##################################################
250 ## if run from command line:
251 if __name__ == '__main__':
252     from Cheetah.TemplateCmdLineIface import CmdLineIface
253     CmdLineIface(templateObj=list_books()).run()
254
255