recent_discuss.py 2.4 KB

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