Commit d9d3f25d authored by ibuler's avatar ibuler

bugfix

parent d6b6e745
...@@ -393,9 +393,7 @@ def addUser(request): ...@@ -393,9 +393,7 @@ def addUser(request):
if request.method == 'POST': if request.method == 'POST':
form = UserAddForm(request.POST) form = UserAddForm(request.POST)
if not form.is_valid(): if form.is_valid():
return HttpResponse('error')
else:
user = form.cleaned_data user = form.cleaned_data
username = user['username'] username = user['username']
password = user['password'] password = user['password']
...@@ -808,13 +806,12 @@ def addAssets(request): ...@@ -808,13 +806,12 @@ def addAssets(request):
idc = request.POST.get('idc') idc = request.POST.get('idc')
comment = request.POST.get('comment') comment = request.POST.get('comment')
idc = IDC.objects.get(id=idc) if '' in (ip, port, idc):
if '' in (ip, port):
error = '带*号内容不能为空。' error = '带*号内容不能为空。'
elif Assets.objects.filter(ip=ip): elif Assets.objects.filter(ip=ip):
error = '主机已存在。' error = '主机已存在。'
if not error: if not error:
idc = IDC.objects.get(id=idc)
asset = Assets(ip=ip, port=port, idc=idc, comment=comment) asset = Assets(ip=ip, port=port, idc=idc, comment=comment)
asset.save() asset.save()
msg = u'%s 添加成功' % ip msg = u'%s 添加成功' % ip
......
...@@ -35,14 +35,14 @@ class UserAddForm(forms.Form): ...@@ -35,14 +35,14 @@ class UserAddForm(forms.Form):
password_again = self.cleaned_data['password_again'] password_again = self.cleaned_data['password_again']
if password != password_again: if password != password_again:
raise forms.ValidationError('Password input twice not match. ') raise forms.ValidationError(u'密码二次输入不一致. ')
return password_again return password_again
def clean_key_pass_again(self): def clean_key_pass_again(self):
key_pass = self.data['key_pass'] key_pass = self.data['key_pass']
key_pass_again = self.data['key_pass_again'] key_pass_again = self.data['key_pass_again']
if key_pass != key_pass_again: if key_pass != key_pass_again:
raise forms.ValidationError('Key Password input twice not match. ') raise forms.ValidationError(u'密码二次输入不一致. ')
if len(key_pass) < 6: if len(key_pass) < 6:
raise forms.ValidationError('Key Password input twice not match. ') raise forms.ValidationError(u'密码二次输入不一致. ')
return key_pass_again return key_pass_again
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment