]> git.phdru.name Git - m_librarian.git/blob - m_librarian/web/views/books_by_author.py
Fix(web): Выровнять вправо размер книги
[m_librarian.git] / m_librarian / web / views / books_by_author.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.1.0'
39 __CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
40 __CHEETAH_genTime__ = 1528755605.645537
41 __CHEETAH_genTimestamp__ = 'Tue Jun 12 01:20:05 2018'
42 __CHEETAH_src__ = 'books_by_author.tmpl'
43 __CHEETAH_srcLastModified__ = 'Tue Jun 12 01:19:14 2018'
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 books_by_author(layout):
56
57     ##################################################
58     ## CHEETAH GENERATED METHODS
59
60
61     def __init__(self, *args, **KWs):
62
63         super(books_by_author, 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''' ''')
95         _v = VFFSL(SL,"author.fullname",True) # u'$author.fullname' on line 7, col 12
96         if _v is not None: write(_filter(_v, rawExpr=u'$author.fullname')) # from line 7, col 12.
97         write(u'''</h1>
98
99 ''')
100         if VFFSL(SL,"books",True): # generated from line 9, col 1
101             write(u'''  <form action="/download/" method="POST" style="height: 80%">
102   <table style="width: 100%; height: 90%">
103   <tr>
104   <td>&nbsp;</td>
105   ''')
106             if False:
107                 _
108             _ = VFFSL(SL,"getattr",False)(VFFSL(SL,"translations",True), 'ugettext', None) or VFFSL(SL,"translations.gettext",True)
109             for column in VFFSL(SL,"columns",True): # generated from line 15, col 3
110                 write(u'''    <td style="text-align: center">''')
111                 if False:
112                     _(VFFSL(SL,"column",True))
113                 _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"_",False)(VFFSL(SL,"column",True))) # u'$cgi.escape($_($column))' on line 16, col 36
114                 if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($_($column))')) # from line 16, col 36.
115                 write(u'''</td>
116 ''')
117             write(u'''  </tr>
118 ''')
119             series = None
120             columns1 = VFFSL(SL,"len",False)(VFFSL(SL,"columns",True))+1
121             for book in VFFSL(SL,"books",True): # generated from line 21, col 3
122                 if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 22, col 3
123                     series = VFFSL(SL,"book.series",True)
124                     write(u'''  <tr>
125   <td colspan="''')
126                     _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 25, col 16
127                     if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 25, col 16.
128                     write(u'''"><b><i>
129 ''')
130                     if VFFSL(SL,"book.series",True): # generated from line 26, col 3
131                         _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 27, col 1
132                         if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 27, col 1.
133                     else: # generated from line 28, col 3
134                         write(u'''\u0412\u043d\u0435 \u0441\u0435\u0440\u0438\u0439''')
135                     write(u'''  </i></b></td>
136   </tr>
137 ''')
138                 write(u'''  <tr>
139   <td><input type=checkbox name=books value="''')
140                 _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 35, col 46
141                 if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 35, col 46.
142                 write(u'''"></td>
143 ''')
144                 for column in VFFSL(SL,"columns",True): # generated from line 36, col 3
145                     if VFFSL(SL,"column",True) in ('ser_no', 'size'): # generated from line 37, col 3
146                         style = ' style="text-align: right; width: 5ex"'
147                     else: # generated from line 39, col 3
148                         style = ''
149                     write(u'''  <td''')
150                     _v = VFFSL(SL,"style",True) # u'$style' on line 42, col 6
151                     if _v is not None: write(_filter(_v, rawExpr=u'$style')) # from line 42, col 6.
152                     write(u'''>''')
153                     _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 42, col 13
154                     if _v is not None: write(_filter(_v, rawExpr=u"$cgi.escape(unicode($getattr($book, $column) or ''))")) # from line 42, col 13.
155                     write(u'''</td>
156 ''')
157                 write(u'''  </tr>
158 ''')
159             write(u'''  <tr>
160   <td colspan="''')
161             _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 47, col 16
162             if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 47, col 16.
163             write(u'''" style="text-align: center"><input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c"></td>
164   </tr>
165   </table>
166   </form>
167 ''')
168         else: # generated from line 51, col 1
169             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>
170 ''')
171         
172         ########################################
173         ## END - generated method body
174         
175         return _dummyTrans and trans.response().getvalue() or ""
176         
177
178     def writeBody(self, **KWS):
179
180
181
182         ## CHEETAH: main method generated for this template
183         trans = KWS.get("trans")
184         if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
185             trans = self.transaction # is None unless self.awake() was called
186         if not trans:
187             trans = DummyTransaction()
188             _dummyTrans = True
189         else: _dummyTrans = False
190         write = trans.response().write
191         SL = self._CHEETAH__searchList
192         _filter = self._CHEETAH__currentFilter
193         
194         ########################################
195         ## START - generated method body
196         
197         
198         ########################################
199         ## END - generated method body
200         
201         return _dummyTrans and trans.response().getvalue() or ""
202         
203     ##################################################
204     ## CHEETAH GENERATED ATTRIBUTES
205
206
207     _CHEETAH__instanceInitialized = False
208
209     _CHEETAH_version = __CHEETAH_version__
210
211     _CHEETAH_versionTuple = __CHEETAH_versionTuple__
212
213     _CHEETAH_genTime = __CHEETAH_genTime__
214
215     _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
216
217     _CHEETAH_src = __CHEETAH_src__
218
219     _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
220
221     title = 'Список книг автора'
222
223     _mainCheetahMethod_for_books_by_author = 'writeBody'
224
225 ## END CLASS DEFINITION
226
227 if not hasattr(books_by_author, '_initCheetahAttributes'):
228     templateAPIClass = getattr(books_by_author,
229                                '_CHEETAH_templateClass',
230                                Template)
231     templateAPIClass._addCheetahPlumbingCodeToClass(books_by_author)
232
233
234 # CHEETAH was developed by Tavis Rudd and Mike Orr
235 # with code, advice and input from many other volunteers.
236 # For more information visit http://cheetahtemplate.org/
237
238 ##################################################
239 ## if run from command line:
240 if __name__ == '__main__':
241     from Cheetah.TemplateCmdLineIface import CmdLineIface
242     CmdLineIface(templateObj=books_by_author()).run()
243
244