]> git.phdru.name Git - m_librarian.git/commitdiff
Merge branch 'master' into wx
authorOleg Broytman <phd@phdru.name>
Wed, 10 Jan 2024 00:50:54 +0000 (03:50 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 10 Jan 2024 00:50:54 +0000 (03:50 +0300)
m_librarian/download.py
m_librarian/web/app.py
m_librarian/web/views/download.py
m_librarian/web/views/download.tmpl
m_librarian/web/views/search_authors_form.py
m_librarian/web/views/search_authors_form.tmpl
m_librarian/web/views/search_books_form.py
m_librarian/web/views/search_books_form.tmpl

index 281efcaf7a2c81b4f32013da206b71c314ea2f74..c0bc1010ca51365b50909fa14b3b7b92b3b387be 100755 (executable)
@@ -71,6 +71,8 @@ _library_path = None
 
 
 def download(book, dest_path=None, lib_path=None, a_format=None):
+    if dest_path is None:
+        dest_path = get_config().getpath('download', 'path')
     if lib_path is None:
         global _library_path
         if _library_path is None:
index 283ddb715b8b819fb0039c57bf375337eff84a1e..7885d4608d58cd15366430c3becb094ce7dec8a0 100644 (file)
@@ -65,16 +65,21 @@ def download_books():
             for bid in form.getall(k):
                 books_ids.append(bid)
     if books_ids:
-        download_path = get_config().getpath('download', 'path')
-        for bid in books_ids:
-            book = Book.get(int(bid))
-            download(book, download_path)
-        return {
-            'message': u'Книги сохранены.',
-        }
+        try:
+            for bid in books_ids:
+                book = Book.get(int(bid))
+                download(book)
+        except Exception as e:
+            return {
+                'error': str(e),
+            }
+        else:
+            return {
+                'message': u'Книги сохранены.',
+            }
     else:
         return {
-            'message': u'Не выбрано книг для сохранения.',
+            'error': u'Не выбрано книг для сохранения.',
         }
 
 
index ef05ca465e1bddc7aa0b8017ddf26416271ee6c8..c207ccbc05ea11d3921c64f95d477fdf60b5df52 100644 (file)
@@ -33,12 +33,12 @@ VFFSL=valueFromFrameOrSearchList
 VFSL=valueFromSearchList
 VFN=valueForName
 currentTime=time.time
-__CHEETAH_version__ = '3.1.0'
-__CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
-__CHEETAH_genTime__ = 1523146500.915016
-__CHEETAH_genTimestamp__ = 'Sun Apr  8 03:15:00 2018'
+__CHEETAH_version__ = '3.3.1'
+__CHEETAH_versionTuple__ = (3, 3, 1, 'final', 0)
+__CHEETAH_genTime__ = 1704845598.39619
+__CHEETAH_genTimestamp__ = 'Wed Jan 10 03:13:18 2024'
 __CHEETAH_src__ = 'download.tmpl'
-__CHEETAH_srcLastModified__ = 'Sun Apr  8 03:14:43 2018'
+__CHEETAH_srcLastModified__ = 'Wed Jan 10 03:10:53 2024'
 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
 
 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
@@ -91,10 +91,18 @@ class download(layout):
         if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 5, col 5.
         write(u'''</h1>
 
-<p>''')
-        _v = VFFSL(SL,"message",True) # u'$message' on line 7, col 4
-        if _v is not None: write(_filter(_v, rawExpr=u'$message')) # from line 7, col 4.
-        write(u'''</p>
+''')
+        if VFFSL(SL,"getVar",False)('error', None): # generated from line 7, col 1
+            write(u'''<p style="color: red">''')
+            _v = VFFSL(SL,"error",True) # u'$error' on line 8, col 23
+            if _v is not None: write(_filter(_v, rawExpr=u'$error')) # from line 8, col 23.
+            write(u'''</p>
+''')
+        else: # generated from line 9, col 1
+            write(u'''<p>''')
+            _v = VFFSL(SL,"message",True) # u'$message' on line 10, col 4
+            if _v is not None: write(_filter(_v, rawExpr=u'$message')) # from line 10, col 4.
+            write(u'''</p>
 ''')
         
         ########################################
@@ -161,7 +169,7 @@ if not hasattr(download, '_initCheetahAttributes'):
 
 # CHEETAH was developed by Tavis Rudd and Mike Orr
 # with code, advice and input from many other volunteers.
-# For more information visit http://cheetahtemplate.org/
+# For more information visit https://cheetahtemplate.org/
 
 ##################################################
 ## if run from command line:
index cf7e5bfae0930e58a7a5df7f37dfca0581268194..f9bf363697e803eb280e6cd65b1998ba05734b68 100644 (file)
@@ -4,5 +4,9 @@
 #def body
 <h1>$title</h1>
 
+#if $getVar('error', None)
+<p style="color: red">$error</p>
+#else
 <p>$message</p>
+#end if
 #end def
index b5229bcc507325c0d4cba0aaa330fd8262d576ce..ab02908feafec37ac80a74aa440c6bef71da4313 100644 (file)
@@ -33,12 +33,12 @@ VFFSL=valueFromFrameOrSearchList
 VFSL=valueFromSearchList
 VFN=valueForName
 currentTime=time.time
-__CHEETAH_version__ = '3.1.0'
-__CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
-__CHEETAH_genTime__ = 1527353789.984589
-__CHEETAH_genTimestamp__ = 'Sat May 26 19:56:29 2018'
+__CHEETAH_version__ = '3.3.1'
+__CHEETAH_versionTuple__ = (3, 3, 1, 'final', 0)
+__CHEETAH_genTime__ = 1704845598.452284
+__CHEETAH_genTimestamp__ = 'Wed Jan 10 03:13:18 2024'
 __CHEETAH_src__ = 'search_authors_form.tmpl'
-__CHEETAH_srcLastModified__ = 'Sat May 26 19:56:28 2018'
+__CHEETAH_srcLastModified__ = 'Wed Jan 10 03:02:59 2024'
 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
 
 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
@@ -172,7 +172,7 @@ class search_authors_form(Template):
   \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
   </div>
   <div style="width: 100%; text-align: center">
-  <input name="submit" type="submit">
+  <input name="submit" type="submit" value="\u0418\u0441\u043a\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u043e\u0432">
   </div>
 </form>
 ''')
@@ -213,7 +213,7 @@ if not hasattr(search_authors_form, '_initCheetahAttributes'):
 
 # CHEETAH was developed by Tavis Rudd and Mike Orr
 # with code, advice and input from many other volunteers.
-# For more information visit http://cheetahtemplate.org/
+# For more information visit https://cheetahtemplate.org/
 
 ##################################################
 ## if run from command line:
index 675d7cb05b5593dc19f89e01af72a9de6f703b3b..721f149e73c22c0c5f0900dbc49c8c8b9e00e281 100644 (file)
@@ -26,6 +26,6 @@ checked#slurp
   Различать прописные/строчные
   </div>
   <div style="width: 100%; text-align: center">
-  <input name="submit" type="submit">
+  <input name="submit" type="submit" value="Искать авторов">
   </div>
 </form>
index 487aaaf4a1052a093923ed70b8ab6b80c286029a..01b8770bb399e09d479a6c66c9190f10e816d4d3 100644 (file)
@@ -33,12 +33,12 @@ VFFSL=valueFromFrameOrSearchList
 VFSL=valueFromSearchList
 VFN=valueForName
 currentTime=time.time
-__CHEETAH_version__ = '3.1.0'
-__CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
-__CHEETAH_genTime__ = 1528667817.826233
-__CHEETAH_genTimestamp__ = 'Mon Jun 11 00:56:57 2018'
+__CHEETAH_version__ = '3.3.3'
+__CHEETAH_versionTuple__ = (3, 3, 3, 'final', 0)
+__CHEETAH_genTime__ = 1704324466.1203597
+__CHEETAH_genTimestamp__ = 'Thu Jan  4 02:27:46 2024'
 __CHEETAH_src__ = 'search_books_form.tmpl'
-__CHEETAH_srcLastModified__ = 'Mon Jun 11 00:30:36 2018'
+__CHEETAH_srcLastModified__ = 'Thu Jan  4 02:27:28 2024'
 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
 
 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
@@ -87,7 +87,7 @@ class search_books_form(Template):
         ## START - generated method body
         
         if VFFSL(SL,"getVar",False)('search_type', '') == VFFSL(SL,"value",True): # generated from line 4, col 1
-            write(u'''checked''')
+            write('''checked''')
         
         ########################################
         ## END - generated method body
@@ -115,7 +115,7 @@ class search_books_form(Template):
         ## START - generated method body
         
         if VFFSL(SL,"getVar",False)('case_sensitive', None): # generated from line 9, col 1
-            write(u'''checked''')
+            write('''checked''')
         
         ########################################
         ## END - generated method body
@@ -143,7 +143,7 @@ class search_books_form(Template):
         ## START - generated method body
         
         if VFFSL(SL,"getVar",False)('use_filters', VFN(VFFSL(SL,"get_config",False)(),"getint",False)('filters', 'use_in_search_forms', 1)): # generated from line 14, col 1
-            write(u'''checked''')
+            write('''checked''')
         
         ########################################
         ## END - generated method body
@@ -169,43 +169,43 @@ class search_books_form(Template):
         ########################################
         ## START - generated method body
         
-        write(u'''<form action="/search_books/" method="POST">
+        write('''<form action="/search_books/" method="POST">
   <div style="width: 100%">
   <input name="search_books" value="''')
         _v = VFFSL(SL,"html_escape",False)(VFFSL(SL,"getVar",False)('search_books',
   ''))
-        if _v is not None: write(_filter(_v, rawExpr=u"$html_escape($getVar('search_books',\n  ''))")) # from line 20, col 37.
-        write(u'''" type="text" style="width: 100%">
+        if _v is not None: write(_filter(_v, rawExpr="$html_escape($getVar('search_books',\n  ''))")) # from line 20, col 37.
+        write('''" type="text" style="width: 100%">
   <br>
   <input name="search_type" value="start" ''')
-        _v = VFFSL(SL,"search_type_checked",False)('start') # u"$search_type_checked('start')" on line 23, col 43
-        if _v is not None: write(_filter(_v, rawExpr=u"$search_type_checked('start')")) # from line 23, col 43.
-        write(u''' type="radio">
-  \u041f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435
+        _v = VFFSL(SL,"search_type_checked",False)('start') # "$search_type_checked('start')" on line 23, col 43
+        if _v is not None: write(_filter(_v, rawExpr="$search_type_checked('start')")) # from line 23, col 43.
+        write(''' type="radio">
+  Подстрока в начале
   <input name="search_type" value="substring" ''')
-        _v = VFFSL(SL,"search_type_checked",False)('substring') # u"$search_type_checked('substring')" on line 25, col 47
-        if _v is not None: write(_filter(_v, rawExpr=u"$search_type_checked('substring')")) # from line 25, col 47.
-        write(u''' type="radio">
-  \u041f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0430
+        _v = VFFSL(SL,"search_type_checked",False)('substring') # "$search_type_checked('substring')" on line 25, col 47
+        if _v is not None: write(_filter(_v, rawExpr="$search_type_checked('substring')")) # from line 25, col 47.
+        write(''' type="radio">
+  Подстрока
   <input name="search_type" value="full" ''')
-        _v = VFFSL(SL,"search_type_checked",False)('full') # u"$search_type_checked('full')" on line 27, col 42
-        if _v is not None: write(_filter(_v, rawExpr=u"$search_type_checked('full')")) # from line 27, col 42.
-        write(u''' type="radio">
-  \u0422\u043e\u0447\u043d\u043e\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435
+        _v = VFFSL(SL,"search_type_checked",False)('full') # "$search_type_checked('full')" on line 27, col 42
+        if _v is not None: write(_filter(_v, rawExpr="$search_type_checked('full')")) # from line 27, col 42.
+        write(''' type="radio">
+  Точное совпадение
   <br>
   <input name="case_sensitive" type="checkbox" ''')
-        _v = VFFSL(SL,"case_sensitive_checked",True) # u'$case_sensitive_checked' on line 30, col 48
-        if _v is not None: write(_filter(_v, rawExpr=u'$case_sensitive_checked')) # from line 30, col 48.
-        write(u'''>
-  \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
+        _v = VFFSL(SL,"case_sensitive_checked",True) # '$case_sensitive_checked' on line 30, col 48
+        if _v is not None: write(_filter(_v, rawExpr='$case_sensitive_checked')) # from line 30, col 48.
+        write('''>
+  Различать прописные/строчные
   <input name="use_filters" type="checkbox" ''')
-        _v = VFFSL(SL,"use_filters_check",True) # u'$use_filters_check' on line 32, col 45
-        if _v is not None: write(_filter(_v, rawExpr=u'$use_filters_check')) # from line 32, col 45.
-        write(u'''>
-  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u044b
+        _v = VFFSL(SL,"use_filters_check",True) # '$use_filters_check' on line 32, col 45
+        if _v is not None: write(_filter(_v, rawExpr='$use_filters_check')) # from line 32, col 45.
+        write('''>
+  Использовать фильтры
   </div>
   <div style="width: 100%; text-align: center">
-  <input name="submit" type="submit">
+  <input name="submit" type="submit" value="Искать книги">
   </div>
 </form>
 ''')
@@ -246,7 +246,7 @@ if not hasattr(search_books_form, '_initCheetahAttributes'):
 
 # CHEETAH was developed by Tavis Rudd and Mike Orr
 # with code, advice and input from many other volunteers.
-# For more information visit http://cheetahtemplate.org/
+# For more information visit https://cheetahtemplate.org/
 
 ##################################################
 ## if run from command line:
index d5e0c0ea8a019062ddfb204f427f23b417743b50..6ac0ca7137cee89c49fa912a9f512f47dd7975ea 100644 (file)
@@ -33,6 +33,6 @@ checked#slurp
   Использовать фильтры
   </div>
   <div style="width: 100%; text-align: center">
-  <input name="submit" type="submit">
+  <input name="submit" type="submit" value="Искать книги">
   </div>
 </form>