mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 23:29:49 +00:00
Add terms to web settings
This commit is contained in:
@@ -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)
|
||||
|
@@ -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,
|
||||
}
|
||||
|
@@ -795,4 +795,6 @@ CONSTANCE_CONFIG = {
|
||||
|
||||
'ENABLE_BRANDING_CSS': (ENABLE_BRANDING_CSS, ''),
|
||||
'CUSTOM_CSS': ('', ''),
|
||||
|
||||
'ENABLE_TERMS_AND_CONDITIONS': (ENABLE_TERMS_AND_CONDITIONS, ''),
|
||||
}
|
||||
|
@@ -1,6 +1,9 @@
|
||||
{% load i18n %}
|
||||
<a href="{{SITE_ROOT}}help/" target="_blank" class="item">{% trans "Help" %}</a>
|
||||
<a href="#" class="js-about item">{% trans "About" %}</a>
|
||||
{% if enable_terms_and_conditions %}
|
||||
<a href="{{SITE_ROOT}}terms/" class="item">{% trans "Terms" %}</a>
|
||||
{% endif %}
|
||||
<a href="{% url 'download_client' %}" class="item last-item"><span aria-hidden="true" class="sf2-icon-monitor vam"></span> <span class="vam">{% trans "Clients" %}</span></a>
|
||||
|
||||
<div class="about-content hide">
|
||||
|
@@ -72,3 +72,16 @@
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if type == 'terms' %}
|
||||
<form class="web-setting-form web-checkbox-setting-form" action="">{% csrf_token %}
|
||||
<h5 class="web-setting-name">{{ setting_display_name }}</h5>
|
||||
<div class="web-setting-input">
|
||||
<label class="checkbox-label">
|
||||
<input class="web-setting-checkbox vam terms-checked" type="checkbox" name="{{ setting_name }}"{% if setting_val %} checked="checked"{% endif %} />
|
||||
<span class="vam">{{ help_tip }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
|
@@ -106,8 +106,8 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if enable_terms_and_conditions and is_default_admin %}
|
||||
<li class="tab {% block cur_tc %}{% endblock %}">
|
||||
{% if is_default_admin %}
|
||||
<li class="tab tc {% if not enable_terms_and_conditions %} hide {% endif %} {% block cur_tc %}{% endblock %}">
|
||||
<a href="{{ SITE_ROOT }}sys/termsadmin/"><span class="sf2-icon-wiki"></span>{% trans "Terms and Conditions" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
{% load seahub_tags i18n %}
|
||||
|
||||
{% block cur_settings %}tab-cur{% endblock %}
|
||||
|
||||
{% block right_panel %}
|
||||
<h3 class="hd">{% trans "Settings" %}</h3>
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
<h4>{% trans "Terms" %}</h4>
|
||||
|
||||
{% 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 %}
|
||||
|
||||
</div>
|
||||
{% 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');
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
8
seahub/templates/termsandconditions/tc_view_terms.html
Normal file
8
seahub/templates/termsandconditions/tc_view_terms.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends 'base_wide_page.html' %}
|
||||
|
||||
{% block wide_page_content %}
|
||||
<h1>{{ terms.name|safe }}</h1>
|
||||
<div id="tc-content" class="article">
|
||||
{{ terms.text|safe }}
|
||||
</div>
|
||||
{% endblock %}
|
@@ -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',
|
||||
|
@@ -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')
|
||||
|
@@ -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<slug>[a-zA-Z0-9_.-]+)/$', TermsView.as_view(), name="tc_view_specific_page"),
|
||||
|
Reference in New Issue
Block a user