topic_tool_change.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. from .tool.func import *
  2. def topic_tool_change(topic_num = 1):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. if admin_check(None) != 1:
  6. return re_error('/error/3')
  7. ip = ip_check()
  8. time = get_time()
  9. topic_num = str(topic_num)
  10. curs.execute(db_change("select title, sub from rd where code = ?"), [topic_num])
  11. rd_d = curs.fetchall()
  12. if not rd_d:
  13. return redirect('/')
  14. if flask.request.method == 'POST':
  15. admin_check(None, 'move_topic (code ' + topic_num + ')')
  16. curs.execute(db_change("select id from topic where code = ? order by id + 0 desc limit 1"), [topic_num])
  17. topic_check = curs.fetchall()
  18. if topic_check:
  19. title_d = flask.request.form.get('title', 'test')
  20. sub_d = flask.request.form.get('sub', 'test')
  21. curs.execute(db_change("update rd set title = ?, sub = ? where code = ?"), [
  22. title_d,
  23. sub_d,
  24. topic_num
  25. ])
  26. do_add_thread(
  27. topic_num,
  28. load_lang('topic_name_change') + ' : ' + sub_d + ' (' + title_d + ')',
  29. '1'
  30. )
  31. do_reload_recent_thread(
  32. topic_num,
  33. time
  34. )
  35. return redirect('/thread/' + topic_num)
  36. else:
  37. return easy_minify(flask.render_template(skin_check(),
  38. imp = [load_lang('topic_name_change'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
  39. data = '''
  40. <form method="post">
  41. ''' + load_lang('document_name') + '''
  42. <hr class="main_hr">
  43. <input value="''' + rd_d[0][0] + '''" name="title" type="text">
  44. <hr class="main_hr">
  45. ''' + load_lang('discussion_name') + '''
  46. <hr class="main_hr">
  47. <input value="''' + rd_d[0][1] + '''" name="sub" type="text">
  48. <hr class="main_hr">
  49. <button type="submit">''' + load_lang('save') + '''</button>
  50. </form>
  51. ''',
  52. menu = [['thread/' + topic_num + '/tool', load_lang('return')]]
  53. ))