添加用户逻辑修改

pull/6/head
guanghongwei 2015-01-27 17:24:33 +08:00
parent 2acc715ebe
commit c782b46f32
2 changed files with 12 additions and 2 deletions

View File

@ -121,6 +121,15 @@ def group_db_add(**kwargs):
UserGroup.objects.create(**kwargs)
def user_group_add(username, group_name):
user = User.objects.get(username=username)
group = UserGroup.objects.get(name=group_name)
groups = [group]
for g in user.user_group.all():
groups.append(g)
user.user_group = groups
def group_add(request):
error = ''
msg = ''
@ -461,6 +470,7 @@ def user_add(request):
server_add_user(username, password, ssh_key_pwd1)
group_db_add(name=username, comment=username, type='U')
user_group_add(username=username, group_name=username)
if LDAP_ENABLE:
ldap_add_user(username, ldap_pwd)
msg = u'娣诲姞鐢ㄦ埛 %s 鎴愬姛锛' % username

View File

@ -168,13 +168,13 @@ $('#userForm').validator({
msg: {required: "蹇呴』濉啓!"}
},
"password": {
rule: "required;length[6~16]",
rule: "required;length[6~50]",
tip: "杈撳叆瀵嗙爜",
ok: "",
msg: {required: "蹇呴』濉啓!"}
},
"ssh_key_pwd1": {
rule: "required;length[6~16]",
rule: "required;length[6~50]",
tip: "ssh绉侀挜瀵嗙爜",
ok: "",
msg: {required: "蹇呴』濉啓"}