topic_change.py 2.2 KB

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