mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 01:44:13 +00:00
Merge pull request #800 from haiwen/active-users
show active users count at sys info page
This commit is contained in:
@@ -15,12 +15,27 @@
|
|||||||
<a href="http://manual{% if LANGUAGE_CODE == 'zh-cn' %}-cn{% endif %}.seafile.com/deploy_pro/migrate_from_seafile_community_server.html" target="_blank">{% trans "Upgrade to Pro Edition" %}</a>
|
<a href="http://manual{% if LANGUAGE_CODE == 'zh-cn' %}-cn{% endif %}.seafile.com/deploy_pro/migrate_from_seafile_community_server.html" target="_blank">{% trans "Upgrade to Pro Edition" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>{% trans "Libraries" %}</dt>
|
<dt>{% trans "Libraries" %}</dt>
|
||||||
<dd>{{repos_count}}</dd>
|
<dd>{{repos_count}}</dd>
|
||||||
|
|
||||||
<dt>{% trans "Users" %}</dt>
|
{% if is_pro %}
|
||||||
<dd>{{users_count}} {% if license_dict %}/ {{license_dict.MaxUsers}}{% endif %}</dd>
|
<dt>{% trans "Active Users" %} / {% trans "Total Users" %} / {% trans "Limits" %}</dt>
|
||||||
|
<dd>
|
||||||
|
{% if active_users_count %}{{ active_users_count }}{% else %}--{% endif %}
|
||||||
|
/
|
||||||
|
{% if users_count %}{{ users_count }}{% else %}--{% endif %}
|
||||||
|
/
|
||||||
|
{% if license_dict %}{{ license_dict.MaxUsers }}{% else %}--{% endif %}
|
||||||
|
</dd>
|
||||||
|
{% else %}
|
||||||
|
<dt>{% trans "Active Users" %} / {% trans "Total Users" %}</dt>
|
||||||
|
<dd>
|
||||||
|
{% if active_users_count %}{{ active_users_count }}{% else %}--{% endif %}
|
||||||
|
/
|
||||||
|
{% if users_count %}{{ users_count }}{% else %}--{% endif %}
|
||||||
|
</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<dt>{% trans "Groups" %}</dt>
|
<dt>{% trans "Groups" %}</dt>
|
||||||
<dd>{{groups_count}}</dd>
|
<dd>{{groups_count}}</dd>
|
||||||
|
@@ -62,20 +62,18 @@ def sys_info(request):
|
|||||||
Arguments:
|
Arguments:
|
||||||
- `request`:
|
- `request`:
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
users_count = ccnet_threaded_rpc.count_emailusers('DB') + ccnet_threaded_rpc.count_emailusers('LDAP')
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(e)
|
|
||||||
users_count = 0
|
|
||||||
|
|
||||||
|
# count repos
|
||||||
repos_count = mute_seafile_api.count_repos()
|
repos_count = mute_seafile_api.count_repos()
|
||||||
|
|
||||||
|
# count groups
|
||||||
try:
|
try:
|
||||||
groups_count = len(ccnet_threaded_rpc.get_all_groups(-1, -1))
|
groups_count = len(ccnet_threaded_rpc.get_all_groups(-1, -1))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
groups_count = 0
|
groups_count = 0
|
||||||
|
|
||||||
|
# count orgs
|
||||||
if MULTI_TENANCY:
|
if MULTI_TENANCY:
|
||||||
try:
|
try:
|
||||||
org_count = ccnet_threaded_rpc.count_orgs()
|
org_count = ccnet_threaded_rpc.count_orgs()
|
||||||
@@ -85,14 +83,47 @@ def sys_info(request):
|
|||||||
else:
|
else:
|
||||||
org_count = -1
|
org_count = -1
|
||||||
|
|
||||||
|
# count users
|
||||||
|
try:
|
||||||
|
active_db_users = ccnet_threaded_rpc.count_emailusers('DB')
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
active_db_users = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
active_ldap_users = ccnet_threaded_rpc.count_emailusers('LDAP')
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
active_ldap_users = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
inactive_db_users = ccnet_threaded_rpc.count_inactive_emailusers('DB')
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
inactive_db_users = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
inactive_ldap_users = ccnet_threaded_rpc.count_inactive_emailusers('LDAP')
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
inactive_ldap_users = 0
|
||||||
|
|
||||||
|
active_users = active_db_users + active_ldap_users if active_ldap_users > 0 \
|
||||||
|
else active_db_users
|
||||||
|
|
||||||
|
inactive_users = inactive_db_users + inactive_ldap_users if inactive_ldap_users > 0 \
|
||||||
|
else inactive_db_users
|
||||||
|
|
||||||
is_pro = is_pro_version()
|
is_pro = is_pro_version()
|
||||||
if is_pro:
|
if is_pro:
|
||||||
license_file = os.path.join(settings.PROJECT_ROOT, '../../seafile-license.txt')
|
license_file = os.path.join(settings.PROJECT_ROOT, '../../seafile-license.txt')
|
||||||
license_dict = parse_license(license_file)
|
license_dict = parse_license(license_file)
|
||||||
else:
|
else:
|
||||||
license_dict = {}
|
license_dict = {}
|
||||||
|
|
||||||
return render_to_response('sysadmin/sys_info.html', {
|
return render_to_response('sysadmin/sys_info.html', {
|
||||||
'users_count': users_count,
|
'users_count': active_users + inactive_users,
|
||||||
|
'active_users_count': active_users,
|
||||||
'repos_count': repos_count,
|
'repos_count': repos_count,
|
||||||
'groups_count': groups_count,
|
'groups_count': groups_count,
|
||||||
'org_count': org_count,
|
'org_count': org_count,
|
||||||
|
Reference in New Issue
Block a user