topic_close_list.py 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. from .tool.func import *
  2. def topic_close_list_2(conn, name, tool):
  3. curs = conn.cursor()
  4. div = ''
  5. if flask.request.method == 'POST':
  6. t_num = ''
  7. while 1:
  8. curs.execute("select title from topic where title = ? and sub = ? limit 1", [name, flask.request.form.get('topic', None) + t_num])
  9. if curs.fetchall():
  10. if t_num == '':
  11. t_num = ' 2'
  12. else:
  13. t_num = ' ' + str(int(t_num.replace(' ', '')) + 1)
  14. else:
  15. break
  16. return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(flask.request.form.get('topic', 'test') + t_num))
  17. else:
  18. plus = ''
  19. menu = [['topic/' + url_pas(name), load_lang('return')]]
  20. if tool == 'close':
  21. curs.execute("select sub from rd where title = ? and stop = 'O' order by sub asc", [name])
  22. sub = load_lang('closed_discussion')
  23. elif tool == 'agree':
  24. curs.execute("select sub from rd where title = ? and agree = 'O' order by sub asc", [name])
  25. sub = load_lang('agreed_discussion')
  26. else:
  27. curs.execute("select sub from rd where title = ? order by date desc", [name])
  28. sub = load_lang('discussion_list')
  29. menu = [['w/' + url_pas(name), load_lang('document')]]
  30. plus = '''
  31. <a href="/topic/''' + url_pas(name) + '''/close">(''' + load_lang('closed_discussion') + ''')</a> <a href="/topic/''' + url_pas(name) + '''/agree">(''' + load_lang('agreed_discussion') + ''')</a>
  32. <hr class=\"main_hr\">
  33. <input placeholder="''' + load_lang('discussion_name') + '''" name="topic" type="text">
  34. <hr class=\"main_hr\">
  35. <button type="submit">''' + load_lang('go') + '''</button>
  36. '''
  37. t_num = 0
  38. for data in curs.fetchall():
  39. t_num += 1
  40. curs.execute("select data, date, ip, block from topic where title = ? and sub = ? and id = '1'", [name, data[0]])
  41. if curs.fetchall():
  42. it_p = 0
  43. if sub == load_lang('discussion_list'):
  44. curs.execute("select title from rd where title = ? and sub = ? and stop = 'O' order by sub asc", [name, data[0]])
  45. if curs.fetchall():
  46. it_p = 1
  47. if it_p != 1:
  48. curs.execute("select id from topic where title = ? and sub = ? order by date desc limit 1", [name, data[0]])
  49. t_data = curs.fetchall()
  50. div += '''
  51. <h2><a href="/topic/''' + url_pas(name) + '''/sub/''' + url_pas(data[0]) + '''">''' + str(t_num) + '''. ''' + data[0] + '''</a></h2>
  52. <div id="topic_pre_''' + str(t_num) + '''"></div>
  53. <div id="topic_back_pre_''' + str(t_num) + '''"></div>
  54. <script>
  55. topic_list_load("''' + name + '''", "''' + data[0] + '''", "1", "topic_pre_''' + str(t_num) + '''");
  56. if("''' + str(t_num) + '''" !== "1") {
  57. topic_list_load("''' + name + '''", "''' + data[0] + '''", "''' + t_data[0][0] + '''", "topic_back_pre_''' + str(t_num) + '''");
  58. }
  59. </script>
  60. '''
  61. if div == '':
  62. plus = re.sub('^<br>', '', plus)
  63. return easy_minify(flask.render_template(skin_check(),
  64. imp = [name, wiki_set(), custom(), other2([' (' + sub + ')', 0])],
  65. data = '<form method="post">' + div + plus + '</form>',
  66. menu = menu
  67. ))