mirror of https://github.com/jumpserver/jumpserver
修改头像
parent
9bab7bf1e7
commit
1c96443e73
|
@ -1,5 +1,5 @@
|
|||
|
||||
def name_proc(request):
|
||||
user_id = request.session.get('user_id')
|
||||
role = request.session.get('role')
|
||||
return {'user_id': user_id, 'role': role}
|
||||
role = request.session.get('role_id')
|
||||
return {'user_id': user_id, 'role_id': role}
|
|
@ -111,4 +111,9 @@ def to_name(user_id):
|
|||
@register.filter(name='to_role_name')
|
||||
def to_role_name(role_id):
|
||||
role_dict = {'0': '普通用户', '1': '组管理员', '2': '超级管理员'}
|
||||
return role_dict.get(role_id, '未知')
|
||||
return role_dict.get(str(role_id), '未知')
|
||||
|
||||
@register.filter(name='to_avatar')
|
||||
def to_avatar(role_id):
|
||||
role_dict = {'0': 'user', '1': 'admin', '2': 'root'}
|
||||
return role_dict.get(str(role_id), 'user')
|
|
@ -111,11 +111,11 @@ def login(request):
|
|||
if md5_crypt(password) == user.password:
|
||||
request.session['user_id'] = user.id
|
||||
if user.role == 'SU':
|
||||
request.session['role'] = 2
|
||||
request.session['role_id'] = 2
|
||||
elif user.role == 'GA':
|
||||
request.session['role'] = 1
|
||||
request.session['role_id'] = 1
|
||||
else:
|
||||
request.session['role'] = 0
|
||||
request.session['role_id'] = 0
|
||||
return HttpResponseRedirect('/')
|
||||
else:
|
||||
error = '密码错误,请重新输入。'
|
||||
|
|
|
@ -17,4 +17,6 @@ urlpatterns = patterns('juser.views',
|
|||
(r'^group_detail/$', 'group_detail'),
|
||||
(r'^group_del/$', 'group_del'),
|
||||
(r'^group_edit/$', 'group_edit'),
|
||||
(r'^profile/$', 'profile'),
|
||||
(r'^chg_pass/$', 'chg_pass'),
|
||||
)
|
||||
|
|
|
@ -505,7 +505,18 @@ def user_add(request):
|
|||
return render_to_response('juser/user_add.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
||||
|
||||
def profile(request):
|
||||
user_id = request.session.get('user_id')
|
||||
if not user_id:
|
||||
return HttpResponseRedirect('/')
|
||||
user = User.objects.get(id=user_id)
|
||||
return render_to_response('juser/user_detail.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def chg_pass(request):
|
||||
header_title, path1, path2 = '修改信息 | Edit Info', '用户管理', '修改个人信息'
|
||||
|
||||
return render_to_response('juser/user_add.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
{% load mytags %}
|
||||
<li class="nav-header">
|
||||
<div class="dropdown profile-element"> <span>
|
||||
<img alt="image" class="img-circle" src="/static/img/profile_small.jpg" />
|
||||
<img alt="image" class="img-circle" width="64" height="64" src="/static/img/{{ role_id | to_avatar }}.png" />
|
||||
</span>
|
||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||
<span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">{{ user_id }}</strong>
|
||||
</span> <span class="text-muted text-xs block">{{ role }} <b class="caret"></b></span> </span> </a>
|
||||
<span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">{{ user_id | to_name}}</strong>
|
||||
</span> <span class="text-muted text-xs block">{{ role_id | to_role_name }} <b class="caret"></b></span> </span> </a>
|
||||
<ul class="dropdown-menu animated fadeInRight m-t-xs">
|
||||
<li><a href="profile.html">Profile</a></li>
|
||||
<li><a href="contacts.html">Contacts</a></li>
|
||||
<li><a href="mailbox.html">Mailbox</a></li>
|
||||
<li><a href="/juser/profile/">个人信息</a></li>
|
||||
<li><a href="/juser/chg_pass/">修改密码</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="/logout/">Logout</a></li>
|
||||
<li><a href="/logout/">注销</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="logo-element">
|
||||
|
|
Loading…
Reference in New Issue