recent_record_topic.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from .tool.func import *
  2. async def recent_record_topic(name = 'Test'):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. num = int(number_check(flask.request.args.get('num', '1')))
  6. sql_num = (num * 50 - 50) if num * 50 > 0 else 0
  7. div = '''
  8. <table id="main_table_set">
  9. <tr id="main_table_top_tr">
  10. <td id="main_table_width">''' + get_lang(conn, 'discussion_name') + '''</td>
  11. <td id="main_table_width">''' + get_lang(conn, 'writer') + '''</td>
  12. <td id="main_table_width">''' + get_lang(conn, 'time') + '''</td>
  13. </tr>
  14. '''
  15. sub = '(' + html.escape(name) + ')'
  16. pas_name = await ip_pas(name)
  17. curs.execute(db_change("select code, id, date from topic where ip = ? order by date desc limit ?, 50"), [name, sql_num])
  18. data_list = curs.fetchall()
  19. for data in data_list:
  20. title = html.escape(data[0])
  21. curs.execute(db_change("select title, sub from rd where code = ?"), [data[0]])
  22. other_data = curs.fetchall()
  23. div += '' + \
  24. '<tr>' + \
  25. '<td>' + \
  26. '<a href="/thread/' + data[0] + '#' + data[1] + '">' + other_data[0][1] + '#' + data[1] + '</a> (' + other_data[0][0] + ')' + \
  27. '</td>' + \
  28. '<td>' + pas_name + '</td>' + \
  29. '<td>' + data[2] + '</td>' + \
  30. '</tr>' + \
  31. ''
  32. div += '</table>'
  33. div += get_next_page_bottom(conn, '/record/topic/' + url_pas(name) + '?num={}', num, data_list)
  34. return easy_minify(conn, flask.render_template(skin_check(conn),
  35. imp = [get_lang(conn, 'discussion_record'), await wiki_set(), await wiki_custom(conn), wiki_css([sub, 0])],
  36. data = div,
  37. menu = [['other', get_lang(conn, 'other')], ['user/' + url_pas(name), get_lang(conn, 'user_tool')]]
  38. ))