topic_top.py 1.1 KB

123456789101112131415161718192021222324252627
  1. from .tool.func import *
  2. def topic_top_2(conn, topic_num, num):
  3. curs = conn.cursor()
  4. topic_change_data = topic_change(topic_num)
  5. name = topic_change_data[0]
  6. sub = topic_change_data[1]
  7. if admin_check(3, 'notice (' + name + ' - ' + sub + '#' + str(num) + ')') != 1:
  8. return re_error('/error/3')
  9. curs.execute(db_change("select title from topic where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
  10. if curs.fetchall():
  11. curs.execute(db_change("select top from topic where id = ? and title = ? and sub = ?"), [str(num), name, sub])
  12. top_data = curs.fetchall()
  13. if top_data:
  14. if top_data[0][0] == 'O':
  15. curs.execute(db_change("update topic set top = '' where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
  16. else:
  17. curs.execute(db_change("update topic set top = 'O' where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
  18. rd_plus(name, sub, get_time())
  19. conn.commit()
  20. return redirect('/thread/' + str(topic_num) + '#' + str(num))