topic_stop.py 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. curs.execute(db_change("select stop, agree from rd where code = ? limit 1"), [topic_num])
  40. rd_d = curs.fetchall()
  41. if rd_d[0][0] == 'O':
  42. stop_d_list += '''
  43. <option value="O">Close</option>
  44. <option value="">Normal</option>
  45. <option value="S">Stop</option>
  46. '''
  47. elif rd_d[0][0] == 'S':
  48. stop_d_list += '''
  49. <option value="S">Stop</option>
  50. <option value="">Normal</option>
  51. <option value="O">Close</option>
  52. '''
  53. else:
  54. stop_d_list += '''
  55. <option value="">Normal</option>
  56. <option value="S">Stop</option>
  57. <option value="O">Close</option>
  58. '''
  59. if rd_d[0][1] == 'O':
  60. agree_check = 'checked="checked"'
  61. else:
  62. agree_check = ''
  63. return easy_minify(flask.render_template(skin_check(),
  64. imp = [load_lang('topic_setting'), wiki_set(), custom(), other2([0, 0])],
  65. data = '''
  66. <hr class=\"main_hr\">
  67. <form method="post">
  68. <select name="stop_d">
  69. ''' + stop_d_list + '''
  70. </select>
  71. <hr class=\"main_hr\">
  72. <input type="checkbox" name="agree" value="O" ''' + agree_check + '''> Agree
  73. <hr class=\"main_hr\">
  74. <input placeholder="''' + load_lang('why') + ''' (''' + load_lang('markup_enabled') + ''')" name="why" type="text">
  75. <hr class=\"main_hr\">
  76. <button type="submit">''' + load_lang('save') + '''</button>
  77. </form>
  78. ''',
  79. menu = [['thread/' + topic_num + '/tool', load_lang('return')]]
  80. ))