diff --git a/webroot/AutoSa/AutoSa/views.py b/webroot/AutoSa/AutoSa/views.py index 5221f8044..22b58c13e 100644 --- a/webroot/AutoSa/AutoSa/views.py +++ b/webroot/AutoSa/AutoSa/views.py @@ -393,9 +393,7 @@ def addUser(request): if request.method == 'POST': form = UserAddForm(request.POST) - if not form.is_valid(): - return HttpResponse('error') - else: + if form.is_valid(): user = form.cleaned_data username = user['username'] password = user['password'] @@ -808,13 +806,12 @@ def addAssets(request): idc = request.POST.get('idc') comment = request.POST.get('comment') - idc = IDC.objects.get(id=idc) - - if '' in (ip, port): + if '' in (ip, port, idc): error = '带*号内容不能为空。' elif Assets.objects.filter(ip=ip): error = '主机已存在。' if not error: + idc = IDC.objects.get(id=idc) asset = Assets(ip=ip, port=port, idc=idc, comment=comment) asset.save() msg = u'%s 添加成功' % ip diff --git a/webroot/AutoSa/UserManage/forms.py b/webroot/AutoSa/UserManage/forms.py index a5597a39c..9c376d0ee 100644 --- a/webroot/AutoSa/UserManage/forms.py +++ b/webroot/AutoSa/UserManage/forms.py @@ -35,14 +35,14 @@ class UserAddForm(forms.Form): password_again = self.cleaned_data['password_again'] if password != password_again: - raise forms.ValidationError('Password input twice not match. ') + raise forms.ValidationError(u'密码二次输入不一致. ') return password_again def clean_key_pass_again(self): key_pass = self.data['key_pass'] key_pass_again = self.data['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: - raise forms.ValidationError('Key Password input twice not match. ') + raise forms.ValidationError(u'密码二次输入不一致. ') return key_pass_again \ No newline at end of file