give_admin_groups.py 2.7 KB

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