From c588aaea3afc955df4056d09f4d80da4ff4e5410 Mon Sep 17 00:00:00 2001 From: guanghongwei Date: Sun, 28 Sep 2014 11:57:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A8=A3=E8=AF=B2=E5=A7=9E=E6=B7=87=EE=86=BD?= =?UTF-8?q?=E6=95=BC=E9=90=A2=E3=84=A6=E5=9F=9B=E6=B7=87=E2=84=83=E4=BC=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webroot/AutoSa/AutoSa/urls.py | 1 + webroot/AutoSa/AutoSa/views.py | 16 ++++- webroot/AutoSa/UserManage/forms.py | 6 +- webroot/AutoSa/templates/chgUser.html | 96 ++++++++++++++++++++++++++ webroot/AutoSa/templates/showUser.html | 2 + 5 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 webroot/AutoSa/templates/chgUser.html diff --git a/webroot/AutoSa/AutoSa/urls.py b/webroot/AutoSa/AutoSa/urls.py index d16a55e60..37885677a 100644 --- a/webroot/AutoSa/AutoSa/urls.py +++ b/webroot/AutoSa/AutoSa/urls.py @@ -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), diff --git a/webroot/AutoSa/AutoSa/views.py b/webroot/AutoSa/AutoSa/views.py index afd533791..b2d3a4cb0 100644 --- a/webroot/AutoSa/AutoSa/views.py +++ b/webroot/AutoSa/AutoSa/views.py @@ -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'}, diff --git a/webroot/AutoSa/UserManage/forms.py b/webroot/AutoSa/UserManage/forms.py index affecacf0..9232ac884 100644 --- a/webroot/AutoSa/UserManage/forms.py +++ b/webroot/AutoSa/UserManage/forms.py @@ -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': '确认密码'})) diff --git a/webroot/AutoSa/templates/chgUser.html b/webroot/AutoSa/templates/chgUser.html new file mode 100644 index 000000000..5f0ead618 --- /dev/null +++ b/webroot/AutoSa/templates/chgUser.html @@ -0,0 +1,96 @@ +{% extends 'base.html' %} +{% block content %} +
+
+ 修改用户信息 + {% if error %} +
+ {{ error }} +
+ {% endif %} + + {% if form.errors %} +
+ Please correct the error{{ form.errors|pluralize }} below. +
+ {% endif %} + + {% if msg %} +
+ {{ msg }} +
+ {% endif %} +
+ {{ form.username.errors }} + +
+ +
+
+
+ {{ form.password.errors }} + +
+ {{ form.password }} +
+
+
+ {{ form.password_again.errors }} + +
+ {{ form.password_again }} +
+
+
+ {{ form.key_pass.errors }} + +
+ {{ form.key_pass }} +
+
+
+ {{ form.key_pass_again.errors }} + +
+ {{ form.key_pass_again }} +
+
+
+ {{ form.name.errors }} + +
+ {{ form.name }} + {{ user.name }} +
+
+
+ {{ form.group.errors }} + +
+ {{ form.group }} +
+
+
+ {{ form.is_admin.errors }} + +
+ {{ form.is_admin }} + {{ user.is_admin }} +
+
+
+ {{ form.is_superuser.errors }} + +
+ {{ form.is_superuser }} + {{ user.is_superuser }} +
+
+
+
+ +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/webroot/AutoSa/templates/showUser.html b/webroot/AutoSa/templates/showUser.html index 5747cc455..c7ee39344 100644 --- a/webroot/AutoSa/templates/showUser.html +++ b/webroot/AutoSa/templates/showUser.html @@ -18,6 +18,7 @@ is_superuser Email Key + 修改 @@ -37,6 +38,7 @@ {{ user.is_superuser }} {{ user.email }} 下载 + 修改 {% endfor %}