mirror of https://github.com/jumpserver/jumpserver
修改保存
parent
63cdef4218
commit
0f18e702e8
|
@ -4,14 +4,13 @@ from django.http import HttpResponse
|
|||
from django.template import RequestContext
|
||||
from django.shortcuts import render_to_response
|
||||
from django.http import HttpResponseRedirect
|
||||
from UserManage.models import User
|
||||
from UserManage.models import User, Group
|
||||
from Assets.models import Assets, AssetsUser
|
||||
import subprocess
|
||||
from Crypto.Cipher import AES
|
||||
from binascii import b2a_hex, a2b_hex
|
||||
import random
|
||||
import ConfigParser
|
||||
import pam
|
||||
from UserManage.forms import UserAddForm, GroupAddForm
|
||||
|
||||
|
||||
|
@ -176,16 +175,22 @@ def addUser(request):
|
|||
if form.is_valid():
|
||||
user = form.cleaned_data
|
||||
ldap_password = keygen(16)
|
||||
group_post = user['group']
|
||||
groups = []
|
||||
for group_name in group_post:
|
||||
groups.append(Group.objects.get(name=group_name))
|
||||
|
||||
u = User(
|
||||
username=user['username'],
|
||||
password=user['password'],
|
||||
key_pass=user['key_pass'],
|
||||
name=user['name'],
|
||||
group=user['group'],
|
||||
is_admin=user['is_admin'],
|
||||
is_superuser=user['is_superuser'],
|
||||
ldap_password=ldap_password)
|
||||
u.save()
|
||||
u.group = groups
|
||||
u.save()
|
||||
|
||||
return render_to_response('addUser.html', {'msg': msg, 'user_menu': 'active'},
|
||||
context_instance=RequestContext(request))
|
||||
|
|
|
@ -2,14 +2,14 @@ from django.db import models
|
|||
|
||||
|
||||
class Group(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
name = models.CharField(max_length=50, unique=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class User(models.Model):
|
||||
username = models.CharField(max_length=50)
|
||||
username = models.CharField(max_length=50, unique=True)
|
||||
password = models.CharField(max_length=100)
|
||||
key_pass = models.CharField(max_length=100)
|
||||
name = models.CharField(max_length=50)
|
||||
|
|
Loading…
Reference in New Issue