topic_tool_setting.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. from .tool.func import *
  2. def topic_tool_setting(topic_num = 1):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. if acl_check(tool = 'toron_auth') == 1:
  6. return re_error(conn, 3)
  7. ip = ip_check()
  8. time = get_time()
  9. topic_num = str(topic_num)
  10. curs.execute(db_change("select stop, agree from rd where code = ?"), [topic_num])
  11. rd_d = curs.fetchall()
  12. if not rd_d:
  13. return redirect(conn, '/')
  14. if flask.request.method == 'POST':
  15. acl_check(tool = 'toron_auth', memo = 'change_topic_set (code ' + topic_num + ')')
  16. stop_d = flask.request.form.get('stop_d', '')
  17. why_d = flask.request.form.get('why', '')
  18. agree_d = flask.request.form.get('agree', '')
  19. if stop_d != rd_d[0][0]:
  20. curs.execute(db_change("update rd set stop = ? where code = ?"), [
  21. stop_d,
  22. topic_num
  23. ])
  24. if stop_d == 'S':
  25. t_state = 'topic_state_change_stop'
  26. elif stop_d == 'O':
  27. t_state = 'topic_state_change_close'
  28. else:
  29. t_state = 'topic_state_change_normal'
  30. do_add_thread(conn,
  31. topic_num,
  32. get_lang(conn, t_state),
  33. '1'
  34. )
  35. if agree_d != rd_d[0][1]:
  36. curs.execute(db_change("update rd set agree = ? where code = ?"), [
  37. agree_d,
  38. topic_num
  39. ])
  40. if agree_d == 'O':
  41. t_state = 'topic_state_change_agree'
  42. else:
  43. t_state = 'topic_state_change_disagree'
  44. do_add_thread(conn,
  45. topic_num,
  46. get_lang(conn, t_state),
  47. '1'
  48. )
  49. if why_d != '':
  50. do_add_thread(conn,
  51. topic_num,
  52. get_lang(conn, 'why') + ' : ' + why_d,
  53. '1'
  54. )
  55. do_reload_recent_thread(conn,
  56. topic_num,
  57. time
  58. )
  59. return redirect(conn, '/thread/' + topic_num)
  60. else:
  61. stop_d_list = ''
  62. agree_check = ''
  63. for_list = [
  64. ['O', get_lang(conn, 'topic_close')],
  65. ['S', get_lang(conn, 'topic_stop')],
  66. ['', get_lang(conn, 'topic_normal')]
  67. ]
  68. for i in for_list:
  69. if rd_d and rd_d[0][0] == i[0]:
  70. stop_d_list = '<option value="' + i[0] + '">' + i[1] + '</option>' + stop_d_list
  71. else:
  72. stop_d_list += '<option value="' + i[0] + '">' + i[1] + '</option>'
  73. agree_check = 'checked="checked"' if rd_d[0][1] == 'O' else ''
  74. return easy_minify(conn, flask.render_template(skin_check(conn),
  75. imp = [get_lang(conn, 'topic_setting'), wiki_set(conn), wiki_custom(conn), wiki_css([0, 0])],
  76. data = render_simple_set(conn, '''
  77. <form method="post">
  78. <h2>''' + get_lang(conn, 'topic_progress') + '''</h2>
  79. <select name="stop_d">
  80. ''' + stop_d_list + '''
  81. </select>
  82. <hr class="main_hr">
  83. <input type="checkbox" name="agree" value="O" ''' + agree_check + '''> ''' + get_lang(conn, 'topic_change_agree') + '''
  84. <h2>''' + get_lang(conn, 'topic_associate') + '''</h2>
  85. ''' + get_lang(conn, 'topic_link_vote') + ''' (''' + get_lang(conn, 'not_working') + ''')
  86. <hr class="main_hr">
  87. <input placeholder="''' + get_lang(conn, 'topic_insert_vote_number') + '''" name="vote_number" type="number">
  88. <h2>''' + get_lang(conn, 'why') + '''</h2>
  89. <input placeholder="''' + get_lang(conn, 'why') + ''' (''' + get_lang(conn, 'markup_enabled') + ''')" name="why" type="text">
  90. <hr class="main_hr">
  91. <button type="submit">''' + get_lang(conn, 'save') + '''</button>
  92. </form>
  93. '''),
  94. menu = [['thread/' + topic_num + '/tool', get_lang(conn, 'return')]]
  95. ))