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(conn, None) != 1:
  6. return re_error(conn, '/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(conn, '/')
  14. if flask.request.method == 'POST':
  15. admin_check(conn, 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(conn,
  27. topic_num,
  28. get_lang(conn, 'topic_name_change') + ' : ' + sub_d + ' (' + title_d + ')',
  29. '1'
  30. )
  31. do_reload_recent_thread(conn,
  32. topic_num,
  33. time
  34. )
  35. return redirect(conn, '/thread/' + topic_num)
  36. else:
  37. return easy_minify(conn, flask.render_template(skin_check(conn),
  38. imp = [get_lang(conn, 'topic_name_change'), wiki_set(conn), wiki_custom(conn), wiki_css([0, 0])],
  39. data = '''
  40. <form method="post">
  41. ''' + get_lang(conn, 'document_name') + '''
  42. <hr class="main_hr">
  43. <input value="''' + rd_d[0][0] + '''" name="title" type="text">
  44. <hr class="main_hr">
  45. ''' + get_lang(conn, '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">''' + get_lang(conn, 'save') + '''</button>
  50. </form>
  51. ''',
  52. menu = [['thread/' + topic_num + '/tool', get_lang(conn, 'return')]]
  53. ))