give_admin_groups.py 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. from .tool.func import *
  2. def give_admin_groups_2(name = None):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. acl_name_list = ['ban', 'nothing', 'toron', 'check', 'acl', 'hidel', 'give', 'owner']
  6. if flask.request.method == 'POST':
  7. if admin_check(None, 'admin_plus (' + name + ')') != 1:
  8. return re_error('/error/3')
  9. elif name in get_default_admin_group():
  10. return re_error('/error/3')
  11. curs.execute(db_change("delete from alist where name = ?"), [name])
  12. for i in acl_name_list:
  13. if flask.request.form.get(i, 0) != 0:
  14. curs.execute(db_change("insert into alist (name, acl) values (?, ?)"), [name, i])
  15. conn.commit()
  16. return redirect('/admin_plus/' + url_pas(name))
  17. else:
  18. data = ''
  19. exist_list = ['', '', '', '', '', '', '', '']
  20. state = 'disabled' if admin_check() != 1 else ''
  21. state = 'disabled' if name in get_default_admin_group() else ''
  22. curs.execute(db_change('select acl from alist where name = ?'), [name])
  23. acl_list = curs.fetchall()
  24. for go in acl_list:
  25. exist_list[acl_name_list.index(go[0])] = 'checked="checked"'
  26. for i in range(0, 8):
  27. if i != 1:
  28. data += '' + \
  29. '<input type="checkbox" ' + \
  30. state + ' ' + \
  31. 'name="' + acl_name_list[i] + '" ' + \
  32. exist_list[i] + '> ' + acl_name_list[i] + \
  33. '<hr class="main_hr">' + \
  34. ''
  35. data += ''
  36. return easy_minify(flask.render_template(skin_check(),
  37. imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('admin_group') + ')', 0])],
  38. data = '''
  39. <form method="post">
  40. ''' + data + '''
  41. <hr class="main_hr">
  42. <h2>''' + load_lang('explanation') + '''</h2>
  43. <ul class="opennamu_ul">
  44. <li style="margin-left: 20px;">owner : ''' + load_lang('owner_authority') + '''</li>
  45. <li style="margin-left: 40px; list-style: circle;">ban : ''' + load_lang('ban_authority') + '''</li>
  46. <li style="margin-left: 40px; list-style: circle;">toron : ''' + load_lang('discussion_authority') + '''</li>
  47. <li style="margin-left: 40px; list-style: circle;">check : ''' + load_lang('user_check_authority') + '''</li>
  48. <li style="margin-left: 40px; list-style: circle;">acl : ''' + load_lang('document_acl_authority') + '''</li>
  49. <li style="margin-left: 40px; list-style: circle;">hidel : ''' + load_lang('history_hide_authority') + '''</li>
  50. <li style="margin-left: 40px; list-style: circle;">give : ''' + load_lang('authorization_authority') + '''</li>
  51. </ul>
  52. <hr class="main_hr">
  53. <button ''' + state + ''' type="submit">''' + load_lang('save') + '''</button>
  54. </form>
  55. ''',
  56. menu = [['admin_group', load_lang('return')]]
  57. ))