1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 18:29:23 +00:00

[inst] Update user table

This commit is contained in:
zhengxie
2016-08-08 18:19:00 +08:00
parent 06022c3109
commit e48ae64576
4 changed files with 26 additions and 21 deletions

View File

@@ -13,7 +13,7 @@
{% if users %}
<table>
<tr>
<th width="36%">{% trans "Email" %}</th>
<th width="36%">{% trans "Email" %} / {% trans "Name" %} / {% trans "Contact Email" %}</th>
<th width="12%">{% trans "Status" %}</th>
<th width="16%">{% trans "Space Used" %}</th>
<th width="22%">{% trans "Create At / Last Login" %}</th>
@@ -22,7 +22,10 @@
{% for user in users %}
<tr data-userid="{{user.email}}">
<td><a href="{% url 'institutions:user_info' user.email %}">{{ user.email }}</a>
<td>
<a href="{% url 'institutions:user_info' user.email %}">{{ user.email }}</a>
{% if user.name %}<br />{{ user.name }}{% endif %}
{% if user.contact_email %}<br />{{ user.contact_email }}{% endif %}
</td>
<td>
<div class="user-status">

View File

@@ -15,7 +15,7 @@
{% if users %}
<table>
<tr>
<th width="36%">{% trans "Email" %}</th>
<th width="36%">{% trans "Email" %} / {% trans "Name" %} / {% trans "Contact Email" %}</th>
<th width="12%">{% trans "Status" %}</th>
<th width="16%">{% trans "Space Used" %}</th>
<th width="22%">{% trans "Create At / Last Login" %}</th>
@@ -24,7 +24,10 @@
{% for user in users %}
<tr data-userid="{{user.email}}">
<td><a href="{% url 'institutions:user_info' user.email %}">{{ user.email }}</a>
<td>
<a href="{% url 'institutions:user_info' user.email %}">{{ user.email }}</a>
{% if user.name %}<br />{{ user.name }}{% endif %}
{% if user.contact_email %}<br />{{ user.contact_email }}{% endif %}
</td>
<td>
<div class="user-status">

View File

@@ -21,7 +21,7 @@ from seahub.institutions.decorators import (inst_admin_required,
from seahub.profile.models import Profile, DetailedProfile
from seahub.utils import is_valid_username, clear_token
from seahub.utils.rpc import mute_seafile_api
from seahub.views.sysadmin import email_user_on_activation
from seahub.views.sysadmin import email_user_on_activation, populate_user_info
logger = logging.getLogger(__name__)
@@ -75,6 +75,7 @@ def useradmin(request):
if u.username == request.user.username:
u.is_self = True
populate_user_info(u)
_populate_user_quota_usage(u)
for e in last_logins:
@@ -110,6 +111,7 @@ def useradmin_search(request):
if u.username == request.user.username:
u.is_self = True
populate_user_info(u)
_populate_user_quota_usage(u)
for e in last_logins:

View File

@@ -112,6 +112,17 @@ def can_view_sys_admin_repo(repo):
else:
return False
def populate_user_info(user):
"""Populate contact email and nickname to user.
"""
user_profile = Profile.objects.get_profile_by_user(user.email)
if user_profile:
user.contact_email = user_profile.contact_email
user.name = user_profile.nickname
else:
user.contact_email = ''
user.name = ''
def _populate_user_quota_usage(user):
"""Populate space/share quota to user.
@@ -190,17 +201,10 @@ def sys_user_admin(request):
else:
trial_users = []
for user in users:
user_profile = Profile.objects.get_profile_by_user(user.email)
if user_profile:
user.contact_email = user_profile.contact_email
user.name = user_profile.nickname
else:
user.contact_email = ''
user.name = ''
if user.email == request.user.email:
user.is_self = True
populate_user_info(user)
_populate_user_quota_usage(user)
# check user's role
@@ -1458,16 +1462,9 @@ def user_search(request):
else:
trial_users = []
for user in users:
populate_user_info(user)
_populate_user_quota_usage(user)
user_profile = Profile.objects.get_profile_by_user(user.email)
if user_profile:
user.contact_email = user_profile.contact_email
user.name = user_profile.nickname
else:
user.contact_email = ''
user.name = ''
# check user's role
if user.role == GUEST_USER:
user.is_guest = True