Surplus_Up (2DU) 6 лет назад
Родитель
Сommit
8271da9c4f
6 измененных файлов с 81 добавлено и 21 удалено
  1. 6 2
      app.py
  2. 0 14
      route/tool/func.py
  3. 61 0
      route/topic_change.py
  4. 7 3
      route/topic_stop.py
  5. 5 0
      route/topic_tool.py
  6. 2 2
      version.json

+ 6 - 2
app.py

@@ -171,12 +171,12 @@ if setup_tool != 0:
     create_data['data'] = ['title', 'data']
     create_data['cache_data'] = ['title', 'data', 'id']
     create_data['history'] = ['id', 'title', 'data', 'date', 'ip', 'send', 'leng', 'hide', 'type']
-    create_data['rd'] = ['code', 'date', 'band', 'stop', 'agree']
+    create_data['rd'] = ['title', 'sub', 'code', 'date', 'band', 'stop', 'agree']
     create_data['user'] = ['id', 'pw', 'acl', 'date', 'encode']
     create_data['user_set'] = ['name', 'id', 'data']
     create_data['user_application'] = ['id', 'pw', 'date', 'encode', 'question', 'answer', 'ip', 'ua', 'token', 'email']
     create_data['ban'] = ['block', 'end', 'why', 'band', 'login']
-    create_data['topic'] = ['id', 'title', 'sub', 'data', 'date', 'ip', 'block', 'top', 'code']
+    create_data['topic'] = ['id', 'data', 'date', 'ip', 'block', 'top', 'code']
     create_data['rb'] = ['block', 'end', 'today', 'blocker', 'why', 'band']
     create_data['back'] = ['title', 'link', 'type']
     create_data['custom'] = ['user', 'css']
@@ -505,6 +505,10 @@ def topic_delete(topic_num = 1):
 def topic_tool(topic_num = 1):
     return topic_tool_2(conn, topic_num)
 
+@app.route('/thread/<int:topic_num>/change', methods=['POST', 'GET'])
+def topic_change(topic_num = 1):
+    return topic_change_2(conn, topic_num)
+
 @app.route('/thread/<int:topic_num>/admin/<int:num>')
 def topic_admin(topic_num = 1, num = 1):
     return topic_admin_2(conn, topic_num, num)

+ 0 - 14
route/tool/func.py

@@ -183,20 +183,6 @@ def captcha_get():
 def update(ver_num):
     print('----')
     # 업데이트 하위 호환 유지 함수
-    # v3.1.5
-    try:
-        num = 1
-        curs.execute(db_change('select title, sub from topic where id = "1" order by date asc'))
-        db_data = curs.fetchall()
-        if db_data:
-            for i in db_data:
-                curs.execute(db_change("update topic set code = ? where title = ? and sub = ? and id = '1'"), [str(num), i[0], i[1]])
-                num += 1
-
-            if num != 1:
-                print('Add topic code')
-    except:
-        pass
 
     if ver_num < 3160027:
         print('Add init set')

+ 61 - 0
route/topic_change.py

@@ -0,0 +1,61 @@
+from .tool.func import *
+
+def topic_change_2(conn, topic_num):
+    curs = conn.cursor()
+
+    if admin_check(None) != 1:
+        return re_error('/error/3')
+
+    ip = ip_check()
+    time = get_time()
+    topic_num = str(topic_num)
+
+    curs.execute(db_change("select title, sub from rd where code = ?"), [topic_num])
+    rd_d = curs.fetchall()
+    if not rd_d:
+        return redirect('/')
+
+    if flask.request.method == 'POST':
+        admin_check(None, 'move_topic (code ' + topic_num + ')')
+
+        curs.execute(db_change("select id from topic where code = ? order by id + 0 desc limit 1"), [topic_num])
+        topic_check = curs.fetchall()
+        if topic_check:
+            title_d = flask.request.form.get('title', 'test')
+            sub_d = flask.request.form.get('sub', 'test')
+
+            curs.execute(db_change("update rd set title = ?, sub = ? where code = ?"), [
+                title_d,
+                sub_d,
+                topic_num
+            ])
+
+            curs.execute(db_change("insert into topic (id, data, date, ip, top, code) values (?, ?, ?, ?, '1', ?)"), [
+                str(int(topic_check[0][0]) + 1),
+                'change name to ' + sub_d + '(' + title_d + ')',
+                time,
+                ip,
+                topic_num
+            ])
+
+            rd_plus(topic_num, time)
+
+        return redirect('/thread/' + topic_num)
+    else:
+        return easy_minify(flask.render_template(skin_check(),
+            imp = [load_lang('topic_setting'), wiki_set(), custom(), other2([0, 0])],
+            data = '''
+                <form method="post">
+                    ''' + load_lang('document_name') + '''
+                    <hr class=\"main_hr\">
+                    <input value="''' + rd_d[0][0] + '''" name="title" type="text">
+                    <hr class=\"main_hr\">
+                    ''' + load_lang('discussion_name') + '''
+                    <hr class=\"main_hr\">
+                    <input value="''' + rd_d[0][1] + '''" name="sub" type="text">
+                    <hr class=\"main_hr\">
+                    <button type="submit">''' + load_lang('save') + '''</button>
+                </form>
+            ''',
+            menu = [['thread/' + topic_num + '/tool', load_lang('return')]]
+        ))

+ 7 - 3
route/topic_stop.py

@@ -10,7 +10,14 @@ def topic_stop_2(conn, topic_num):
     time = get_time()
     topic_num = str(topic_num)
 
+    curs.execute(db_change("select stop, agree from rd where code = ?"), [topic_num])
+    rd_d = curs.fetchall()
+    if not rd_d:
+        return redirect('/')
+
     if flask.request.method == 'POST':
+        admin_check(3, 'change_topic_set (code ' + topic_num + ')')
+
         curs.execute(db_change("select id from topic where code = ? order by id + 0 desc limit 1"), [topic_num])
         topic_check = curs.fetchall()
         if topic_check:
@@ -51,8 +58,6 @@ def topic_stop_2(conn, topic_num):
             ['', 'Normal']
         ]
 
-        curs.execute(db_change("select stop, agree from rd where code = ? limit 1"), [topic_num])
-        rd_d = curs.fetchall()
         for i in for_list:
             if rd_d and rd_d[0][0] == i[0]:
                 stop_d_list = '<option value="' + i[0] + '">' + i[1] + '</option>' + stop_d_list
@@ -64,7 +69,6 @@ def topic_stop_2(conn, topic_num):
         return easy_minify(flask.render_template(skin_check(),
             imp = [load_lang('topic_setting'), wiki_set(), custom(), other2([0, 0])],
             data = '''
-                <hr class=\"main_hr\">
                 <form method="post">
                     <select name="stop_d">
                         ''' + stop_d_list + '''

+ 5 - 0
route/topic_tool.py

@@ -42,6 +42,11 @@ def topic_tool_2(conn, topic_num):
                         ''' + load_lang('topic_delete') + '''
                     </a>
                 </li>
+                <li>
+                    <a href="/thread/''' + topic_num + '''/change">
+                        ''' + load_lang('topic_name_change') + '''
+                    </a>
+                </li>
             </ul>
         '''
 

+ 2 - 2
version.json

@@ -1,7 +1,7 @@
 {
     "master" : {
-        "r_ver" : "v3.1.7-master-05",
-        "c_ver" : "3170400",
+        "r_ver" : "v3.1.7-master-07",
+        "c_ver" : "3170600",
         "s_ver" : "7"
     }, "stable" : {
         "r_ver" : "v3.1.6-stable-05",