Surplus_Up (2DU) преди 6 години
родител
ревизия
35a7c41672
променени са 5 файла, в които са добавени 35 реда и са изтрити 58 реда
  1. 3 3
      route/tool/func.py
  2. 3 5
      route/topic.py
  3. 17 27
      route/topic_close_list.py
  4. 11 22
      route/topic_stop.py
  5. 1 1
      route/topic_top.py

+ 3 - 3
route/tool/func.py

@@ -854,7 +854,7 @@ def acl_check(name = 'test', tool = '', topic_num = 'test'):
         end = 3
     elif tool == 'topic' or tool == 'render':
         if not name:
-            curs.execute(db_change("select title from topic where code = ? and id = '1'"), [topic_num])
+            curs.execute(db_change("select title from rd where code = ?"), [topic_num])
             topic_data = curs.fetchall()
             if topic_data:
                 name = topic_data[0][0]
@@ -1057,12 +1057,12 @@ def ban_insert(name, end, why, login, blocker, type_d = None):
 
     conn.commit()
 
-def rd_plus(topic_num, date):
+def rd_plus(topic_num, date, name = None, sub = None):
     curs.execute(db_change("select code from rd where code = ?"), [topic_num])
     if curs.fetchall():
         curs.execute(db_change("update rd set date = ? where code = ?"), [date, topic_num])
     else:
-        curs.execute(db_change("insert into rd (code, date) values (?, ?, ?)"), [topic_num, date])
+        curs.execute(db_change("insert into rd (title, sub, code, date) values (?, ?, ?, ?)"), [name, sub, topic_num, date])
 
     conn.commit()
 

+ 3 - 5
route/topic.py

@@ -10,7 +10,7 @@ def topic_2(conn, topic_num):
         name = flask.request.form.get('topic', 'test')
         sub = flask.request.form.get('title', 'test')
     else:
-        curs.execute(db_change("select title, sub from topic where code = ? and id = '1'"), [topic_num])
+        curs.execute(db_change("select title, sub from rd where code = ?"), [topic_num])
         name = curs.fetchall()
         if name:
             sub = name[0][1]
@@ -83,11 +83,9 @@ def topic_2(conn, topic_num):
         data = re.sub("(?P<in>#(?:[0-9]+))", '[[\g<in>]]', data)
         data = savemark(data)
 
