mirror of https://github.com/jumpserver/jumpserver
添加修改用户信息
parent
52e567b157
commit
c588aaea3a
|
@ -16,6 +16,7 @@ urlpatterns = patterns('',
|
|||
(r'^logout/$', views.logout),
|
||||
(r'^showUser/$', views.showUser),
|
||||
(r'^addUser/$', views.addUser),
|
||||
(r'^chgUser/$', views.chgUser),
|
||||
(r'^showAssets/$', views.showAssets),
|
||||
(r'^addAssets/$', views.addAssets),
|
||||
(r'^showPerm/$', views.showPerm),
|
||||
|
|
|
@ -580,6 +580,20 @@ def addPerm(request):
|
|||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
@admin_required
|
||||
def chgUser(request):
|
||||
"""修改用户信息"""
|
||||
error = ''
|
||||
msg = ''
|
||||
|
||||
if request.method == "GET":
|
||||
username = request.GET.get('username')
|
||||
user = User.objects.get(username=username)
|
||||
return render_to_response('chgUser.html',
|
||||
{'user': user, 'user_menu': 'active'},
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
@login_required
|
||||
def chgPass(request):
|
||||
"""修改登录系统的密码"""
|
||||
|
@ -599,7 +613,7 @@ def chgPass(request):
|
|||
error = '两次密码不匹配'
|
||||
|
||||
if not error:
|
||||
user.password = password
|
||||
user.password = md5_crypt(password)
|
||||
user.save()
|
||||
|
||||
return render_to_response('chgPass.html', {'msg': msg, 'error': error, 'pass_menu': 'active'},
|
||||
|
|
|
@ -10,9 +10,11 @@ class GroupAddForm(forms.Form):
|
|||
|
||||
class UserAddForm(forms.Form):
|
||||
username = forms.CharField(max_length=30,
|
||||
widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': '用户名'}))
|
||||
widget=forms.TextInput(
|
||||
attrs={'class': 'form-control', 'placeholder': '用户名'}))
|
||||
password = forms.CharField(max_length=30,
|
||||
widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': '密码'}))
|
||||
widget=forms.PasswordInput(
|
||||
attrs={'class': 'form-control', 'placeholder': '密码'}))
|
||||
password_again = forms.CharField(max_length=30,
|
||||
widget=forms.PasswordInput(
|
||||
attrs={'class': 'form-control', 'placeholder': '确认密码'}))
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
{% extends 'base.html' %}
|
||||
{% block content %}
|
||||
<form class="form-horizontal" role="form" method="post" action="" >
|
||||
<fieldset >
|
||||
<legend>修改用户信息</legend>
|
||||
{% if error %}
|
||||
<div class="alert alert-danger">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if form.errors %}
|
||||
<div class="alert alert-danger">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if msg %}
|
||||
<div class="alert alert-success">
|
||||
{{ msg }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="form-group">
|
||||
{{ form.username.errors }}
|
||||
<label for="id_username" class="col-sm-2 control-label">用户名<span style="color: red"> *</span></label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" id="id_username" name="id_username" class="form-control" value="{{ user.username }}" disabled="disabled" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.password.errors }}
|
||||
<label for="id_password" class="col-sm-2 control-label">密码<span style="color: red"> *</span></label>
|
||||
<div class="col-sm-4">
|
||||
{{ form.password }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.password_again.errors }}
|
||||
<label for="id_password_again" class="col-sm-2 control-label">确认密码<span style="color: red"> *</span></label>
|
||||
<div class="col-sm-4">
|
||||
{{ form.password_again }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.key_pass.errors }}
|
||||
<label for="id_keypass" class="col-sm-2 control-label">密钥密码<span style="color: red"> *</span></label>
|
||||
<div class="col-sm-4">
|
||||
{{ form.key_pass }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.key_pass_again.errors }}
|
||||
<label for="id_keypass_again" class="col-sm-2 control-label">确认密码<span style="color: red"> *</span></label>
|
||||
<div class="col-sm-4">
|
||||
{{ form.key_pass_again }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.name.errors }}
|
||||
<label for="id_name" class="col-sm-2 control-label">姓名<span style="color: red"> *</span></label>
|
||||
<div class="col-sm-4">
|
||||
{{ form.name }}
|
||||
{{ user.name }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.group.errors }}
|
||||
<label for="id_group" class="col-sm-2 control-label">属组</label>
|
||||
<div class="col-sm-4">
|
||||
{{ form.group }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.is_admin.errors }}
|
||||
<label for="id_is_admin" class="col-sm-2 control-label">组admin</label>
|
||||
<div class="col-sm-4">
|
||||
{{ form.is_admin }}
|
||||
{{ user.is_admin }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.is_superuser.errors }}
|
||||
<label for="id_is_superuser" class="col-sm-2 control-label">超级admin</label>
|
||||
<div class="col-sm-4">
|
||||
{{ form.is_superuser }}
|
||||
{{ user.is_superuser }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-4">
|
||||
<button class="btn btn-primary">添加</button>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -18,6 +18,7 @@
|
|||
<th>is_superuser</th>
|
||||
<th>Email</th>
|
||||
<th>Key</th>
|
||||
<th>修改</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -37,6 +38,7 @@
|
|||
<td>{{ user.is_superuser }}</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td><a href="/downKey/?username={{ user.username }}">下载</a></td>
|
||||
<td><a href="/chgUser/?username={{ user.username }}">修改</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in New Issue