mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-31 14:52:38 +00:00
[sys admin] Add system info page
This commit is contained in:
parent
27e494670f
commit
a23cf3db5e
@ -5,6 +5,9 @@
|
|||||||
<div class="side-tabnav">
|
<div class="side-tabnav">
|
||||||
<h3 class="hd">{% trans "System Admin" %}</h3>
|
<h3 class="hd">{% trans "System Admin" %}</h3>
|
||||||
<ul class="side-tabnav-tabs">
|
<ul class="side-tabnav-tabs">
|
||||||
|
<li class="tab {% block cur_info %}{% endblock %}">
|
||||||
|
<a href="{{ SITE_ROOT }}sys/info/" class="lib">{% trans "Info" %}</a>
|
||||||
|
</li>
|
||||||
<li class="tab {% block cur_repo %}{% endblock %}">
|
<li class="tab {% block cur_repo %}{% endblock %}">
|
||||||
<a href="{{ SITE_ROOT }}sys/seafadmin/" class="lib">{% trans "Libraries" %}</a>
|
<a href="{{ SITE_ROOT }}sys/seafadmin/" class="lib">{% trans "Libraries" %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
35
seahub/templates/sysadmin/sys_info.html
Normal file
35
seahub/templates/sysadmin/sys_info.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{% extends "sysadmin/base.html" %}
|
||||||
|
{% load seahub_tags i18n %}
|
||||||
|
|
||||||
|
{% block cur_info %}tab-cur{% endblock %}
|
||||||
|
|
||||||
|
{% block right_panel %}
|
||||||
|
<h3 class="hd">{% trans "Info" %}</h3>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>{% trans "System Info" %}</dt>
|
||||||
|
<dd>{% if is_pro %}
|
||||||
|
{% trans "Professional Edition" %} {% if license_dict %} {% trans "expires on" %} {{ license_dict.Expiration}}{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% trans "Community Edition" %}
|
||||||
|
<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 %}
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>{% trans "Libraries" %}</dt>
|
||||||
|
<dd>{{repos_count}}</dd>
|
||||||
|
|
||||||
|
<dt>{% trans "Users" %}</dt>
|
||||||
|
<dd>{{users_count}} {% if license_dict %}/ {{license_dict.MaxUsers}}{% endif %}</dd>
|
||||||
|
|
||||||
|
<dt>{% trans "Groups" %}</dt>
|
||||||
|
<dd>{{groups_count}}</dd>
|
||||||
|
|
||||||
|
{% if multi_tenancy %}
|
||||||
|
<dt>{% trans "Organizations" %}</dt>
|
||||||
|
<dd>{{org_count}}</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -203,6 +203,7 @@ urlpatterns = patterns('',
|
|||||||
(r'^thumbnail/', include('seahub.thumbnail.urls')),
|
(r'^thumbnail/', include('seahub.thumbnail.urls')),
|
||||||
|
|
||||||
### system admin ###
|
### system admin ###
|
||||||
|
url(r'^sys/info/$', sys_info, name='sys_info'),
|
||||||
url(r'^sys/seafadmin/$', sys_repo_admin, name='sys_repo_admin'),
|
url(r'^sys/seafadmin/$', sys_repo_admin, name='sys_repo_admin'),
|
||||||
url(r'^sys/seafadmin/system/$', sys_list_system, name='sys_list_system'),
|
url(r'^sys/seafadmin/system/$', sys_list_system, name='sys_list_system'),
|
||||||
url(r'^sys/seafadmin/repo-trash/$', sys_repo_trash, name='sys_repo_trash'),
|
url(r'^sys/seafadmin/repo-trash/$', sys_repo_trash, name='sys_repo_trash'),
|
||||||
|
37
seahub/utils/licenseparse.py
Normal file
37
seahub/utils/licenseparse.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def parse_license(file_path):
|
||||||
|
"""Parse license file and return dict.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
- `file_path`:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
e.g.
|
||||||
|
|
||||||
|
{'Hash': 'fdasfjl',
|
||||||
|
'Name': 'seafile official',
|
||||||
|
'Licencetype': 'User',
|
||||||
|
'LicenceKEY': '123',
|
||||||
|
'Expiration': '2016-3-2',
|
||||||
|
'MaxUsers': '1000000',
|
||||||
|
'ProductID': 'Seafile server for Windows'
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
ret = {}
|
||||||
|
lines = []
|
||||||
|
try:
|
||||||
|
with open(file_path) as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn(e)
|
||||||
|
return {}
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
if len(line.split('=')) == 2:
|
||||||
|
k, v = line.split('=')
|
||||||
|
ret[k.strip()] = v.strip().strip('"')
|
||||||
|
|
||||||
|
return ret
|
@ -29,6 +29,7 @@ from seahub.constants import GUEST_USER, DEFAULT_USER
|
|||||||
from seahub.utils import IS_EMAIL_CONFIGURED, string2list, is_valid_username, \
|
from seahub.utils import IS_EMAIL_CONFIGURED, string2list, is_valid_username, \
|
||||||
is_pro_version
|
is_pro_version
|
||||||
from seahub.utils.rpc import mute_seafile_api
|
from seahub.utils.rpc import mute_seafile_api
|
||||||
|
from seahub.utils.licenseparse import parse_license
|
||||||
from seahub.views import get_system_default_repo_id
|
from seahub.views import get_system_default_repo_id
|
||||||
from seahub.forms import SetUserQuotaForm, AddUserForm, BatchAddUserForm
|
from seahub.forms import SetUserQuotaForm, AddUserForm, BatchAddUserForm
|
||||||
from seahub.profile.models import Profile, DetailedProfile
|
from seahub.profile.models import Profile, DetailedProfile
|
||||||
@ -46,9 +47,44 @@ except:
|
|||||||
ENABLE_TRIAL_ACCOUNT = False
|
ENABLE_TRIAL_ACCOUNT = False
|
||||||
if ENABLE_TRIAL_ACCOUNT:
|
if ENABLE_TRIAL_ACCOUNT:
|
||||||
from seahub_extra.trialaccount.models import TrialAccount
|
from seahub_extra.trialaccount.models import TrialAccount
|
||||||
|
try:
|
||||||
|
from seahub.settings import MULTI_TENANCY
|
||||||
|
except ImportError:
|
||||||
|
MULTI_TENANCY = False
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@sys_staff_required
|
||||||
|
def sys_info(request):
|
||||||
|
"""System info(members, pro, ..) page.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
- `request`:
|
||||||
|
"""
|
||||||
|
users_count = ccnet_threaded_rpc.count_emailusers('DB')
|
||||||
|
repos_count = len(seafile_api.get_repo_list(-1, -1))
|
||||||
|
groups_count = len(ccnet_threaded_rpc.get_all_groups(-1, -1))
|
||||||
|
if MULTI_TENANCY:
|
||||||
|
org_count = ccnet_threaded_rpc.count_orgs()
|
||||||
|
else:
|
||||||
|
org_count = -1
|
||||||
|
|
||||||
|
is_pro = is_pro_version()
|
||||||
|
if is_pro:
|
||||||
|
license_dict = parse_license('../../../../seafile-license.txt')
|
||||||
|
else:
|
||||||
|
license_dict = {}
|
||||||
|
return render_to_response('sysadmin/sys_info.html', {
|
||||||
|
'users_count': users_count,
|
||||||
|
'repos_count': repos_count,
|
||||||
|
'groups_count': groups_count,
|
||||||
|
'org_count': org_count,
|
||||||
|
'is_pro': is_pro,
|
||||||
|
'license_dict': license_dict,
|
||||||
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@sys_staff_required
|
@sys_staff_required
|
||||||
def sys_repo_admin(request):
|
def sys_repo_admin(request):
|
||||||
|
Loading…
Reference in New Issue
Block a user