]> git.phdru.name Git - m_librarian.git/blob - m_librarian/web/views/search_books_form.py
Feat(search): Использовать фильтры из файла конфигурации
[m_librarian.git] / m_librarian / web / views / search_books_form.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 from bottle import html_escape
29
30 ##################################################
31 ## MODULE CONSTANTS
32 VFFSL=valueFromFrameOrSearchList
33 VFSL=valueFromSearchList
34 VFN=valueForName
35 currentTime=time.time
36 __CHEETAH_version__ = '3.1.0'
37 __CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
38 __CHEETAH_genTime__ = 1528138831.71884
39 __CHEETAH_genTimestamp__ = 'Mon Jun  4 22:00:31 2018'
40 __CHEETAH_src__ = 'search_books_form.tmpl'
41 __CHEETAH_srcLastModified__ = 'Mon Jun  4 22:00:29 2018'
42 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
43
44 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
45     raise AssertionError(
46       'This template was compiled with Cheetah version'
47       ' %s. Templates compiled before version %s must be recompiled.'%(
48          __CHEETAH_version__, RequiredCheetahVersion))
49
50 ##################################################
51 ## CLASSES
52
53 class search_books_form(Template):
54
55     ##################################################
56     ## CHEETAH GENERATED METHODS
57
58
59     def __init__(self, *args, **KWs):
60
61         super(search_books_form, self).__init__(*args, **KWs)
62         if not self._CHEETAH__instanceInitialized:
63             cheetahKWArgs = {}
64             allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
65             for k,v in KWs.items():
66                 if k in allowedKWs: cheetahKWArgs[k] = v
67             self._initCheetahInstance(**cheetahKWArgs)
68         
69
70     def search_type_checked(self, value, **KWS):
71
72
73
74         ## CHEETAH: generated from #def $search_type_checked($value) at line 3, col 1.
75         trans = KWS.get("trans")
76         if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
77             trans = self.transaction # is None unless self.awake() was called
78         if not trans:
79             trans = DummyTransaction()
80             _dummyTrans = True
81         else: _dummyTrans = False
82         write = trans.response().write
83         SL = self._CHEETAH__searchList
84         _filter = self._CHEETAH__currentFilter
85         
86         ########################################
87         ## START - generated method body
88         
89         if VFFSL(SL,"getVar",False)('search_type', '') == VFFSL(SL,"value",True): # generated from line 4, col 1
90             write(u'''checked''')
91         
92         ########################################
93         ## END - generated method body
94         
95         return _dummyTrans and trans.response().getvalue() or ""
96         
97
98     def case_sensitive_checked(self, **KWS):
99
100
101
102         ## CHEETAH: generated from #def $case_sensitive_checked at line 8, col 1.
103         trans = KWS.get("trans")
104         if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
105             trans = self.transaction # is None unless self.awake() was called
106         if not trans:
107             trans = DummyTransaction()
108             _dummyTrans = True
109         else: _dummyTrans = False
110         write = trans.response().write
111         SL = self._CHEETAH__searchList
112         _filter = self._CHEETAH__currentFilter
113         
114         ########################################
115         ## START - generated method body
116         
117         if VFFSL(SL,"getVar",False)('case_sensitive', None): # generated from line 9, col 1
118             write(u'''checked''')
119         
120         ########################################
121         ## END - generated method body
122         
123         return _dummyTrans and trans.response().getvalue() or ""
124         
125
126     def use_filters_check(self, **KWS):
127
128
129
130         ## CHEETAH: generated from #def $use_filters_check at line 13, col 1.
131         trans = KWS.get("trans")
132         if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
133             trans = self.transaction # is None unless self.awake() was called
134         if not trans:
135             trans = DummyTransaction()
136             _dummyTrans = True
137         else: _dummyTrans = False
138         write = trans.response().write
139         SL = self._CHEETAH__searchList
140         _filter = self._CHEETAH__currentFilter
141         
142         ########################################
143         ## START - generated method body
144         
145         if VFFSL(SL,"getVar",False)('use_filters', VFN(VFFSL(SL,"get_config",False)(),"getint",False)('filters', 'use_in_search_forms')): # generated from line 14, col 1
146             write(u'''checked''')
147         
148         ########################################
149         ## END - generated method body
150         
151         return _dummyTrans and trans.response().getvalue() or ""
152         
153
154     def respond(self, trans=None):
155
156
157
158         ## CHEETAH: main method generated for this template
159         if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
160             trans = self.transaction # is None unless self.awake() was called
161         if not trans:
162             trans = DummyTransaction()
163             _dummyTrans = True
164         else: _dummyTrans = False
165         write = trans.response().write
166         SL = self._CHEETAH__searchList
167         _filter = self._CHEETAH__currentFilter
168         
169         ########################################
170         ## START - generated method body
171         
172         write(u'''<form action="/search_books/" method="POST">
173   <div style="width: 100%">
174   <input name="search_books" value="''')
175         _v = VFFSL(SL,"html_escape",False)(VFFSL(SL,"getVar",False)('search_books',
176   ''))
177         if _v is not None: write(_filter(_v, rawExpr=u"$html_escape($getVar('search_books',\n  ''))")) # from line 20, col 37.
178         write(u'''" type="text" style="width: 100%">
179   <br>
180   <input name="search_type" value="start" ''')
181         _v = VFFSL(SL,"search_type_checked",False)('start') # u"$search_type_checked('start')" on line 23, col 43
182         if _v is not None: write(_filter(_v, rawExpr=u"$search_type_checked('start')")) # from line 23, col 43.
183         write(u''' type="radio">
184   \u041f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435
185   <input name="search_type" value="substring" ''')
186         _v = VFFSL(SL,"search_type_checked",False)('substring') # u"$search_type_checked('substring')" on line 25, col 47
187         if _v is not None: write(_filter(_v, rawExpr=u"$search_type_checked('substring')")) # from line 25, col 47.
188         write(u''' type="radio">
189   \u041f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0430
190   <input name="search_type" value="full" ''')
191         _v = VFFSL(SL,"search_type_checked",False)('full') # u"$search_type_checked('full')" on line 27, col 42
192         if _v is not None: write(_filter(_v, rawExpr=u"$search_type_checked('full')")) # from line 27, col 42.
193         write(u''' type="radio">
194   \u0422\u043e\u0447\u043d\u043e\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435
195   <br>
196   <input name="case_sensitive" type="checkbox" ''')
197         _v = VFFSL(SL,"case_sensitive_checked",True) # u'$case_sensitive_checked' on line 30, col 48
198         if _v is not None: write(_filter(_v, rawExpr=u'$case_sensitive_checked')) # from line 30, col 48.
199         write(u'''>
200   \u0420\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u043f\u0438\u0441\u043d\u044b\u0435/\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0435
201   <input name="use_filters" type="checkbox" ''')
202         _v = VFFSL(SL,"use_filters_check",True) # u'$use_filters_check' on line 32, col 45
203         if _v is not None: write(_filter(_v, rawExpr=u'$use_filters_check')) # from line 32, col 45.
204         write(u'''>
205   \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u044b
206   </div>
207   <div style="width: 100%; text-align: center">
208   <input name="submit" type="submit">
209   </div>
210 </form>
211 ''')
212         
213         ########################################
214         ## END - generated method body
215         
216         return _dummyTrans and trans.response().getvalue() or ""
217         
218     ##################################################
219     ## CHEETAH GENERATED ATTRIBUTES
220
221
222     _CHEETAH__instanceInitialized = False
223
224     _CHEETAH_version = __CHEETAH_version__
225
226     _CHEETAH_versionTuple = __CHEETAH_versionTuple__
227
228     _CHEETAH_genTime = __CHEETAH_genTime__
229
230     _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
231
232     _CHEETAH_src = __CHEETAH_src__
233
234     _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
235
236     _mainCheetahMethod_for_search_books_form = 'respond'
237
238 ## END CLASS DEFINITION
239
240 if not hasattr(search_books_form, '_initCheetahAttributes'):
241     templateAPIClass = getattr(search_books_form,
242                                '_CHEETAH_templateClass',
243                                Template)
244     templateAPIClass._addCheetahPlumbingCodeToClass(search_books_form)
245
246
247 # CHEETAH was developed by Tavis Rudd and Mike Orr
248 # with code, advice and input from many other volunteers.
249 # For more information visit http://cheetahtemplate.org/
250
251 ##################################################
252 ## if run from command line:
253 if __name__ == '__main__':
254     from Cheetah.TemplateCmdLineIface import CmdLineIface
255     CmdLineIface(templateObj=search_books_form()).run()
256
257