list_acl.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from .tool.func import *
  2. async def list_acl(arg_num = 1):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. sql_num = (arg_num * 50 - 50) if arg_num * 50 > 0 else 0
  6. div = '<ul>'
  7. curs.execute(db_change(
  8. "select distinct title, data, type from acl where data != '' and not title like 'user:%' order by title desc limit ?, 50"
  9. ), [sql_num])
  10. list_data = curs.fetchall()
  11. for data in list_data:
  12. curs.execute(db_change("select time from re_admin where what like ? order by time desc limit 1"), ['acl (' + data[0] + ')%'])
  13. time_data = curs.fetchall()
  14. time_data = (time_data[0][0] + ' | ') if time_data else ''
  15. curs.execute(db_change("select data from acl where title = ? and type = 'why'"), [data[0]])
  16. why_data = curs.fetchall()
  17. why_data = (' | ' + why_data[0][0]) if why_data and why_data[0][0] != '' else ''
  18. div += '' + \
  19. '<li>' + \
  20. time_data + \
  21. '<a href="/acl/' + url_pas(data[0]) + '">' + html.escape(data[0]) + '</a>' + \
  22. why_data + \
  23. '</li>' + \
  24. ''
  25. div += '</ul>'
  26. div += await get_next_page_bottom('/list/document/acl/{}', arg_num, list_data)
  27. return await render_template(
  28. await get_lang('acl_document_list'),
  29. div,
  30. 0,
  31. [['other', await get_lang('return')]]
  32. )