close_topic_list.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. from .tool.func import *
  2. def close_topic_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('close') + ''
  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('agreement') + ''
  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('close') + ''')</a> <a href="/topic/''' + url_pas(name) + '''/agree">(''' + load_lang('agreement') + ''')</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. for data in curs.fetchall():
  38. curs.execute("select data, date, ip, block from topic where title = ? and sub = ? and id = '1'", [name, data[0]])
  39. if curs.fetchall():
  40. it_p = 0
  41. if sub == load_lang('discussion_list'):
  42. curs.execute("select title from rd where title = ? and sub = ? and stop = 'O' order by sub asc", [name, data[0]])
  43. if curs.fetchall():
  44. it_p = 1
  45. if it_p != 1:
  46. div += '<h2><a href="/topic/' + url_pas(name) + '/sub/' + url_pas(data[0]) + '">' + data[0] + '</a></h2>'
  47. if div == '':
  48. plus = re.sub('^<br>', '', plus)
  49. return easy_minify(flask.render_template(skin_check(),
  50. imp = [name, wiki_set(), custom(), other2([' (' + sub + ')', 0])],
  51. data = '<form method="post">' + div + plus + '</form>',
  52. menu = menu
  53. ))