topic_stop.py 3.4 KB

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