give_admin_groups.py 3.1 KB

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