OSDN Git Service

mentenance
authoryamat0jp <yamat0jp@yahoo.co.jp>
Sat, 19 Nov 2016 08:35:05 +0000 (17:35 +0900)
committeryamat0jp <yamat0jp@yahoo.co.jp>
Sat, 19 Nov 2016 08:35:05 +0000 (17:35 +0900)
__pycache__/index.cpython-35.pyc
index.py
static/db/db.json

index cd7f056..4ce12b5 100644 (file)
Binary files a/__pycache__/index.cpython-35.pyc and b/__pycache__/index.cpython-35.pyc differ
index c079913..b5bf734 100755 (executable)
--- a/index.py
+++ b/index.py
@@ -1,5 +1,6 @@
 
 import os.path
+import shutil
 import tornado.auth
 import tornado.escape
 import tornado.web
@@ -173,10 +174,15 @@ class AdminConfHandler(BaseHandler):
     @tornado.web.authenticated
     def post(self,dbname,func):
         if func == 'set':
+            param = self.application.db.get(where('kinds') == 'conf')['mentenance']
             if self.get_argument('mente','') == 'on':
                 mente = True
+                if param != mente:
+                    self.store()
             else:
                 mente = False  
+                if param != mente:
+                    self.restore()
             word = self.get_argument('pass','')
             if word == '':
                 self.render('regist.htm',content='パスワードを設定してください')
@@ -187,6 +193,21 @@ class AdminConfHandler(BaseHandler):
             for x in self.get_arguments('item'):
                 table.remove(where('number') == int(x))
         self.redirect('/'+dbname+'/admin/0/')
+        
+    def store(self):
+        self.application.db.close()
+        shutil.copy('static/db/db.json','static/db/bak.json')
+        self.application.db = TinyDB('static/db/db.json')
+        
+    def restore(self):
+        database = self.application.db
+        bak = TinyDB('static/db/bak.json')
+        for x in database.tables():
+            if self.application.collection(x) == True:
+                database.purge_table(x)
+                if x in bak.tables():
+                    table = database.table(x)
+                    table.insert_multiple(bak.table(x).all())
           
 class UserHandler(tornado.web.RequestHandler):
     def post(self,dbname):
@@ -227,7 +248,7 @@ class Application(tornado.web.Application):
                         'ui_modules':{'Footer':FooterModule},
                         'cookie_secret':'bZJc2sWbQLKos6GkHn/VB9oXwQt8SOROkRvJ5/xJ89E=',
                         'xsrf_cookies':True,
-                        'debug':True,
+                        #'debug':True,
                         'login_url':'/login'
                         }
         tornado.web.Application.__init__(self,handlers,**settings)
