topic_stop.py 2.9 KB

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