recent_discuss.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from .tool.func import *
  2. def recent_discuss(tool):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. div = ''
  6. if tool == 'normal':
  7. div += '<a href="/recent_discuss/close">(' + load_lang('close_discussion') + ')</a> '
  8. div += '<a href="/recent_discuss/open">(' + load_lang('open_discussion_list') + ')</a>'
  9. m_sub = 0
  10. elif tool == 'close':
  11. div += '<a href="/recent_discuss">(' + load_lang('normal') + ')</a>'
  12. m_sub = ' (' + load_lang('closed') + ')'
  13. else:
  14. div += '<a href="/recent_discuss">(' + load_lang('normal') + ')</a>'
  15. m_sub = ' (' + load_lang('open_discussion_list') + ')'
  16. div += '''
  17. <hr class="main_hr">
  18. <table id="main_table_set">
  19. <tbody>
  20. <tr id="main_table_top_tr">
  21. <td id="main_table_width_half">''' + load_lang('discussion_name') + '''</td>
  22. <td id="main_table_width_half">''' + load_lang('time') + '''</td>
  23. </tr>
  24. '''
  25. if tool == 'normal':
  26. curs.execute(db_change("select title, sub, date, code from rd where not stop = 'O' order by date desc limit 50"))
  27. elif tool == 'close':
  28. curs.execute(db_change("select title, sub, date, code from rd where stop = 'O' order by date desc limit 50"))
  29. else:
  30. curs.execute(db_change('select title, sub, date, code from rd where stop != "O" order by date asc limit 50'))
  31. for data in curs.fetchall():
  32. div += '' + \
  33. '<tr>' + \
  34. '<td>' + \
  35. '<a href="/thread/' + data[3] + '">' + html.escape(data[1]) + '</a> ' + \
  36. '<a href="/topic/' + url_pas(data[0]) + '">(' + html.escape(data[0]) + ')</a>' + \
  37. '</td>' + \
  38. '<td>' + data[2] + '</td>' + \
  39. '</tr>' + \
  40. ''
  41. div += '</tbody></table>'
  42. return easy_minify(flask.render_template(skin_check(),
  43. imp = [load_lang('recent_discussion'), wiki_set(), wiki_custom(), wiki_css([m_sub, 0])],
  44. data = div,
  45. menu = 0
  46. ))