index eeaa943..d68baa4 100644 (file)
@@ -1 +1 @@
-{"bbs": {"5": {"number": 1, "title": "\u3053\u306eBBS\u306f\u3059\u3054\u3044\u3067\u3059\u3002\u3002\u3002\uff20\uff20\uff1b", "password": "", "name": "None", "comment": "<p>\u3053\u306e\u63b2\u793a\u677f\u306f\u3059\u3054\u3044\u3067\u3059\u3002\u4f55\u304c\u3059\u3054\u3044\u306e\u304b\u5229\u7528\u8005\u306b\u306f\u308f\u304b\u3089\u306a\u3044\u3067\u3057\u3087\u3046\u3051\u308c\u3069\u3001\u7ba1\u7406\u8005\u306f\u7ba1\u7406\u304c\u3057\u3084\u3059\u3044\u3067\u3059\u3002\u7c21\u5358\u306b\u904b\u7528\u3067\u304d\u307e\u3059\u3002heroku\u3067git\u3059\u308c\u3070\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30af\u30ea\u30a2\u3057\u3066\u3059\u3050\u4f7f\u3048\u308b\u72b6\u614b\u306b\u306a\u308a\u307e\u3059\u3002\u6c17\u306b\u3057\u306a\u3044\u4eba\u306f\u305d\u306e\u307e\u307e\u4f7f\u3048\u307e\u3059\u3002\r\n<p>\u3000tornado\u3092\u4f7f\u7528\u3057\u3066\u66f8\u304b\u308c\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304c\u5927\u5909\u7c21\u7d20\u3067\u3059\u3002\u306a\u304a\u304b\u3064\u30d6\u30ed\u30b0\u30b7\u30b9\u30c6\u30e0\u306b\u30a2\u30c3\u30d7\u304c\u30b0\u30ec\u30fc\u30c9\u3055\u305b\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002\r\n<p>\u3000\u63b2\u793a\u677f\u306e\u7ba1\u7406\u306b\u5fc5\u8981\u306a\u62e1\u5f35\u3067\u3059\u304c\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u8ffd\u52a0\u306f\u7ba1\u7406\u8005\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u8ffd\u52a0\u3057\u305f\u3044URL\u3092\u6253\u3061\u8fbc\u3080\u3060\u3051\u3002\u305d\u3046\u3059\u308c\u3070\u81ea\u52d5\u3067\u4f5c\u6210\u3055\u308c\u305f\u65b0\u3057\u3044\u30c1\u30e3\u30f3\u30cd\u30eb\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u308c\u307e\u3059\u3002\r\n<p>\u3000\u3055\u3042\u4f7f\u3044\u305f\u304f\u306a\u308a\u307e\u3057\u305f\u304b\u3002", "date": "2016/11/18/16:17"}}, "bbs3": {}, "bbs2": {}, "_default": {"5": {"title": "pybbs", "mentenance": false, "count": 30, "password": "admin", "out_words": ["\u6b7b\u306d", "\u963f\u5446", "\u30a2\u30db", "\u99ac\u9e7f", "\u30d0\u30ab"], "title2": "<h1 style=color:gray;text-align:center>pybbs</h1>", "bad_words": ["<style", "<link", "<script", "<img"], "kinds": "conf"}}, "bbs1": {"1": {"number": 1, "title": "\u30bf\u30a4\u30c8\u30eb\u306a\u3057.", "password": "", "name": "", "comment": "<p>test", "date": "2016/11/19:44"}, "2": {"number": 2, "title": "\u30bf\u30a4\u30c8\u30eb\u306a\u3057.", "password": "", "name": "?", "comment": "<p>test date", "date": "2016/11/19 Nov:46"}, "3": {"number": 3, "title": "\u30bf\u30a4\u30c8\u30eb\u306a\u3057.", "password": "", "name": "?", "comment": "<p>test now", "date": "2016/11/19 15:47"}}}
\ No newline at end of file
+{"bbs": {"1": {"name": "None", "comment": "<p>\u3053\u306e\u63b2\u793a\u677f\u306f\u3059\u3054\u3044\u3067\u3059\u3002\u4f55\u304c\u3059\u3054\u3044\u306e\u304b\u5229\u7528\u8005\u306b\u306f\u308f\u304b\u3089\u306a\u3044\u3067\u3057\u3087\u3046\u3051\u308c\u3069\u3001\u7ba1\u7406\u8005\u306f\u7ba1\u7406\u304c\u3057\u3084\u3059\u3044\u3067\u3059\u3002\u7c21\u5358\u306b\u904b\u7528\u3067\u304d\u307e\u3059\u3002heroku\u3067git\u3059\u308c\u3070\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30af\u30ea\u30a2\u3057\u3066\u3059\u3050\u4f7f\u3048\u308b\u72b6\u614b\u306b\u306a\u308a\u307e\u3059\u3002\u6c17\u306b\u3057\u306a\u3044\u4eba\u306f\u305d\u306e\u307e\u307e\u4f7f\u3048\u307e\u3059\u3002\r\n<p>\u3000tornado\u3092\u4f7f\u7528\u3057\u3066\u66f8\u304b\u308c\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304c\u5927\u5909\u7c21\u7d20\u3067\u3059\u3002\u306a\u304a\u304b\u3064\u30d6\u30ed\u30b0\u30b7\u30b9\u30c6\u30e0\u306b\u30a2\u30c3\u30d7\u304c\u30b0\u30ec\u30fc\u30c9\u3055\u305b\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002\r\n<p>\u3000\u63b2\u793a\u677f\u306e\u7ba1\u7406\u306b\u5fc5\u8981\u306a\u62e1\u5f35\u3067\u3059\u304c\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u8ffd\u52a0\u306f\u7ba1\u7406\u8005\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u8ffd\u52a0\u3057\u305f\u3044URL\u3092\u6253\u3061\u8fbc\u3080\u3060\u3051\u3002\u305d\u3046\u3059\u308c\u3070\u81ea\u52d5\u3067\u4f5c\u6210\u3055\u308c\u305f\u65b0\u3057\u3044\u30c1\u30e3\u30f3\u30cd\u30eb\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u308c\u307e\u3059\u3002\r\n<p>\u3000\u3055\u3042\u4f7f\u3044\u305f\u304f\u306a\u308a\u307e\u3057\u305f\u304b\u3002", "number": 1, "date": "2016/11/18/16:17", "password": "", "title": "\u3053\u306eBBS\u306f\u3059\u3054\u3044\u3067\u3059\u3002\u3002\u3002\uff20\uff20\uff1b"}}, "bbs3": {}, "bbs1": {}, "bbs2": {}, "_default": {"1": {"bad_words": ["<style", "<link", "<script", "<img"], "title2": "<h1 style=color:gray;text-align:center>pybbs</h1>", "password": "admin", "title": "pybbs", "out_words": ["\u6b7b\u306d", "\u963f\u5446", "\u30a2\u30db", "\u99ac\u9e7f", "\u30d0\u30ab"], "kinds": "conf", "mentenance": false, "count": 30}}}
\ No newline at end of file