topic_stop.py 3.4 KB

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