Surplus_Up (2DU) 6 лет назад
Родитель
Сommit
90a287c234
8 измененных файлов с 136 добавлено и 159 удалено
  1. 3 3
      app.py
  2. 0 6
      language/en-US.json
  3. 4 5
      language/help_tool.py
  4. 0 6
      language/ko-KR.json
  5. 4 2
      route/topic.py
  6. 31 49
      route/topic_admin.py
  7. 67 56
      route/topic_stop.py
  8. 27 32
      route/topic_tool.py

+ 3 - 3
app.py

@@ -443,9 +443,9 @@ def topic_block(name = None, sub = None, num = 1):
 def topic_top(name = None, sub = None, num = 1):
     return topic_top_2(conn, name, sub, num)
                 
-@app.route('/topic/<everything:name>/sub/<sub>/tool/<regex("close|stop|agree"):tool>', methods=['POST', 'GET'])
-def topic_stop(name = None, sub = None, tool = None):
-    return topic_stop_2(conn, name, sub, tool)
+@app.route('/topic/<everything:name>/sub/<sub>/setting', methods=['POST', 'GET'])
+def topic_stop(name = None, sub = None):
+    return topic_stop_2(conn, name, sub)
 
 @app.route('/topic/<everything:name>/sub/<sub>/tool')
 def topic_tool(name = None, sub = None):

+ 0 - 6
language/en-US.json

@@ -263,12 +263,6 @@
         "_comment_2.5_" : "Topic tool",
             "topic_tool" : "Discussion tool",
             "topic_state" : "Discussion status",
-            "topic_stop" : "Stop discussion",
-            "topic_close" : "Close discussion",
-            "topic_restart" : "Discussion restart",
-            "topic_open" : "Open discussion",
-            "topic_agreement" : "Discussion agreement",
-            "topic_destruction" : "Cancel discussion agreement",
         "_comment_2.6_" : "Period",
             "1_day" : "1 day",
             "5_day" : "5 days",

+ 4 - 5
language/help_tool.py

@@ -1,19 +1,18 @@
 import re
 import json
 
-print('o_name : ', end = '')
-o_name = input()
-o_json = json.loads(open(o_name + '.json', encoding='utf-8').read())
+o_json = json.loads(open('en-US.json', encoding='utf-8').read())
 
 print('n_name : ', end = '')
 n_name = input()
 n_json = json.loads(open(n_name + '.json', encoding='utf-8').read())
 
-for i in n_json:
+print()
+for i in list(n_json):
     if not i in o_json:
         del n_json[i]
 
-for i in o_json:
+for i in list(o_json):
     if not re.search('^_', i[0]):
         if not i in n_json:
             print('o_title : ' + i)

+ 0 - 6
language/ko-KR.json

@@ -46,7 +46,6 @@
     "email_acl": "이메일을 가진 유저만",
     "email_error": "이런 이메일을 가진 사용자가 없습니다.",
     "version": "버전",
-    "topic_agreement": "토론 합의",
     "open": "열기",
     "update_branch": "업데이트를 가져올 브랜치",
     "edit_filter_error": "편집 필터에 의해 금지된 단어가 사용되었습니다.",
@@ -59,7 +58,6 @@
     "edit_record": "편집 기록",
     "preview": "미리보기",
     "no_login_error": "비로그인 상태입니다.",
-    "topic_destruction": "토론 합의 취소",
     "upload": "업로드",
     "user_name": "사용자 이름",
     "member_acl": "가입자만",
@@ -88,7 +86,6 @@
     "file_name_error": "파일 이름에는 알파벳, 한글, 공백, 밑줄 과 빼기 기호만 사용할 수 있습니다.",
     "pass": "넘기기",
     "recaptcha_error": "'나는 로봇이 아닙니다'를 통해 reCAPTCHA를 수행하세요.",
-    "topic_close": "토론 닫기",
     "file_capacity_error": "최대 파일 크기 (MB) :",
     "setting": "설정",
     "end": "끝",
@@ -105,7 +102,6 @@
     "wiki_port": "위키 포트",
     "limitless": "무기한",
     "normal": "일반",
-    "topic_open": "토론 열기",
     "reset_user_ok": "검사 성공",
     "in_progress": "진행중",
     "under_category": "하위 분류",
@@ -268,7 +264,6 @@
     "discussion_record": "토론 기록",
     "move": "이동",
     "recent_change": "최근 편집",
-    "topic_restart": "토론 중지 해제",
     "destruction": "취소",
     "count": "기여 횟수",
     "main_head": "전역 <head>",
@@ -288,7 +283,6 @@
     "360_day": "360일",
     "inter_error": "내부 오류.",
     "50_edit_acl": "기여 횟수 총합 50회 이상 가입자만",
