topic_comment_notice.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. from .tool.func import *
  2. def topic_comment_notice(topic_num = 1, num = 1):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. topic_num = str(topic_num)
  6. num = str(num)
  7. if admin_check(3, 'notice (code ' + topic_num + '#' + num + ')') != 1:
  8. return re_error('/error/3')
  9. curs.execute(db_change("select code from topic where code = ? and id = ?"), [topic_num, num])
  10. if curs.fetchall():
  11. curs.execute(db_change("select top from topic where code = ? and id = ?"), [topic_num, num])
  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 code = ? and id = ?"), [topic_num, num])
  16. else:
  17. curs.execute(db_change("update topic set top = 'O' where code = ? and id = ?"), [topic_num, num])
  18. do_reload_recent_thread(
  19. topic_num,
  20. get_time()
  21. )
  22. conn.commit()
  23. return redirect('/thread/' + topic_num + '#' + num)