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

Only show share usage when option is enabled

This commit is contained in:
zhengxie
2014-12-25 14:40:54 +08:00
parent 04e365e026
commit 444fc459d0
6 changed files with 37 additions and 16 deletions

View File

@@ -1,10 +1,12 @@
{% load i18n %}
<div class="item">
<p>{% trans "Self:" %} {{ space_usage|filesizeformat }} {% if space_quota > 0 %}/ {{ space_quota|filesizeformat }} {% endif %}</p>
<p>{% trans "Used:" %} {{ space_usage|filesizeformat }} {% if space_quota > 0 %}/ {{ space_quota|filesizeformat }} {% endif %}</p>
{% if not org %}
{% if CALC_SHARE_USAGE %}
<p>{% trans "Sharing:" %} {{ share_usage|filesizeformat }} {% if share_quota > 0 %}/ {{ share_quota|filesizeformat }} {% endif %}</p>
{% endif %}
{% endif %}
{% if space_quota > 0 or share_quota > 0 %}
<div id="quota-bar">

View File

@@ -41,10 +41,10 @@
<tr>
<th width="25%">{% trans "Email" %}</th>
<th width="12%">{% trans "Status" %}</th>
<th width="11%">{% trans "Role" %}</th>
<th width="15%">{% trans "Space Used" %}</th>
<th width="9%">{% trans "Role" %}</th>
<th width="18%">{% trans "Space Used" %}</th>
<th width="22%">{% trans "Create At / Last Login" %}</th>
<th width="15%">{% trans "Operations" %}</th>
<th width="14%">{% trans "Operations" %}</th>
</tr>
{% for user in admin_users %}
@@ -85,11 +85,12 @@
{% endif %}
</td>
<td>
<td style="font-size:11px;">
<p> {{ user.space_usage|filesizeformat }} {% if user.space_quota > 0 %} / {{ user.space_quota|filesizeformat }} {% endif %} </p>
{% if not user.org %}
{% if CALC_SHARE_USAGE %}
{{ user.self_usage|filesizeformat }} + {{ user.share_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
{% else %}
{{ user.self_usage|filesizeformat }} {% if user.quota > 0 %} / {{ user.quota|filesizeformat }} {% endif %}
<p> {{ user.share_usage|filesizeformat }} {% if user.share_quota > 0 %} / {{ user.share_quota|filesizeformat }} {% endif %} </p>
{% endif %}
{% endif %}
</td>
<td>

View File

@@ -4,7 +4,7 @@
<th width="25%">{% trans "Email" %}</th>
<th width="12%">{% trans "Status" %}</th>
<th width="9%">{% trans "Role" %}</th>
<th width="18%">{% trans "Space/Share Used" %}</th>
<th width="18%">{% trans "Space Used" %}</th>
<th width="22%">{% trans "Create At / Last Login" %}</th>
<th width="14%">{% trans "Operations" %}</th>
</tr>
@@ -56,8 +56,10 @@
<td style="font-size:11px;">
<p> {{ user.space_usage|filesizeformat }} {% if user.space_quota > 0 %} / {{ user.space_quota|filesizeformat }} {% endif %} </p>
{% if not user.org %}
{% if CALC_SHARE_USAGE %}
<p> {{ user.share_usage|filesizeformat }} {% if user.share_quota > 0 %} / {{ user.share_quota|filesizeformat }} {% endif %} </p>
{% endif %}
{% endif %}
</td>
<td>
{% if user.source != 'LDAP' %}

View File

@@ -40,8 +40,11 @@
</dl>
<h3 class="hd">{% trans "Space Used" %}</h3>
<p>{% trans "Self" %}: {{ space_usage|filesizeformat }} {% if space_quota > 0 %} / {{ space_quota|filesizeformat }} {% endif %}</p>
<p>{% trans "Used" %}: {{ space_usage|filesizeformat }} {% if space_quota > 0 %} / {{ space_quota|filesizeformat }} {% endif %}</p>
{% if CALC_SHARE_USAGE %}
<p>{% trans "Sharing" %}: {{ share_usage|filesizeformat }} {% if share_quota > 0 %} / {{ share_quota|filesizeformat }} {% endif %}</p>
{% endif %}
<a href="#" id="set-quota">{% trans "Set Quota" %}</a>
</div>

View File

@@ -1387,8 +1387,12 @@ def space_and_traffic(request):
if not org:
space_quota = seafile_api.get_user_quota(username)
space_usage = seafile_api.get_user_self_usage(username)
if CALC_SHARE_USAGE:
share_quota = seafile_api.get_user_share_quota(username)
share_usage = seafile_api.get_user_share_usage(username)
else:
share_quota = 0
share_usage = 0
else:
org_id = org[0].org_id
space_quota = seafserv_threaded_rpc.get_org_user_quota(org_id,
@@ -1446,6 +1450,7 @@ def space_and_traffic(request):
"space_usage": space_usage,
"share_quota": share_quota,
"share_usage": share_usage,
"CALC_SHARE_USAGE": CALC_SHARE_USAGE,
"show_quota_help": not CALC_SHARE_USAGE,
"rates": rates,
"TRAFFIC_STATS_ENABLED": TRAFFIC_STATS_ENABLED,

View File

@@ -166,9 +166,13 @@ def _populate_user_quota_usage(user):
user.share_usage = user.share_quota = 0
else:
user.space_usage = seafile_api.get_user_self_usage(user.email)
user.share_usage = seafile_api.get_user_share_usage(user.email)
user.space_quota = seafile_api.get_user_quota(user.email)
if CALC_SHARE_USAGE:
user.share_quota = seafile_api.get_user_share_quota(user.email)
user.share_usage = seafile_api.get_user_share_usage(user.email)
else:
user.share_usage = user.share_quota = 0
except SearpcError as e:
logger.error(e)
user.space_usage = user.space_quota = user.share_usage = user.share_quota = -1
@@ -332,8 +336,11 @@ def user_info(request, email):
if not org:
space_usage = seafile_api.get_user_self_usage(email)
space_quota = seafile_api.get_user_quota(email)
if CALC_SHARE_USAGE:
share_usage = seafile_api.get_user_share_usage(email)
share_quota = seafile_api.get_user_share_quota(email)
else:
share_quota = share_usage = 0
else:
org_id = org[0].org_id
org_name = org[0].org_name
@@ -413,6 +420,7 @@ def user_info(request, email):
'space_usage': space_usage,
'share_quota': share_quota,
'share_usage': share_usage,
'CALC_SHARE_USAGE': CALC_SHARE_USAGE,
'in_repos': in_repos,
'email': email,
'profile': profile,