topic_tool_delete.py 1.2 KB

123456789101112131415161718192021222324252627282930
  1. from .tool.func import *
  2. async def topic_tool_delete(topic_num = 1):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. if await acl_check(tool = 'owner_auth') == 1:
  6. return await re_error(conn, 3)
  7. topic_num = str(topic_num)
  8. if flask.request.method == 'POST':
  9. await acl_check(tool = 'owner_auth', memo = 'delete topic (' + topic_num + ')')
  10. curs.execute(db_change("delete from topic where code = ?"), [topic_num])
  11. curs.execute(db_change("delete from rd where code = ?"), [topic_num])
  12. return redirect(conn, '/')
  13. else:
  14. return easy_minify(flask.render_template(await skin_check(),
  15. imp = [await get_lang('topic_delete'), await wiki_set(), await wiki_custom(conn), wiki_css([0, 0])],
  16. data = '''
  17. <form method="post">
  18. <span>''' + await get_lang('delete_warning') + '''</span>
  19. <hr class="main_hr">
  20. <button type="submit">''' + await get_lang('delete') + '''</button>
  21. </form>
  22. ''',
  23. menu = [['thread/' + topic_num + '/tool', await get_lang('return')]]
  24. ))