-    "topic_stop": "토론 중지",
     "tool": "도구",
     "adsense_enable": "애드센스 사용",
     "list": "목록",

+ 4 - 2
route/topic.py

@@ -78,7 +78,7 @@ def topic_2(conn, name, sub):
     else:
         data = ''
     
-        curs.execute("select title from rd where title = ? and sub = ? and (stop = 'O' or stop = 'S')", [name, sub])
+        curs.execute("select stop from rd where title = ? and sub = ? and stop != ''", [name, sub])
         close_data = curs.fetchall()
         
         if close_data and admin != 1:
@@ -103,6 +103,8 @@ def topic_2(conn, name, sub):
 
         return easy_minify(flask.render_template(skin_check(), 
             imp = [name, wiki_set(), custom(), other2([' (' + load_lang('discussion') + ')', 0])],
-            data = '<h2 id="topic_top_title">' + sub + '</h2>' + data,
+            data = '''
+                <h2 id="topic_top_title">''' + sub + '''</h2>
+                ''' + data,
             menu = [['topic/' + url_pas(name), load_lang('list')]]
         ))

+ 31 - 49
route/topic_admin.py

@@ -8,67 +8,49 @@ def topic_admin_2(conn, name, sub, num):
     if not data:
         return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
 
-    ban = ''
-
-    if admin_check(3) == 1:
-        ban +=  '''
-            </ul>
-            <br>
-            <h2>''' + load_lang('admin_tool') + '''</h2>
-            <ul>
-        '''
-        is_ban = '<li><a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/b/' + str(num) + '">'
-
-        if data[0][0] == 'O':
-            is_ban += load_lang('hide_release')
-        else:
-            is_ban += load_lang('hide')
-        
-        is_ban += '''
-                </a>
-            </li>
+    ban = '''
+        <h2>''' + load_lang('state') + '''</h2>
+        <ul>
+            <li>''' + load_lang('writer') + ' : ''' + ip_pas(data[0][1]) + '''</li>
+            <li>''' + load_lang('time') + ' : ' + data[0][2] + '''</li>
+        </ul>
+        <br>
+        <h2>''' + load_lang('other_tool') + '''</h2>
+        <ul>
             <li>
-                <a href="/topic/''' + url_pas(name) + '/sub/' + url_pas(sub) + '/notice/' + str(num) + '''">
-        '''
+                <a href="/topic/''' + url_pas(name) + '/sub/' + url_pas(sub) + '/raw/' + str(num) + '''">''' + load_lang('raw') + '''</a>
+            </li>
+        </ul>
+    '''
 
+    if admin_check(3) == 1:
         curs.execute("select id from topic where title = ? and sub = ? and id = ? and top = 'O'", [name, sub, str(num)])
-        if curs.fetchall():
-            is_ban += load_lang('pinned_release')
-        else:
-            is_ban += load_lang('pinned') + ''
-        
-        is_ban += '</a></li></ul>'
-        ban += '<li><a href="/ban/' + url_pas(data[0][1]) + '">'
+        top_topic_d = curs.fetchall()
 
         curs.execute("select end from ban where block = ?", [data[0][1]])
-        if curs.fetchall():
-            ban += load_lang('ban_release')
-        else:
-            ban += load_lang('ban')
+        user_ban_d = curs.fetchall()
         
-        ban += '</a></li>' + is_ban
-
-    ban +=  '''
-            </ul>
+        ban += '''
             <br>
-            <h2>''' + load_lang('other_tool') + '''</h2>
+            <h2>''' + load_lang('admin_tool') + '''</h2>
             <ul>
                 <li>
-                    <a href="/topic/''' + url_pas(name) + '/sub/' + url_pas(sub) + '/raw/' + str(num) + '''">''' + load_lang('raw') + '''</a>
+                    <a href="/ban/''' + url_pas(data[0][1]) + '''">
+                        ''' + (load_lang('ban_release') if user_ban_d else load_lang('ban')) + '''
+                    </a>
                 </li>
-            '''
-    ban = '<li>' + load_lang('time') + ' : ' + data[0][2] + '</li>' + ban
-    
-    if ip_or_user(data[0][1]) == 1:
-        ban = '<li>' + load_lang('writer') + ' : ' + data[0][1] + ' <a href="/record/' + url_pas(data[0][1]) + '">(' + load_lang('record') + ')</a></li>' + ban
-    else:
-        ban =   '''
                 <li>
-                    ''' + load_lang('writer') + ' : <a href="/w/user:' + data[0][1] + '">' + data[0][1] + '</a> <a href="/record/' + url_pas(data[0][1]) + '">(' + load_lang('record') + ''')</a>
+                    <a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/b/' + str(num) + '">
+                    ''' + (load_lang('hide_release') if data[0][0] == 'O' else load_lang('hide')) + '''
+                    </a>
                 </li>
-                ''' + ban
-
-    ban = '<h2>' + load_lang('state') + '</h2><ul>' + ban
+                <li>
+                    <a href="/topic/''' + url_pas(name) + '/sub/' + url_pas(sub) + '/notice/' + str(num) + '''">
+                        ''' + (load_lang('pinned_release') if top_topic_d else load_lang('pinned')) + '''
+                    </a>
+                </li>
+            </ul>
+        '''
 
     return easy_minify(flask.render_template(skin_check(), 
         imp = [load_lang('discussion_tool'), wiki_set(), custom(), other2([' (#' + str(num) + ')', 0])],

+ 67 - 56
route/topic_stop.py

@@ -1,84 +1,95 @@
 from .tool.func import *
 
-def topic_stop_2(conn, name, sub, tool):
+def topic_stop_2(conn, name, sub):
     curs = conn.cursor()
 
-    if admin_check(3, 'topic ' + tool + ' (' + name + ' - ' + sub + ')') != 1:
+    if admin_check(3) != 1:
         return re_error('/error/3')
 
     ip = ip_check()
     time = get_time()
 
-    if flask.request.method == 'POST' or tool == 'agree' or tool == 'stop':
+    if flask.request.method == 'POST':
         curs.execute("select id from topic where title = ? and sub = ? order by id + 0 desc limit 1", [name, sub])
         topic_check = curs.fetchall()
         if topic_check:
-            if tool == 'agree':
-                curs.execute("select title from rd where title = ? and sub = ? and agree = 'O'", [name, sub])
-                if curs.fetchall():
-                    curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, 'ok', ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, time, ip])
-                    curs.execute("update rd set agree = '' where title = ? and sub = ?", [name, sub])
-                else:
-                    curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, 'break', ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, time, ip])
-                    curs.execute("update rd set agree = 'O' where title = ? and sub = ?", [name, sub])
+            stop_d = flask.request.form.get('stop_d', '')
+            why_d = flask.request.form.get('why', '')
+            agree_d = flask.request.form.get('agree', '')
+
+            curs.execute("update rd set stop = ?, agree = ? where title = ? and sub = ?", [
+                stop_d,
+                agree_d,
+                name, 
+                sub
+            ])
+
+            if stop_d == 'S':
+                t_state = 'Stop'
+            elif stop_d == 'O':
+                t_state = 'Close'
             else:
-                # 이 쪽 잘못 짜여 있음 내일 수정 필요
-                if tool == 'close':
-                    why = flask.request.form.get('why', '')
-                    set_list = [
-                        'O', 
-                        'S', 
-                        'close' + (('[br][br]why : ' + why) if why else ''), 
-                        'open' + (('[br][br]why : ' + why) if why else '')
-                    ]
-                elif tool == 'stop':
-                    set_list = [
-                        '', 
-                        'O', 
-                        'stop', 
-                        'restart'
-                    ]
-                else:
-                    return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
+                t_state = 'Normal'
+
+            curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')", [
+                str(int(topic_check[0][0]) + 1), 
+                name, 
+                sub, 
+                t_state + (' (Agree)' if agree_d != '' else '') + (('[br][br]Why : ' + why_d) if why_d else ''), 
+                time, 
+                ip
+            ])
 
-                curs.execute("select title from rd where title = ? and sub = ? and stop = ?", [name, sub, set_list[1]])
-                if curs.fetchall():
-                    curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')", [
-                        str(int(topic_check[0][0]) + 1),
-                        name, 
-                        sub, 
-                        set_list[3], 
-                        time, 
-                        ip
-                    ])
-                    curs.execute("update rd set stop = '' where title = ? and sub = ?", [name, sub])
-                else:
-                    curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')", [
-                        str(int(topic_check[0][0]) + 1), 
-                        name, 
-                        sub, 
-                        set_list[2], 
-                        time, 
-                        ip
-                    ])
-                    curs.execute("update rd set stop = ? where title = ? and sub = ?", [set_list[0], name, sub])
-            
             rd_plus(name, sub, time)
-            
-            conn.commit()
 
         return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))    
     else:
+        stop_d_list = ''
+        agree_check = ''
+
+        curs.execute("select stop, agree from rd where title = ? and sub = ? limit 1", [name, sub])
+        rd_d = curs.fetchall()
+        if rd_d[0][0] == 'O':
+            stop_d_list += '''
+                <option value="O">Close</option>
+                <option value="">Normal</option>
+                <option value="S">Stop</option>
+            '''
+        elif rd_d[0][0] == 'S':
+            stop_d_list += '''
+                <option value="S">Stop</option>
+                <option value="">Normal</option>
+                <option value="O">Close</option>
+            '''
+        else:
+            stop_d_list += '''
+                <option value="">Normal</option>
+                <option value="S">Stop</option>
+                <option value="O">Close</option>
+            '''
+
+        if rd_d[0][1] == 'O':
+            agree_check = 'checked="checked"'
+        else:
+            agree_check = ''
+
         return easy_minify(flask.render_template(skin_check(),
-            imp = [name, wiki_set(), custom(), other2([' (' + tool + ')', 0])],
+            imp = [name, wiki_set(), custom(), other2([' (topic_tool)', 0])],
             data = '''
