mirror of https://github.com/jumpserver/jumpserver
添加forms
parent
45b874fcd8
commit
73d61e09ed
|
@ -12,6 +12,8 @@ from binascii import b2a_hex, a2b_hex
|
||||||
import random
|
import random
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import pam
|
import pam
|
||||||
|
from UserManage.forms import UserAddForm, GroupAddFrom
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
base_dir = "/opt/jumpserver/"
|
base_dir = "/opt/jumpserver/"
|
||||||
|
@ -165,7 +167,7 @@ def addUser(request):
|
||||||
"""添加用户"""
|
"""添加用户"""
|
||||||
jm = PyCrypt(key)
|
jm = PyCrypt(key)
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
return render_to_response('addUser.html', {'user_menu': 'active'},
|
return render_to_response('addUser.html', {'user_menu': 'active', 'form': UserAddForm},
|
||||||
context_instance=RequestContext(request))
|
context_instance=RequestContext(request))
|
||||||
else:
|
else:
|
||||||
username = request.POST.get('username')
|
username = request.POST.get('username')
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
from UserManage.models import Group
|
||||||
|
|
||||||
|
|
||||||
|
class GroupAddForm(forms.Form):
|
||||||
|
name = forms.CharField(max_length=30)
|
||||||
|
|
||||||
|
|
||||||
|
class UserAddForm(forms.Form):
|
||||||
|
username = forms.CharField(max_length=30,
|
||||||
|
widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': '用户名'}))
|
||||||
|
password = forms.CharField(max_length=30,
|
||||||
|
widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': '密码'}))
|
||||||
|
password_again = forms.CharField(max_length=30,
|
||||||
|
widget=forms.PasswordInput(
|
||||||
|
attrs={'class': 'form-control', 'placeholder': '确认密码'}))
|
||||||
|
key_pass = forms.CharField(max_length=30,
|
||||||
|
widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': '密钥密码'}))
|
||||||
|
key_pass_again = forms.CharField(max_length=30,
|
||||||
|
widget=forms.PasswordInput(
|
||||||
|
attrs={'class': 'form-control', 'placeholder': '确认密码'}))
|
||||||
|
name = forms.CharField(max_length=30,
|
||||||
|
widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': '姓名'}))
|
||||||
|
group = forms.ModelMultipleChoiceField(queryset=Group.objects.all(),
|
||||||
|
widget=forms.MultipleChoiceField(attrs={'class': 'form-control'}))
|
||||||
|
is_admin = forms.BooleanField()
|
||||||
|
is_superuser = forms.BooleanField()
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ class Group(models.Model):
|
||||||
class User(models.Model):
|
class User(models.Model):
|
||||||
username = models.CharField(max_length=50)
|
username = models.CharField(max_length=50)
|
||||||
password = models.CharField(max_length=100)
|
password = models.CharField(max_length=100)
|
||||||
|
key_pass = models.CharField(max_length=100)
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
group = models.ManyToManyField(Group)
|
group = models.ManyToManyField(Group)
|
||||||
is_admin = models.BooleanField()
|
is_admin = models.BooleanField()
|
||||||
|
|
|
@ -3,56 +3,76 @@
|
||||||
<form class="form-horizontal" role="form" method="post" action="" >
|
<form class="form-horizontal" role="form" method="post" action="" >
|
||||||
<fieldset >
|
<fieldset >
|
||||||
<legend>添加用户</legend>
|
<legend>添加用户</legend>
|
||||||
{% if error %}
|
{% if form.errors %}
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
{{ error }}
|
Please correct the error{{ form.errors|pluralize }} below.
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if msg %}
|
{% if msg %}
|
||||||
<div class="alert alert-success">
|
<div class="alert alert-success">
|
||||||
{{ msg }}
|
{{ msg }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username" class="col-sm-2 control-label">用户名<span style="color: red"> *</span></label>
|
{{ form.username.errors }}
|
||||||
|
<label for="id_username" class="col-sm-2 control-label">用户名<span style="color: red"> *</span></label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input type="text" class="form-control" id="username" name="username" placeholder="用户名">
|
{{ form.username }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password" class="col-sm-2 control-label">密码<span style="color: red"> *</span></label>
|
{{ form.password.errors }}
|
||||||
|
<label for="id_password" class="col-sm-2 control-label">密码<span style="color: red"> *</span></label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input type="password" class="form-control" id="password" name="password" placeholder="密码">
|
{{ form.password }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password_confirm" class="col-sm-2 control-label">确认密码<span style="color: red"> *</span></label>
|
{{ 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">
|
<div class="col-sm-4">
|
||||||
<input type="password" class="form-control" id="password_confirm" name="password_confirm" placeholder="确认密码">
|
{{ form.password_again }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="keypass" class="col-sm-2 control-label">Key密码<span style="color: red"> *</span></label>
|
{{ 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">
|
<div class="col-sm-4">
|
||||||
<input type="password" class="form-control" id="keypass" name="keypass" placeholder="Key密码">
|
{{ form.key_pass }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="keypass_confirm" class="col-sm-2 control-label">确认密码<span style="color: red"> *</span></label>
|
{{ 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">
|
<div class="col-sm-4">
|
||||||
<input type="password" class="form-control" id="keypass_confirm" name="keypass_confirm" placeholder="确认密码">
|
{{ form.key_pass_again }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name" class="col-sm-2 control-label">姓名<span style="color: red"> *</span></label>
|
{{ form.name.errors }}
|
||||||
|
<label for="id_name" class="col-sm-2 control-label">姓名<span style="color: red"> *</span></label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input type="text" class="form-control" id="name" name='name' placeholder="姓名">
|
{{ form.name }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email" class="col-sm-2 control-label">E-mail</label>
|
{{ form.group.errors }}
|
||||||
|
<label for="id_group" class="col-sm-2 control-label">属组</label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input type="email" class="form-control" id="email" name="email" placeholder="用户名">
|
{{ form.group }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="id_is_admin" class="col-sm-2 control-label">组admin</label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
{{ form.is_admin }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="id_is_superuser" class="col-sm-2 control-label">超级admin</label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
{{ form.is_superuser }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
Loading…
Reference in New Issue