diff --git a/seahub/base/accounts.py b/seahub/base/accounts.py
index 1acf66da5e..b4ba342f96 100644
--- a/seahub/base/accounts.py
+++ b/seahub/base/accounts.py
@@ -329,7 +329,7 @@ class User(object):
signals.user_deleted.send(sender=self.__class__, username=username)
Profile.objects.delete_profile_by_user(username)
- if settings.ENABLE_TERMS_AND_CONDITIONS:
+ if config.ENABLE_TERMS_AND_CONDITIONS:
from termsandconditions.models import UserTermsAndConditions
UserTermsAndConditions.objects.filter(username=username).delete()
self.delete_user_options(username)
diff --git a/seahub/base/context_processors.py b/seahub/base/context_processors.py
index a1e08ecc3d..42b41670de 100644
--- a/seahub/base/context_processors.py
+++ b/seahub/base/context_processors.py
@@ -112,7 +112,7 @@ def base(request):
'enable_thumbnail': ENABLE_THUMBNAIL,
'thumbnail_size_for_original': THUMBNAIL_SIZE_FOR_ORIGINAL,
'enable_guest_invitation': ENABLE_GUEST_INVITATION,
- 'enable_terms_and_conditions': dj_settings.ENABLE_TERMS_AND_CONDITIONS,
+ 'enable_terms_and_conditions': config.ENABLE_TERMS_AND_CONDITIONS,
'show_logout_icon': SHOW_LOGOUT_ICON,
'is_pro': True if is_pro_version() else False,
}
diff --git a/seahub/settings.py b/seahub/settings.py
index 04c4f14fb7..cdff74fc1c 100644
--- a/seahub/settings.py
+++ b/seahub/settings.py
@@ -795,4 +795,6 @@ CONSTANCE_CONFIG = {
'ENABLE_BRANDING_CSS': (ENABLE_BRANDING_CSS, ''),
'CUSTOM_CSS': ('', ''),
+
+ 'ENABLE_TERMS_AND_CONDITIONS': (ENABLE_TERMS_AND_CONDITIONS, ''),
}
diff --git a/seahub/templates/nav_footer.html b/seahub/templates/nav_footer.html
index 3ffefc7824..07378fc9fb 100644
--- a/seahub/templates/nav_footer.html
+++ b/seahub/templates/nav_footer.html
@@ -1,6 +1,9 @@
{% load i18n %}
{% trans "Help" %}
{% trans "About" %}
+{% if enable_terms_and_conditions %}
+{% trans "Terms" %}
+{% endif %}
{% trans "Clients" %}
diff --git a/seahub/templates/snippets/web_settings_form.html b/seahub/templates/snippets/web_settings_form.html
index b12670dd68..84feb663e6 100644
--- a/seahub/templates/snippets/web_settings_form.html
+++ b/seahub/templates/snippets/web_settings_form.html
@@ -72,3 +72,16 @@
{% endif %}
+
+{% if type == 'terms' %}
+
+{% endif %}
+
diff --git a/seahub/templates/sysadmin/base.html b/seahub/templates/sysadmin/base.html
index 548f8985d4..8ad1c6efcd 100644
--- a/seahub/templates/sysadmin/base.html
+++ b/seahub/templates/sysadmin/base.html
@@ -106,8 +106,8 @@
{% endif %}
- {% if enable_terms_and_conditions and is_default_admin %}
-
+ {% if is_default_admin %}
+
{% trans "Terms and Conditions" %}
{% endif %}
diff --git a/seahub/templates/sysadmin/settings.html b/seahub/templates/sysadmin/settings.html
index ae914fef54..8a4f9dff7b 100644
--- a/seahub/templates/sysadmin/settings.html
+++ b/seahub/templates/sysadmin/settings.html
@@ -2,7 +2,6 @@
{% load seahub_tags i18n %}
{% block cur_settings %}tab-cur{% endblock %}
-
{% block right_panel %}
{% trans "Settings" %}
@@ -180,6 +179,14 @@
{% trans "If turn on, the desktop clients will not be able to sync a folder outside the default Seafile folder." as help_tip %}
{% include "snippets/web_settings_form.html" %}
{% endwith %}
+
+ {% trans "Terms" %}
+
+ {% with type="terms" setting_display_name="ENABLE_TERMS_AND_CONDITIONS" setting_name="ENABLE_TERMS_AND_CONDITIONS" setting_val=config_dict.ENABLE_TERMS_AND_CONDITIONS%}
+ {% trans "If turn on, enable system admin add T&C, all users need to accept terms before using." as help_tip %}
+ {% include "snippets/web_settings_form.html" %}
+ {% endwith %}
+
{% endblock %}
@@ -319,5 +326,17 @@ $('.web-setting-file-upload-input').on('change', function() {
error: ajaxErrorHandler
});
});
+
+$('.terms-checked').on('change', function() {
+ var checkbox = $(this),
+ key = checkbox.attr('name');
+
+ if (checkbox.prop('checked')) {
+ $('.tc').removeClass('hide');
+ } else {
+ $('.tc').addClass('hide');
+ }
+});
+
{% endblock %}
diff --git a/seahub/templates/termsandconditions/tc_view_terms.html b/seahub/templates/termsandconditions/tc_view_terms.html
new file mode 100644
index 0000000000..37717674f5
--- /dev/null
+++ b/seahub/templates/termsandconditions/tc_view_terms.html
@@ -0,0 +1,8 @@
+{% extends 'base_wide_page.html' %}
+
+{% block wide_page_content %}
+ {{ terms.name|safe }}
+
+ {{ terms.text|safe }}
+
+{% endblock %}
diff --git a/seahub/views/sysadmin.py b/seahub/views/sysadmin.py
index 96b57e2645..16041e735a 100644
--- a/seahub/views/sysadmin.py
+++ b/seahub/views/sysadmin.py
@@ -2075,7 +2075,7 @@ def sys_settings(request):
'ENABLE_USER_CREATE_ORG_REPO', 'FORCE_PASSWORD_CHANGE',
'LOGIN_ATTEMPT_LIMIT', 'FREEZE_USER_ON_LOGIN_FAILED',
'ENABLE_SHARE_TO_ALL_GROUPS', 'ENABLE_TWO_FACTOR_AUTH',
- 'ENABLE_BRANDING_CSS',
+ 'ENABLE_BRANDING_CSS', 'ENABLE_TERMS_AND_CONDITIONS',
]
STRING_WEB_SETTINGS = ('SERVICE_URL', 'FILE_SERVER_ROOT', 'TEXT_PREVIEW_EXT',
diff --git a/thirdpart/termsandconditions/middleware.py b/thirdpart/termsandconditions/middleware.py
index ae0d2033f4..eacdcbe448 100644
--- a/thirdpart/termsandconditions/middleware.py
+++ b/thirdpart/termsandconditions/middleware.py
@@ -3,6 +3,7 @@ from .models import TermsAndConditions
from django.conf import settings
import logging
from .pipeline import redirect_to_terms_accept
+from constance import config
LOGGER = logging.getLogger(name='termsandconditions')
@@ -19,7 +20,7 @@ class TermsAndConditionsRedirectMiddleware(object):
def process_request(self, request):
"""Process each request to app to ensure terms have been accepted"""
- if not settings.ENABLE_TERMS_AND_CONDITIONS:
+ if not config.ENABLE_TERMS_AND_CONDITIONS:
return None
LOGGER.debug('termsandconditions.middleware')
diff --git a/thirdpart/termsandconditions/urls.py b/thirdpart/termsandconditions/urls.py
index 95180b3f0e..e04ad2a8f0 100644
--- a/thirdpart/termsandconditions/urls.py
+++ b/thirdpart/termsandconditions/urls.py
@@ -11,7 +11,7 @@ from .models import DEFAULT_TERMS_SLUG
urlpatterns = (
# # View Default Terms
- # url(r'^$', TermsView.as_view(), {"slug": DEFAULT_TERMS_SLUG}, name="tc_view_page"),
+ url(r'^$', TermsView.as_view(), {"slug": DEFAULT_TERMS_SLUG}, name="tc_view_page"),
# # View Specific Active Terms
# url(r'^view/(?P[a-zA-Z0-9_.-]+)/$', TermsView.as_view(), name="tc_view_specific_page"),