recent_history_send.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from .tool.func import *
  2. def recent_history_send(name = 'Test', rev = 1):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. num = str(rev)
  6. if admin_check(conn) != 1:
  7. return re_error(conn, '/error/3')
  8. if flask.request.method == 'POST':
  9. admin_check(conn, None, 'send edit ' + name + ' r' + num)
  10. curs.execute(db_change("select send from history where title = ? and id = ?"), [name, num])
  11. if curs.fetchall():
  12. curs.execute(db_change("update history set send = ? where title = ? and id = ?"), [
  13. flask.request.form.get('send', ''),
  14. name,
  15. num
  16. ])
  17. conn.commit()
  18. return redirect(conn, '/history/' + url_pas(name))
  19. else:
  20. curs.execute(db_change("select send from history where title = ? and id = ?"), [name, num])
  21. send = curs.fetchall()
  22. if send:
  23. send = send[0][0]
  24. return easy_minify(conn, flask.render_template(skin_check(conn),
  25. imp = [name, wiki_set(conn), wiki_custom(conn), wiki_css(['(' + get_lang(conn, 'send_edit') + ') (r' + num + ')', 0])],
  26. data = '''
  27. <form method="post">
  28. <span>''' + get_lang(conn, 'delete_warning') + '''</span>
  29. <hr class="main_hr">
  30. <input value="''' + html.escape(send) + '''" name="send">
  31. <hr class="main_hr">
  32. <button type="submit">''' + get_lang(conn, 'edit') + '''</button>
  33. </form>
  34. ''',
  35. menu = [['history/' + url_pas(name), get_lang(conn, 'return')]]
  36. ))
  37. else:
  38. return redirect(conn, '/history/' + url_pas(name))