]> git.phdru.name Git - m_librarian.git/blob - m_librarian/web/views/list_authors.py
Feat(web): В таблицах авторов и книг добавить заголовки колонок
[m_librarian.git] / m_librarian / web / views / list_authors.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 from views.search_authors_form import search_authors_form
32
33 ##################################################
34 ## MODULE CONSTANTS
35 VFFSL=valueFromFrameOrSearchList
36 VFSL=valueFromSearchList
37 VFN=valueForName
38 currentTime=time.time
39 __CHEETAH_version__ = '3.1.0'
40 __CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
41 __CHEETAH_genTime__ = 1528717961.404398
42 __CHEETAH_genTimestamp__ = 'Mon Jun 11 14:52:41 2018'
43 __CHEETAH_src__ = 'list_authors.tmpl'
44 __CHEETAH_srcLastModified__ = 'Mon Jun 11 14:52:34 2018'
45 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
46
47 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
48     raise AssertionError(
49       'This template was compiled with Cheetah version'
50       ' %s. Templates compiled before version %s must be recompiled.'%(
51          __CHEETAH_version__, RequiredCheetahVersion))
52
53 ##################################################
54 ## CLASSES
55
56 class list_authors(layout):
57
58     ##################################################
59     ## CHEETAH GENERATED METHODS
60
61
62     def __init__(self, *args, **KWs):
63
64         super(list_authors, self).__init__(*args, **KWs)
65         if not self._CHEETAH__instanceInitialized:
66             cheetahKWArgs = {}
67             allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
68             for k,v in KWs.items():
69                 if k in allowedKWs: cheetahKWArgs[k] = v
70             self._initCheetahInstance(**cheetahKWArgs)
71         
72
73     def body(self, **KWS):
74
75
76
77         ## CHEETAH: generated from #def body at line 6, col 1.
78         trans = KWS.get("trans")
79         if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
80             trans = self.transaction # is None unless self.awake() was called
81         if not trans:
82             trans = DummyTransaction()
83             _dummyTrans = True
84         else: _dummyTrans = False
85         write = trans.response().write
86         SL = self._CHEETAH__searchList
87         _filter = self._CHEETAH__currentFilter
88         
89         ########################################
90         ## START - generated method body
91         
92         write(u'''<h1>\u041f\u043e\u0438\u0441\u043a \u0430\u0432\u0442\u043e\u0440\u043e\u0432</h1>
93 ''')
94         _v = VFFSL(SL,"search_authors_form",False)(searchList=VFFSL(SL,"searchList",True)) # u'$search_authors_form(searchList=$searchList)' on line 9, col 1
95         if _v is not None: write(_filter(_v, rawExpr=u'$search_authors_form(searchList=$searchList)')) # from line 9, col 1.
96         write(u'''
97
98 <h1>''')
99         _v = VFFSL(SL,"title",True) # u'$title' on line 11, col 5
100         if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 11, col 5.
101         write(u'''</h1>
102
103 ''')
104         if VFFSL(SL,"authors",True): # generated from line 13, col 1
105             write(u'''  <table>
106   <tr>
107   ''')
108             if False:
109                 _
110             _ = VFFSL(SL,"getattr",False)(VFFSL(SL,"translations",True), 'ugettext', None) or VFFSL(SL,"translations.gettext",True)
111             for column in VFFSL(SL,"columns",True): # generated from line 17, col 3
112                 write(u'''    <td style="text-align: center">''')
113                 if False:
114                     _(VFFSL(SL,"column",True))
115                 _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"_",False)(VFFSL(SL,"column",True))) # u'$cgi.escape($_($column))' on line 18, col 36
116                 if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($_($column))')) # from line 18, col 36.
117                 write(u'''</td>
118 ''')
119             write(u'''  </tr>
120 ''')
121             for author in VFFSL(SL,"authors",True): # generated from line 21, col 3
122                 write(u'''  <tr>
123 ''')
124                 for column in VFFSL(SL,"columns",True): # generated from line 23, col 3
125                     write(u'''    <td><a href="/books-by-author/''')
126                     _v = VFFSL(SL,"author.id",True) # u'$author.id' on line 24, col 35
127                     if _v is not None: write(_filter(_v, rawExpr=u'$author.id')) # from line 24, col 35.
128                     write(u'''/">
129     ''')
130                     _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 25, col 5
131                     if _v is not None: write(_filter(_v, rawExpr=u"$cgi.escape(unicode($getattr($author, $column) or ''))")) # from line 25, col 5.
132                     write(u'''
133     </a></td>
134 ''')
135                 write(u'''  </tr>
136 ''')
137             write(u'''  </table>
138 ''')
139         else: # generated from line 31, col 1
140             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>
141 ''')
142         
143         ########################################
144         ## END - generated method body
145         
146         return _dummyTrans and trans.response().getvalue() or ""
147         
148
149     def writeBody(self, **KWS):
150
151
152
153         ## CHEETAH: main method generated for this template
154         trans = KWS.get("trans")
155         if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
156             trans = self.transaction # is None unless self.awake() was called
157         if not trans:
158             trans = DummyTransaction()
159             _dummyTrans = True
160         else: _dummyTrans = False
161         write = trans.response().write
162         SL = self._CHEETAH__searchList
163         _filter = self._CHEETAH__currentFilter
164         
165         ########################################
166         ## START - generated method body
167         
168         
169         ########################################
170         ## END - generated method body
171         
172         return _dummyTrans and trans.response().getvalue() or ""
173         
174     ##################################################
175     ## CHEETAH GENERATED ATTRIBUTES
176
177
178     _CHEETAH__instanceInitialized = False
179
180     _CHEETAH_version = __CHEETAH_version__
181
182     _CHEETAH_versionTuple = __CHEETAH_versionTuple__
183
184     _CHEETAH_genTime = __CHEETAH_genTime__
185
186     _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
187
188     _CHEETAH_src = __CHEETAH_src__
189
190     _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
191
192     title = 'Список авторов'
193
194     _mainCheetahMethod_for_list_authors = 'writeBody'
195
196 ## END CLASS DEFINITION
197
198 if not hasattr(list_authors, '_initCheetahAttributes'):
199     templateAPIClass = getattr(list_authors,
200                                '_CHEETAH_templateClass',
201                                Template)
202     templateAPIClass._addCheetahPlumbingCodeToClass(list_authors)
203
204
205 # CHEETAH was developed by Tavis Rudd and Mike Orr
206 # with code, advice and input from many other volunteers.
207 # For more information visit http://cheetahtemplate.org/
208
209 ##################################################
210 ## if run from command line:
211 if __name__ == '__main__':
212     from Cheetah.TemplateCmdLineIface import CmdLineIface
213     CmdLineIface(templateObj=list_authors()).run()
214
215