diff --git a/seahub/base/context_processors.py b/seahub/base/context_processors.py index 1878efaa8f..33ee5b0b5b 100644 --- a/seahub/base/context_processors.py +++ b/seahub/base/context_processors.py @@ -23,6 +23,10 @@ try: from seahub.settings import ENABLE_PUBFILE except ImportError: ENABLE_PUBFILE = False +try: + from seahub.settings import ENABLE_SYSADMIN_EXTRA +except ImportError: + ENABLE_SYSADMIN_EXTRA = False def base(request): """ @@ -70,6 +74,7 @@ def base(request): 'repo_password_min_length': REPO_PASSWORD_MIN_LENGTH, 'events_enabled': EVENTS_ENABLED, 'traffic_stats_enabled': TRAFFIC_STATS_ENABLED, + 'sysadmin_extra_enabled': ENABLE_SYSADMIN_EXTRA, 'mods_available': mods_available, 'mods_enabled': mods_enabled, 'grps': grps, diff --git a/seahub/templates/sysadmin/base.html b/seahub/templates/sysadmin/base.html index 18924ef128..f773a03b9e 100644 --- a/seahub/templates/sysadmin/base.html +++ b/seahub/templates/sysadmin/base.html @@ -25,6 +25,11 @@ {% trans "Traffic" %} {% endif %} + {% if sysadmin_extra_enabled %} +
  • + {% trans "Login" %} +
  • + {% endif %} {% endblock %} diff --git a/seahub/urls.py b/seahub/urls.py index 88e585a442..4e6f12f9c0 100644 --- a/seahub/urls.py +++ b/seahub/urls.py @@ -221,6 +221,12 @@ if getattr(settings, 'ENABLE_PAYMENT', False): (r'^pay/', include('seahub_extra.pay.urls')), ) +if getattr(settings, 'ENABLE_SYSADMIN_EXTRA', False): + from seahub_extra.sysadmin_extra.views import sys_login_admin + urlpatterns += patterns('', + url(r'^sys/loginadmin/', sys_login_admin, name='sys_login_admin'), + ) + # serve office converter static files from seahub.utils import HAS_OFFICE_CONVERTER if HAS_OFFICE_CONVERTER: diff --git a/seahub/utils/ip.py b/seahub/utils/ip.py new file mode 100644 index 0000000000..15a59d4d96 --- /dev/null +++ b/seahub/utils/ip.py @@ -0,0 +1,7 @@ +def get_remote_ip(request): + x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') + if x_forwarded_for: + ip = x_forwarded_for.split(',')[0] + else: + ip = request.META.get('REMOTE_ADDR', '-') + return ip