-        rd_plus(topic_num, today)
-        curs.execute(db_change("insert into topic (id, title, sub, data, date, ip, code) values (?, ?, ?, ?, ?, ?, ?)"), [
+        rd_plus(topic_num, today, name, sub)
+        curs.execute(db_change("insert into topic (id, data, date, ip, code) values (?, ?, ?, ?, ?)"), [
             num,
-            name if num == 1 else '',
-            sub if num == 1 else '',
             data,
             today,
             ip,

+ 17 - 27
route/topic_close_list.py

@@ -10,11 +10,11 @@ def topic_close_list_2(conn, name):
     menu = [['topic/' + url_pas(name), load_lang('return')]]
 
     if tool == 'close':
-        curs.execute(db_change("select sub from rd where title = ? and stop = 'O' order by sub asc"), [name])
+        curs.execute(db_change("select code, sub from rd where title = ? and stop = 'O' order by sub asc"), [name])
 
         sub = load_lang('closed_discussion')
     elif tool == 'agree':
-        curs.execute(db_change("select sub from rd where title = ? and agree = 'O' order by sub asc"), [name])
+        curs.execute(db_change("select code, sub from rd where title = ? and agree = 'O' order by sub asc"), [name])
 
         sub = load_lang('agreed_discussion')
     else:
@@ -50,37 +50,27 @@ def topic_close_list_2(conn, name):
             <div id="see_preview"></div>
         '''
 
-        curs.execute(db_change("select sub from rd where title = ? order by date desc"), [name])
+        curs.execute(db_change("select code, sub from rd where title = ? and stop != 'O' order by date desc"), [name])
 
     t_num = 0
     for data in curs.fetchall():
         t_num += 1
+        t_str_num = str(t_num)
 
-        curs.execute(db_change("select code from topic where title = ? and sub = ? and id = '1'"), [name, data[0]])
-        first_topic = curs.fetchall()
-        if first_topic:
-            it_p = 0
-
-            if tool == '':
-                curs.execute(db_change("select title from rd where code = ? and stop != '' order by sub asc"), [first_topic[0][0]])
-                if curs.fetchall():
-                    it_p = 1
-
-            if it_p != 1:
-                curs.execute(db_change("select id from topic where code = ? order by date desc limit 1"), [first_topic[0][0]])
-                t_data = curs.fetchall()
+        curs.execute(db_change("select id from topic where code = ? order by date desc limit 1"), [data[0]])
+        t_data = curs.fetchall()
 
-                div += '''
-                    <h2><a href="/thread/''' + first_topic[0][0] + '">' + str(t_num) + '. ' + data[0] + '''</a></h2>
-                    <div id="topic_pre_''' + str(t_num) + '''"></div>
-                    <div id="topic_back_pre_''' + str(t_num) + '''"></div>
-                    <script>
-                        topic_list_load(''' + first_topic[0][0] + ', 1, "topic_pre_' + str(t_num) + '''");
-                        if(''' + str(t_data[0][0]) + ''' !== 1) {
-                            topic_list_load(''' + first_topic[0][0] + ', ' + t_data[0][0] + ', "topic_back_pre_' + str(t_num) + '''");
-                        }
-                    </script>
-                '''
+        div += '''
+            <h2><a href="/thread/''' + data[0] + '">' + t_str_num + '. ' + data[1] + '''</a></h2>
+            <div id="topic_pre_''' + t_str_num + '''"></div>
+            <div id="topic_back_pre_''' + t_str_num + '''"></div>
+            <script>
+                topic_list_load(''' + data[0] + ', 1, "topic_pre_' + t_str_num + '''");
+                if(''' + t_data[0][0] + ''' !== 1) {
+                    topic_list_load(''' + data[0] + ', ' + t_data[0][0] + ', "topic_back_pre_' + t_str_num + '''");
+                }
+            </script>
+        '''
 
     if div == '':
         plus = re.sub('^<br>', '', plus)

+ 11 - 22
route/topic_stop.py

@@ -45,32 +45,21 @@ def topic_stop_2(conn, topic_num):
     else:
         stop_d_list = ''
         agree_check = ''
+        for_list = [
+            ['O', 'Close'],
+            ['S', 'Stop'],
+            ['', 'Normal']
+        ]
 
         curs.execute(db_change("select stop, agree from rd where code = ? limit 1"), [topic_num])
         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>
-            '''
+        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
+            else:
+                stop_d_list += '<option value="' + i[0] + '">' + i[1] + '</option>'
 
-        if rd_d[0][1] == 'O':
-            agree_check = 'checked="checked"'
-        else:
-            agree_check = ''
+        agree_check = 'checked="checked"' if rd_d[0][1] == 'O' else ''
 
         return easy_minify(flask.render_template(skin_check(),
             imp = [load_lang('topic_setting'), wiki_set(), custom(), other2([0, 0])],

+ 1 - 1
route/topic_top.py

@@ -9,7 +9,7 @@ def topic_top_2(conn, topic_num, num):
     if admin_check(3, 'notice (code ' + topic_num + '#' + num + ')') != 1:
         return re_error('/error/3')
 
-    curs.execute(db_change("select title from topic where code = ? and id = ?"), [topic_num, num])
+    curs.execute(db_change("select code from topic where code = ? and id = ?"), [topic_num, num])
     if curs.fetchall():
         curs.execute(db_change("select top from topic where code = ? and id = ?"), [topic_num, num])
         top_data = curs.fetchall()