recent_history_send.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from .tool.func import *
  2. async 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 await acl_check('', 'owner_auth', '', '') == 1:
  7. return await re_error(conn, 3)
  8. if flask.request.method == 'POST':
  9. await acl_check(tool = 'owner_auth', memo = '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. return redirect(conn, '/history/' + url_pas(name))
  18. else:
  19. curs.execute(db_change("select send from history where title = ? and id = ?"), [name, num])
  20. send = curs.fetchall()
  21. if send:
  22. send = send[0][0]
  23. return easy_minify(conn, flask.render_template(skin_check(conn),
  24. imp = [name, await wiki_set(), await wiki_custom(conn), wiki_css(['(' + get_lang(conn, 'send_edit') + ') (r' + num + ')', 0])],
  25. data = '''
  26. <form method="post">
  27. <span>''' + get_lang(conn, 'delete_warning') + '''</span>
  28. <hr class="main_hr">
  29. <input value="''' + html.escape(send) + '''" name="send">
  30. <hr class="main_hr">
  31. <button type="submit">''' + get_lang(conn, 'edit') + '''</button>
  32. </form>
  33. ''',
  34. menu = [['history/' + url_pas(name), get_lang(conn, 'return')]]
  35. ))
  36. else:
  37. return redirect(conn, '/history/' + url_pas(name))