mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-30 13:23:14 +00:00
Add email-userid info page
This commit is contained in:
parent
8c9a5084e6
commit
5b92a3aab9
@ -13,21 +13,20 @@
|
|||||||
<h2>所有用户</h2>
|
<h2>所有用户</h2>
|
||||||
<table class="user-list">
|
<table class="user-list">
|
||||||
<tr>
|
<tr>
|
||||||
<th width="30%">邮箱</th>
|
<th width="70%">邮箱</th>
|
||||||
<th width="10%">是否激活</th>
|
<th width="20%">是否激活</th>
|
||||||
<th width="40%">个人 ID</th>
|
|
||||||
<th width="10%">角色</th>
|
|
||||||
<th width="10%">操作</th>
|
<th width="10%">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ user.props.email }}</td>
|
<td><a href="{{ SITE_ROOT }}useradmin/info/{{ user.props.email }}">{{ user.props.email }}</a></td>
|
||||||
{% if user.props.is_active %}
|
{% if user.props.is_active %}
|
||||||
<td>已激活</td>
|
<td>已激活</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td><button data="{{ SITE_ROOT }}useradmin/activate/{{ user.props.id }}/" class="activate">激活</button></td>
|
<td><button data="{{ SITE_ROOT }}useradmin/activate/{{ user.props.id }}/" class="activate">激活</button></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<!--
|
||||||
{% if user.userid_list %}
|
{% if user.userid_list %}
|
||||||
<td>{{ user.userid_list|first }}</td>
|
<td>{{ user.userid_list|first }}</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -35,9 +34,10 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<td>
|
<td>
|
||||||
{% for role in user.role_list %}
|
{% for role in user.role_list %}
|
||||||
{{ role }} <!--<button data="{{ SITE_ROOT }}useradmin/{{ user.profile.ccnet_user_id }}/role/remove/?role={{ role }}" class="role-delete-btn">删除</button>--><br />
|
{{ role }} <button data="{{ SITE_ROOT }}useradmin/{{ user.profile.ccnet_user_id }}/role/remove/?role={{ role }}" class="role-delete-btn">删除</button><br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
|
-->
|
||||||
<td>
|
<td>
|
||||||
{% if user.profile %}
|
{% if user.profile %}
|
||||||
<!-- <button class="add-role-btn" userid="{{ user.profile.ccnet_user_id }}" email="{{ user.email }}">添加角色</button> -->
|
<!-- <button class="add-role-btn" userid="{{ user.profile.ccnet_user_id }}" email="{{ user.email }}">添加角色</button> -->
|
||||||
|
55
templates/userinfo.html
Normal file
55
templates/userinfo.html
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
{% extends "myhome_base.html" %}
|
||||||
|
|
||||||
|
{% block nav_useradmin_class %}class="cur"{% endblock %}
|
||||||
|
{% block left_panel %}
|
||||||
|
<ul>
|
||||||
|
<li><a href="{{ SITE_ROOT }}useradmin/add/">添加用户</a></li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block right_panel %}
|
||||||
|
|
||||||
|
<h2>用户信息</h2>
|
||||||
|
<table class="user-list">
|
||||||
|
<tr>
|
||||||
|
<th width="50%">个人 ID</th>
|
||||||
|
<th width="30%">角色</th>
|
||||||
|
<th width="20%">状态</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% for userid, roles in user_dict.items %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ userid }}</td>
|
||||||
|
<td>{{ roles }}</td>
|
||||||
|
{% if roles %}
|
||||||
|
<td>已验证</td>
|
||||||
|
{% else %}
|
||||||
|
<td>未验证</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_script %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
$('.activate').each(function(){
|
||||||
|
$(this).click(function(){
|
||||||
|
location.href = $(this).attr('data');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$(".add-role-btn").each(function() {
|
||||||
|
$(this).click(function() {
|
||||||
|
var url = "{{ SITE_ROOT }}useradmin/" + $(this).attr("userid") + "/role/add/";
|
||||||
|
$("#add-role-form").attr('action', url);
|
||||||
|
$("#add-role-form #user_email").html($(this).attr("email"));
|
||||||
|
$("#add-role-form").modal({appendTo: "#main"});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//delete confirm
|
||||||
|
addConfirmTo($('.remove-user-btn'));
|
||||||
|
addConfirmTo($('.role-delete-btn'));
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
3
urls.py
3
urls.py
@ -5,7 +5,7 @@ from django.views.generic.simple import direct_to_template
|
|||||||
from seahub.views import root, peers, groups, myhome, \
|
from seahub.views import root, peers, groups, myhome, \
|
||||||
repo, group, modify_token, remove_repo, seafadmin, useradmin, \
|
repo, group, modify_token, remove_repo, seafadmin, useradmin, \
|
||||||
role_add, role_remove, activate_user, user_add, user_remove, \
|
role_add, role_remove, activate_user, user_add, user_remove, \
|
||||||
ownerhome, remove_fetched_repo
|
ownerhome, remove_fetched_repo, user_info
|
||||||
|
|
||||||
# Uncomment the next two lines to enable the admin:
|
# Uncomment the next two lines to enable the admin:
|
||||||
#from django.contrib import admin
|
#from django.contrib import admin
|
||||||
@ -36,6 +36,7 @@ urlpatterns = patterns('',
|
|||||||
(r'^seafadmin/$', seafadmin),
|
(r'^seafadmin/$', seafadmin),
|
||||||
url(r'^useradmin/$', useradmin, name='useradmin'),
|
url(r'^useradmin/$', useradmin, name='useradmin'),
|
||||||
(r'^useradmin/add/$', user_add),
|
(r'^useradmin/add/$', user_add),
|
||||||
|
(r'^useradmin/info/(?P<email>[^/]+)/$', user_info),
|
||||||
(r'^useradmin/(?P<user_id>[^/]+)/role/add/$', role_add),
|
(r'^useradmin/(?P<user_id>[^/]+)/role/add/$', role_add),
|
||||||
(r'^useradmin/(?P<user_id>[^/]+)/role/remove/$', role_remove),
|
(r'^useradmin/(?P<user_id>[^/]+)/role/remove/$', role_remove),
|
||||||
(r'^useradmin/(?P<user_id>[^/]+)/user/remove/$', user_remove),
|
(r'^useradmin/(?P<user_id>[^/]+)/user/remove/$', user_remove),
|
||||||
|
22
views.py
22
views.py
@ -278,7 +278,7 @@ def useradmin(request):
|
|||||||
try:
|
try:
|
||||||
user.userid_list = get_binding_userids(user.get_email())
|
user.userid_list = get_binding_userids(user.get_email())
|
||||||
# user.ccnet_user = ccnet_rpc.get_user(user.profile.ccnet_user_id)
|
# user.ccnet_user = ccnet_rpc.get_user(user.profile.ccnet_user_id)
|
||||||
user.role_list = user.ccnet_user.props.role_list.split(',')
|
# user.role_list = user.ccnet_user.props.role_list.split(',')
|
||||||
except:
|
except:
|
||||||
user.ccnet_user = None
|
user.ccnet_user = None
|
||||||
|
|
||||||
@ -288,6 +288,26 @@ def useradmin(request):
|
|||||||
},
|
},
|
||||||
context_instance=RequestContext(request))
|
context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def user_info(request, email):
|
||||||
|
if not request.user.is_staff:
|
||||||
|
raise Http404
|
||||||
|
|
||||||
|
user_dict = {}
|
||||||
|
|
||||||
|
userid_list = get_binding_userids(email)
|
||||||
|
for userid in userid_list:
|
||||||
|
try:
|
||||||
|
roles = ccnet_rpc.get_user(userid).props.role_list
|
||||||
|
except:
|
||||||
|
roles = ''
|
||||||
|
user_dict[userid] = roles
|
||||||
|
|
||||||
|
return render_to_response(
|
||||||
|
'userinfo.html', {
|
||||||
|
'user_dict': user_dict,
|
||||||
|
},
|
||||||
|
context_instance=RequestContext(request))
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def role_add(request, user_id):
|
def role_add(request, user_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user