Просмотр исходного кода

토론 닫기 사유 지정 가능

Surplus_Up (2DU) 7 лет назад
Родитель
Сommit
03a6afe2a1
6 измененных файлов с 79 добавлено и 61 удалено
  1. 1 1
      app.py
  2. 8 1
      language/en-US.json
  3. 10 3
      language/ko-KR.json
  4. 1 6
      route/topic.py
  5. 53 44
      route/topic_stop.py
  6. 6 6
      route/topic_tool.py

+ 1 - 1
app.py

@@ -433,7 +433,7 @@ 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>')
+@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)
 

+ 8 - 1
language/en-US.json

@@ -164,7 +164,13 @@
         "not_sure" : "Not sure",
         "use_push_alarm" : "Enable Push Notification",
         "topic_tool" : "Discussion tool",
-        "topic_state" : "Discussion state",
+        "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.1_" : "Filter",
             "_comment_2.1.1_" : "List",
                 "interwiki_list" : "Interwiki(s) list",
@@ -251,6 +257,7 @@
         "user_reset_sign" : "Your account information has changed like this.",
         "ban_explanation" : "If the blockout period is not set, it is an indefinite block.",
         "update_warring" : "Manual updates are recommended if your version is 0.2 or lower than the latest version.",
+        "markup_enabled" : "Markup enabled",
         "_comment_3.1_" : "Error",
             "update_error" : "Auto update is not support.",
             "inter_error" : "Internal error.",

+ 10 - 3
language/ko-KR.json

@@ -46,8 +46,8 @@
         "upload" : "업로드",
         "version" : "버전",
         "stop" : "중지",
-        "close" : "닫",
-        "open" : "",
+        "close" : "닫",
+        "open" : "열기",
         "agreement" : "동의",
         "template" : "틀",
         "category" : "분류",
@@ -56,7 +56,7 @@
         "editor" : "에디터",
         "hide" : "숨김",
         "check" : "검사",
-        "destruction" : "삭제",
+        "destruction" : "취소",
         "tool" : "도구",
         "recent" : "최근",
         "password" : "비밀번호",
@@ -165,6 +165,12 @@
         "use_push_alarm" : "푸쉬 알림 사용",
         "topic_tool" : "토론 도구",
         "topic_state" : "토론 상태",
+        "topic_stop" : "토론 중지",
+        "topic_close" : "토론 닫기",
+        "topic_restart" : "토론 중지 해제",
+        "topic_open" : "토론 열기",
+        "topic_agreement" : "토론 합의",
+        "topic_destruction" : "토론 합의 취소",
         "_comment_2.1_" : "필터",
             "_comment_2.1.1_" : "목록",
                 "interwiki_list" : "인터위키 목록",
@@ -251,6 +257,7 @@
         "user_reset_sign" : "사용자의 계정 정보가 다음과 같이 변경 되었습니다.",
         "ban_explanation" : "차단 기간이 정해지지 않으면 무기한 차단 입니다.",
         "update_warring" : "최신 버전보다 0.2 버전 이상 낮은 경우 수동 업데이트를 권장 드립니다.",
+        "markup_enabled" : "문법 사용 가능",
         "_comment_3.1_" : "오류",
             "update_error" : "자동 업데이트가 지원되지 않습니다.",
             "inter_error" : "내부 오류.",

+ 1 - 6
route/topic.py

@@ -191,12 +191,7 @@ def topic_2(conn, name, sub):
                 <form style="''' + display + '''" method="post">
                     <textarea style="height: 100px;" name="content"></textarea>
                     <hr class=\"main_hr\">
-            ''' + captcha_get()
-            
-            if display == '':
-                data += ip_warring()
-
-            data += '''
+                    ''' + captcha_get() + (ip_warring() if display == '' else '') + '''
                     <button type="submit">''' + load_lang('send') + '''</button>
                 </form>
             '''

+ 53 - 44
route/topic_stop.py

@@ -3,53 +3,62 @@ from .tool.func import *
 def topic_stop_2(conn, name, sub, tool):
     curs = conn.cursor()
 
-    if tool == 'close':
-        set_list = [
-            'O', 
-            'S', 
-            load_lang('close', 1), 
-            load_lang('open', 1)
-        ]
-    elif tool == 'stop':
-        set_list = [
-            '', 
-            'O', 
-            load_lang('stop', 1), 
-            load_lang('restart', 1)
-        ]
-    elif tool == 'agree':
-        pass
-    else:
-        return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub))
-
     if admin_check(3, 'topic ' + tool + ' (' + name + ' - ' + sub + ')') != 1:
         return re_error('/error/3')
 
     ip = ip_check()
     time = get_time()
-    
-    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 (?, ?, ?, '" + load_lang('agreement', 1) + " X', ?, ?, '', '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 (?, ?, ?, '" + load_lang('agreement', 1) + " O', ?, ?, '', '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])
-        else:
-            curs.execute("select title from rd where title = ? and sub = ? and stop = ?", [name, sub, set_list[0]])
-            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])
+
+    if flask.request.method == 'POST' or tool == 'agree' or tool == 'stop':
+        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])
             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))    
+                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))
+
+                curs.execute("select title from rd where title = ? and sub = ? and stop = ?", [name, sub, set_list[0]])
+                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:
+        return easy_minify(flask.render_template(skin_check(),
+            imp = [name, wiki_set(), custom(), other2([' (' + tool + ')', 0])],
+            data = '''
+                <span>''' + load_lang('markup_enabled') + '''</span>
+                <hr class=\"main_hr\">
+                <form method="post">
+                    <input placeholder="''' + load_lang('why') + '''" name="why" type="text">
+                    <hr class=\"main_hr\">
+                    <button type="submit">''' + load_lang('save') + '''</button>
+                </form>
+            ''',
+            menu = [['topic/' + url_pas(name) + '/sub/' + url_pas(sub), load_lang('return')]]
+        ))

+ 6 - 6
route/topic_tool.py

@@ -15,25 +15,25 @@ def topic_tool_2(conn, name, sub):
 
         curs.execute("select title from rd where title = ? and sub = ? and stop = 'O'", [name, sub])
         if curs.fetchall():
-            all_data += load_lang('open')
+            all_data += load_lang('topic_open')
         else:
-            all_data += load_lang('close')
+            all_data += load_lang('topic_close')
         
         all_data += '</a></li><li><a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/stop">'
 
         curs.execute("select title from rd where title = ? and sub = ? and stop = 'S'", [name, sub])
         if curs.fetchall():
-            all_data += load_lang('restart')
+            all_data += load_lang('topic_restart')
         else:
-            all_data += load_lang('stop')
+            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('destruction')
+            all_data += load_lang('topic_destruction')
         else:
-            all_data += load_lang('agreement')
+            all_data += load_lang('topic_agreement')
         
         all_data += '</a></li></ul>'