topic_stop.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. from .tool.func import *
  2. def topic_stop_2(conn, topic_num):
  3. curs = conn.cursor()
  4. if admin_check(3) != 1:
  5. return re_error('/error/3')
  6. ip = ip_check()
  7. time = get_time()
  8. topic_num = str(topic_num)
  9. curs.execute(db_change("select stop, agree from rd where code = ?"), [topic_num])
  10. rd_d = curs.fetchall()
  11. if not rd_d:
  12. return redirect('/')
  13. if flask.request.method == 'POST':
  14. admin_check(3, 'change_topic_set (code ' + topic_num + ')')
  15. curs.execute(db_change("select id from topic where code = ? order by id + 0 desc limit 1"), [topic_num])
  16. topic_check = curs.fetchall()
  17. if topic_check:
  18. stop_d = flask.request.form.get('stop_d', '')
  19. why_d = flask.request.form.get('why', '')
  20. agree_d = flask.request.form.get('agree', '')
  21. curs.execute(db_change("update rd set stop = ?, agree = ? where code = ?"), [
  22. stop_d,
  23. agree_d,
  24. topic_num
  25. ])
  26. if stop_d == 'S':
  27. t_state = 'Stop'
  28. elif stop_d == 'O':
  29. t_state = 'Close'
  30. else:
  31. t_state = 'Normal'
  32. curs.execute(db_change("insert into topic (id, data, date, ip, top, code) values (?, ?, ?, ?, '1', ?)"), [
  33. str(int(topic_check[0][0]) + 1),
  34. t_state + (' (Agree)' if agree_d != '' else '') + (('[br][br]Why : ' + why_d) if why_d else ''),
  35. time,
  36. ip,
  37. topic_num
  38. ])
  39. rd_plus(topic_num, time)
  40. return redirect('/thread/' + topic_num)
  41. else:
  42. stop_d_list = ''
  43. agree_check = ''
  44. for_list = [
  45. ['O', 'Close'],
  46. ['S', 'Stop'],
  47. ['', 'Normal']
  48. ]
  49. for i in for_list:
  50. if rd_d and rd_d[0][0] == i[0]:
  51. stop_d_list = '<option value="' + i[0] + '">' + i[1] + '</option>' + stop_d_list
  52. else:
  53. stop_d_list += '<option value="' + i[0] + '">' + i[1] + '</option>'
  54. agree_check = 'checked="checked"' if rd_d[0][1] == 'O' else ''
  55. return easy_minify(flask.render_template(skin_check(),
  56. imp = [load_lang('topic_setting'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
  57. data = '''
  58. <form method="post">
  59. <select name="stop_d">
  60. ''' + stop_d_list + '''
  61. </select>
  62. <hr class=\"main_hr\">
  63. <input type="checkbox" name="agree" value="O" ''' + agree_check + '''> Agree
  64. <hr class=\"main_hr\">
  65. <input placeholder="''' + load_lang('why') + ''' (''' + load_lang('markup_enabled') + ''')" name="why" type="text">
  66. <hr class=\"main_hr\">
  67. <button type="submit">''' + load_lang('save') + '''</button>
  68. </form>
  69. ''',
  70. menu = [['thread/' + topic_num + '/tool', load_lang('return')]]
  71. ))