Răsfoiți Sursa

block_log 정리

잉여개발기 (SPDV) 2 ani în urmă
părinte
comite
8822658e90
3 a modificat fișierele cu 44 adăugiri și 77 ștergeri
  1. 10 7
      app.py
  2. 1 1
      route/__init__.py
  3. 33 69
      route/recent_block.py

+ 10 - 7
app.py

@@ -452,13 +452,9 @@ app.route('/list/user/check/<name>/<do_type>/<int:arg_num>/<plus_name>')(list_us
 app.route('/list/user/check/delete/<name>/<ip>/<time>/<do_type>', methods = ['POST', 'GET'])(list_user_check_delete)
 
 # Func-auth
-# /auth/give
-# /auth/give/<name>
 app.route('/auth/give', methods = ['POST', 'GET'])(give_auth)
 app.route('/auth/give/<name>', methods = ['POST', 'GET'])(give_auth)
 
-# /auth/give
-# /auth/give/<name>
 app.route('/auth/give/ban', methods = ['POST', 'GET'])(give_user_ban)
 app.route('/auth/give/ban/<everything:name>', methods = ['POST', 'GET'])(give_user_ban)
 app.route('/auth/give/ban_regex/<everything:name>', methods = ['POST', 'GET'], defaults = { 'ban_type' : 'regex' })(give_user_ban)
@@ -477,9 +473,16 @@ app.route('/app_submit', methods = ['POST', 'GET'])(recent_app_submit_2)
 
 # /auth/history
 # ongoing 반영 필요
-app.route('/block_log')(recent_block_2)
-app.route('/block_log/<regex("user"):tool>/<name>')(recent_block_2)
-app.route('/block_log/<regex("admin"):tool>/<name>')(recent_block_2)
+app.route('/block_log')(recent_block)
+app.route('/block_log/<int:num>')(recent_block)
+app.route('/block_log/user/<name>', defaults = { 'tool' : 'user' })(recent_block)
+app.route('/block_log/user/<name>/<int:num>', defaults = { 'tool' : 'user' })(recent_block)
+app.route('/block_log/admin/<name>', defaults = { 'tool' : 'admin' })(recent_block)
+app.route('/block_log/admin/<name>/<int:num>', defaults = { 'tool' : 'admin' })(recent_block)
+app.route('/block_log/regex', defaults = { 'tool' : 'regex' })(recent_block)
+app.route('/block_log/regex/<int:num>', defaults = { 'tool' : 'regex' })(recent_block)
+app.route('/block_log/ongoing', defaults = { 'tool' : 'ongoing' })(recent_block)
+app.route('/block_log/ongoing/<int:num>', defaults = { 'tool' : 'ongoing' })(recent_block)
 
 # Func-history
 app.route('/recent_change', defaults = { 'tool' : 'recent' })(recent_change)

+ 1 - 1
route/__init__.py

@@ -107,7 +107,7 @@ from route.main_view_image import main_view_image
 
 from route.recent_app_submit import recent_app_submit_2
 
-from route.recent_block import recent_block_2
+from route.recent_block import recent_block
 from route.recent_change import recent_change
 from route.recent_discuss import recent_discuss
 from route.recent_history_add import recent_history_add

+ 33 - 69
route/recent_block.py

@@ -1,10 +1,9 @@
 from .tool.func import *
 
-def recent_block_2(name = 'Test', tool = 'all'):
+def recent_block(name = 'Test', tool = 'all', num = 1):
     with get_db_connect() as conn:
         curs = conn.cursor()
 
-        num = int(number_check(flask.request.args.get('num', '1')))
         sql_num = (num * 50 - 50) if num * 50 > 0 else 0
 
         div = '''
@@ -17,75 +16,40 @@ def recent_block_2(name = 'Test', tool = 'all'):
                     </tr>
         '''
 
-        get_type = flask.request.args.get('type', '')
-        sub_type = flask.request.args.get('s_type', '')
+        div = '' + \
+            '<a href="/block_log">(' + load_lang('all') + ')</a> ' + \
+            '<a href="/manager/11">(' + load_lang('blocked') + ')</a> ' + \
+            '<a href="/manager/12">(' + load_lang('admin') + ')</a> ' + \
+            '<a href="/block_log/ongoing">(' + load_lang('in_progress') + ')</a> ' + \
+            '<a href="/block_log/regex">(' + load_lang('regex') + ')</a>' + \
+            '<hr class="main_hr">' + \
+        '' + div
+
         if tool == 'all':
-            if get_type == 'ongoing':
-                sub = ' (' + load_lang('in_progress') + ')'
-
-                if sub_type == '':
-                    div = '' + \
-                        '<a href="?type=ongoing&s_type=regex">(' + load_lang('regex') + ')</a> ' + \
-                        '<a href="?type=ongoing&s_type=normal">(' + load_lang('normal') + ')</a>' + \
-                        '<hr class="main_hr">' + \
-                    '' + div
-                    menu = [['block_log', load_lang('return')]]
-                    plus_sql = ''
-                else:
-                    menu = [['block_log?type=ongoing', load_lang('return')]]
-
-                    if sub_type == 'regex':
-                        sub += ' (' + load_lang('regex') + ')'
-                        plus_sql = 'and band = \'regex\' '
-                    else:
-                        sub += ' (' + load_lang('normal') + ')'
-                        plus_sql = 'and band = \'\' '
-
-                curs.execute(db_change("" + \
-                    "select why, block, blocker, end, today, band, ongoing from rb " + \
-                    "where ((end > ? and end like '2%') or end = '') and ongoing = '1' " + plus_sql + \
-                    "order by end desc limit ?, 50" + \
-                ""), [
-                    get_time(),
-                    sql_num
-                ])
-            else:
-                sub = 0
-                menu = 0
-
-                div = '' + \
-                    '<a href="/manager/11">(' + load_lang('blocked') + ')</a> ' + \
-                    '<a href="/manager/12">(' + load_lang('admin') + ')</a> ' + \
-                    '<a href="?type=ongoing">(' + load_lang('in_progress') + ')</a>' + \
-                    '<hr class="main_hr">' + \
-                '' + div
-
-                curs.execute(db_change("" + \
-                    "select why, block, blocker, end, today, band, ongoing " + \
-                    "from rb order by today desc limit ?, 50" + \
-                ""), [sql_num])
+            sub = 0
+            menu = [['other', load_lang('return')]]
+
+            curs.execute(db_change("select why, block, blocker, end, today, band, ongoing from rb order by today desc limit ?, 50"), [sql_num])
+        elif tool == 'ongoing':
+            sub = '(' + load_lang('in_progress') + ')'
+            menu = [['other', load_lang('return')]]
+
+            curs.execute(db_change("select why, block, blocker, end, today, band, ongoing from rb where ongoing = '1' order by end desc limit ?, 50"), [sql_num])
+        elif tool == 'regex':
+            sub = '(' + load_lang('regex') + ')'
+            menu = [['other', load_lang('return')]]
+
+            curs.execute(db_change("select why, block, blocker, end, today, band, ongoing from rb where band = 'regex' order by today desc limit ?, 50"), [sql_num])
         elif tool == 'user':
-            sub = ' (' + load_lang('blocked') + ')'
-            menu = [['block_log', load_lang('normal')]]
-
-            curs.execute(db_change("" + \
-                "select why, block, blocker, end, today, band, ongoing " + \
-                "from rb where block = ? order by today desc limit ?, 50" + \
-            ""), [
-                name, 
-                sql_num
-            ])
+            sub = '(' + load_lang('blocked') + ')'
+            menu = [['other', load_lang('return')]]
+
+            curs.execute(db_change("select why, block, blocker, end, today, band, ongoing from rb where block = ? order by today desc limit ?, 50"), [name, sql_num])
         else:
-            sub = ' (' + load_lang('admin') + ')'
-            menu = [['block_log', load_lang('normal')]]
+            sub = '(' + load_lang('admin') + ')'
+            menu = [['other', load_lang('return')]]
 
-            curs.execute(db_change("" + \
-                "select why, block, blocker, end, today, band, ongoing " + \
-                "from rb where blocker = ? order by today desc limit ?, 50" + \
-            ""), [
-                name, 
-                sql_num
-            ])
+            curs.execute(db_change("select why, block, blocker, end, today, band, ongoing from rb where blocker = ? order by today desc limit ?, 50"), [name, sql_num])
 
         data_list = curs.fetchall()
         all_ip = ip_pas([i[1] for i in data_list] + [i[2] for i in data_list])
@@ -137,9 +101,9 @@ def recent_block_2(name = 'Test', tool = 'all'):
         div += '</table>'
 
         if tool == 'all':
-            div += next_fix('/block_log?num=', num, data_list)
+            div += next_fix('/block_log/', num, data_list)
         else:
-            div += next_fix('/block_log/' + url_pas(tool) + '/' + url_pas(name) + '?num=', num, data_list)
+            div += next_fix('/block_log/' + url_pas(tool) + '/' + url_pas(name) + '/', num, data_list)
 
         return easy_minify(flask.render_template(skin_check(),
             imp = [load_lang('recent_ban'), wiki_set(), wiki_custom(), wiki_css([sub, 0])],