mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-21 03:18:23 +00:00
Refactor code
This commit is contained in:
@@ -17,8 +17,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
SEACLOUD_MODE = False
|
SEACLOUD_MODE = False
|
||||||
|
|
||||||
from seahub.utils import HAS_FILE_SEARCH, EVENTS_ENABLED, \
|
from seahub.utils import HAS_FILE_SEARCH, EVENTS_ENABLED, TRAFFIC_STATS_ENABLED
|
||||||
TRAFFIC_STATS_ENABLED, is_pro_version
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from seahub.settings import ENABLE_PUBFILE
|
from seahub.settings import ENABLE_PUBFILE
|
||||||
@@ -58,7 +57,6 @@ def base(request):
|
|||||||
repo_id_patt = r".*/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12})/.*"
|
repo_id_patt = r".*/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12})/.*"
|
||||||
m = re.match(repo_id_patt, request.get_full_path())
|
m = re.match(repo_id_patt, request.get_full_path())
|
||||||
search_repo_id = m.group(1) if m is not None else None
|
search_repo_id = m.group(1) if m is not None else None
|
||||||
is_pro = is_pro_version()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'seafile_version': SEAFILE_VERSION,
|
'seafile_version': SEAFILE_VERSION,
|
||||||
@@ -84,5 +82,4 @@ def base(request):
|
|||||||
'grps': grps,
|
'grps': grps,
|
||||||
'multi_tenancy': MULTI_TENANCY,
|
'multi_tenancy': MULTI_TENANCY,
|
||||||
'search_repo_id': search_repo_id,
|
'search_repo_id': search_repo_id,
|
||||||
'is_pro': is_pro,
|
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,7 @@
|
|||||||
$(function(){
|
$(function(){
|
||||||
// check if server version is the latest one
|
// check if server version is the latest one
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'http://seafile.com/ajax/check_server_version/?v=' + e('{{seafile_version}}') + '&p=' + e('{{platform}}') + '&id=' + '{{server_id}}' + {% if is_pro %} '&pro=1' {% else %} '' {% endif %},
|
url: 'http://seafile.com/ajax/check_server_version/?v=' + e('{{seafile_version}}') + '&p=' + e('{{platform}}') + '&id=' + '{{server_id}}' + '&pro=' + '{{pro_server}}',
|
||||||
dataType: 'jsonp',
|
dataType: 'jsonp',
|
||||||
jsonpCallback: 'xx',
|
jsonpCallback: 'xx',
|
||||||
crossDomain: true,
|
crossDomain: true,
|
||||||
|
@@ -24,7 +24,8 @@ from seahub.base.models import UserLastLogin
|
|||||||
from seahub.base.decorators import sys_staff_required
|
from seahub.base.decorators import sys_staff_required
|
||||||
from seahub.auth.decorators import login_required, login_required_ajax
|
from seahub.auth.decorators import login_required, login_required_ajax
|
||||||
from seahub.constants import GUEST_USER, DEFAULT_USER
|
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
|
||||||
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
|
||||||
@@ -206,6 +207,7 @@ def sys_user_admin(request):
|
|||||||
|
|
||||||
platform = get_platform_name()
|
platform = get_platform_name()
|
||||||
server_id = get_server_id()
|
server_id = get_server_id()
|
||||||
|
pro_server = 1 if is_pro_version() else 0
|
||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
'sysadmin/sys_useradmin.html', {
|
'sysadmin/sys_useradmin.html', {
|
||||||
@@ -222,6 +224,7 @@ def sys_user_admin(request):
|
|||||||
'default_user': DEFAULT_USER,
|
'default_user': DEFAULT_USER,
|
||||||
'guest_user': GUEST_USER,
|
'guest_user': GUEST_USER,
|
||||||
'enable_guest': ENABLE_GUEST,
|
'enable_guest': ENABLE_GUEST,
|
||||||
|
'pro_server': pro_server,
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
Reference in New Issue
Block a user