topic_block.py 917 B

12345678910111213141516171819202122232425
  1. from .tool.func import *
  2. def topic_block_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, 'blind (' + name + ' - ' + sub + '#' + str(num) + ')') != 1:
  8. return re_error('/error/3')
  9. curs.execute(db_change("select block from topic where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
  10. block = curs.fetchall()
  11. if block:
  12. if block[0][0] == 'O':
  13. curs.execute(db_change("update topic set block = '' where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
  14. else:
  15. curs.execute(db_change("update topic set block = 'O' where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
  16. rd_plus(name, sub, get_time())
  17. conn.commit()
  18. return redirect('/thread/' + str(topic_num) + '#' + str(num))