2
0

topic_close_list.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. from .tool.func import *
  2. def topic_close_list_2(conn, name):
  3. curs = conn.cursor()
  4. div = ''
  5. tool = flask.request.args.get('tool', '')
  6. plus = ''
  7. menu = [['topic/' + url_pas(name), load_lang('return')]]
  8. if tool == 'close':
  9. curs.execute(db_change("select code, sub from rd where title = ? and stop = 'O' order by sub asc"), [name])
  10. sub = load_lang('closed_discussion')
  11. elif tool == 'agree':
  12. curs.execute(db_change("select code, sub from rd where title = ? and agree = 'O' order by sub asc"), [name])
  13. sub = load_lang('agreed_discussion')
  14. else:
  15. sub = load_lang('discussion_list')
  16. menu = [['w/' + url_pas(name), load_lang('document')]]
  17. if acl_check(name, 'topic', None) == 1:
  18. display = 'display: none;'
  19. else:
  20. display = ''
  21. curs.execute(db_change("select code from topic order by code + 0 desc limit 1"))
  22. t_data = curs.fetchall()
  23. if t_data:
  24. topic_num = str(int(t_data[0][0]) + 1)
  25. else:
  26. topic_num = '1'
  27. plus = '''
  28. <a href="/topic/''' + url_pas(name) + '?tool=close">(' + load_lang('closed_discussion') + ')</a> <a href="/topic/' + url_pas(name) + '?tool=agree">(' + load_lang('agreed_discussion') + ''')</a>
  29. <hr class="main_hr">
  30. <form style="''' + display + '" method="post" action="/thread/' + topic_num + '''">
  31. <input placeholder="''' + load_lang('discussion_name') + '''" name="title">
  32. <hr class="main_hr">
  33. <textarea rows="10" id="content" placeholder="''' + load_lang('content') + '''" name="content"></textarea>
  34. <hr class="main_hr">
  35. ''' + captcha_get() + (ip_warning() if display == '' else '') + '''
  36. <input style="display: none;" name="topic" value="''' + name + '''">
  37. <button type="submit">''' + load_lang('send') + '''</button>
  38. <button id="preview" type="button" onclick="load_preview(\'''' + url_pas(name) + '\')">' + load_lang('preview') + '''</button>
  39. </form>
  40. <hr class="main_hr">
  41. <div id="see_preview"></div>
  42. '''
  43. curs.execute(db_change("select code, sub from rd where title = ? and stop != 'O' order by date desc"), [name])
  44. for data in curs.fetchall():
  45. curs.execute(db_change("select id from topic where code = ? order by id + 0 desc limit 1"), [data[0]])
  46. t_data = curs.fetchall()
  47. div += '''
  48. <h2><a href="/thread/''' + data[0] + '">' + data[0] + '. ' + data[1] + '''</a></h2>
  49. <div id="topic_pre_''' + data[0] + '''"></div>
  50. <div id="topic_back_pre_''' + data[0] + '''"></div>
  51. <script>
  52. new_topic_load(''' + data[0] + ', "list", "?num=1", "topic_pre_' + data[0] + '''");
  53. if(''' + t_data[0][0] + ''' !== 1) {
  54. new_topic_load(''' + data[0] + ', "list", "?num=' + t_data[0][0] + '", "topic_back_pre_' + data[0] + '''");
  55. }
  56. </script>
  57. '''
  58. if div == '':
  59. plus = re.sub(r'^<br>', '', plus)
  60. return easy_minify(flask.render_template(skin_check(),
  61. imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + sub + ')', 0])],
  62. data = div + plus,
  63. menu = menu
  64. ))