-                <span>''' + load_lang('markup_enabled') + '''</span>
                 <hr class=\"main_hr\">
                 <form method="post">
+                    <select name="stop_d">
+                        ''' + stop_d_list + '''
+                    </select>
+                    <hr class=\"main_hr\">
+                    <input type="checkbox" name="agree" value="O" ''' + agree_check + '''> Agree
+                    <hr class=\"main_hr\">
                     <input placeholder="''' + load_lang('why') + '''" name="why" type="text">
                     <hr class=\"main_hr\">
+                    <span>''' + load_lang('markup_enabled') + '''</span>
+                    <hr class=\"main_hr\">
                     <button type="submit">''' + load_lang('save') + '''</button>
                 </form>
             ''',
-            menu = [['topic/' + url_pas(name) + '/sub/' + url_pas(sub), load_lang('return')]]
+            menu = [['topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool', load_lang('return')]]
         ))

+ 27 - 32
route/topic_tool.py

@@ -2,45 +2,40 @@ from .tool.func import *
 
 def topic_tool_2(conn, name, sub):
     curs = conn.cursor()
-    
-    curs.execute("select id from topic where title = ? and sub = ? limit 1", [name, sub])
-    topic_exist = curs.fetchall()
-    if not topic_exist:
-        return re_error('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
 
-    all_data = ''
+    data = ''
 
-    if admin_check(3) == 1:
-        all_data = '<h2>' + load_lang('topic_state') + '</h2><ul><li><a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/close">'
-
-        curs.execute("select title from rd where title = ? and sub = ? and stop = 'O'", [name, sub])
-        if curs.fetchall():
-            all_data += load_lang('topic_open')
+    curs.execute("select stop, agree from rd where title = ? and sub = ?", [name, sub])
+    close_data = curs.fetchall()
+    if close_data:
+        if close_data[0][0] == 'S':
+            t_state = 'Stop'
+        elif close_data[0][0] == 'O':
+            t_state = 'Close'
         else:
-            all_data += load_lang('topic_close')
-        
-        all_data += '</a></li><li><a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/stop">'
+            t_state = 'Normal'
+    else:
+        t_state = 'Normal'
 
-        curs.execute("select title from rd where title = ? and sub = ? and stop = 'S'", [name, sub])
-        if curs.fetchall():
-            all_data += load_lang('topic_restart')
-        else:
-            all_data += load_lang('topic_stop')
-            
-        all_data += '</a></li><li><a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/agree">'
-        
-        curs.execute("select title from rd where title = ? and sub = ? and agree = 'O'", [name, sub])
-        if curs.fetchall():
-            all_data += load_lang('topic_destruction')
-        else:
-            all_data += load_lang('topic_agreement')
-        
-        all_data += '</a></li></ul>'
+    if admin_check(3) == 1:
+        data = '''
+            <h2>''' + load_lang('admin_tool') + '''</h2>
+            <ul>
+                <li><a href="/topic/''' + url_pas(name) + '/sub/' + url_pas(sub) + '''/setting"> Topic setting</a></li>
+            </ul>
+        '''
 
-    all_data += '<h2>' + load_lang('tool') + '</h2><ul><li><a id="reload" href="javascript:void(0);" onclick="req_alarm();">' + load_lang('use_push_alarm') + '</a></li></ul>'
+    print(close_data)
+    data += '''
+        <h2>''' + load_lang('tool') + '''</h2>
+        <ul>
+            <li><a id="reload" href="javascript:void(0);" onclick="req_alarm();">''' + load_lang('use_push_alarm') + '''</a></li>
+            <li>''' + load_lang('topic_state') + ''' : ''' + t_state + '' + (' (Agree)' if close_data and (close_data[0][1] == 'O') else '') + '''</li>
+        </ul>
+    '''
 
     return easy_minify(flask.render_template(skin_check(), 
         imp = [name, wiki_set(), custom(), other2([' (' + load_lang('topic_tool') + ')', 0])],
-        data = all_data,
+        data = data,
         menu = [['topic/' + url_pas(name) + '/sub/' + url_pas(sub), load_lang('return')]]
     ))