bbs_make.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from .tool.func import *
  2. def bbs_make():
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. if admin_check() != 1:
  6. return re_error('/error/3')
  7. if flask.request.method == 'POST':
  8. curs.execute(db_change('select set_id from bbs_set where set_name = "bbs_name" order by set_id + 0 desc'))
  9. db_data = curs.fetchall()
  10. bbs_num = str(int(db_data[0][0]) + 1) if db_data else '1'
  11. bbs_name = flask.request.form.get('bbs_name', 'test')
  12. bbs_type = flask.request.form.get('bbs_type', 'comment')
  13. bbs_type = bbs_type if bbs_type in ['comment', 'thread'] else 'comment'
  14. curs.execute(db_change("insert into bbs_set (set_name, set_code, set_id, set_data) values ('bbs_name', '', ?, ?)"), [bbs_num, bbs_name])
  15. curs.execute(db_change("insert into bbs_set (set_name, set_code, set_id, set_data) values ('bbs_type', '', ?, ?)"), [bbs_num, bbs_type])
  16. conn.commit()
  17. return redirect('/bbs/main')
  18. else:
  19. return easy_minify(flask.render_template(skin_check(),
  20. imp = [load_lang('bbs_make'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
  21. data = '''
  22. <form method="post">
  23. <input placeholder="''' + load_lang('bbs_name') + '''" name="bbs_name">
  24. <hr class="main_hr">
  25. <select name="bbs_type">
  26. <option value="comment">''' + load_lang('comment_base') + '''</option>
  27. <option value="thread">''' + load_lang('thread_base') + '''</option>
  28. </select>
  29. <hr class="main_hr">
  30. <button type="submit">''' + load_lang('save') + '''</button>
  31. </form>
  32. ''',
  33. menu = [['bbs/main', load_lang('return')]]
  34. ))