Add improvements to the TOS links and make them optional

This commit is contained in:
Kevin Chung
2020-09-07 15:20:06 -04:00
parent 58056e83e9
commit f172f9de28
5 changed files with 25 additions and 5 deletions

View File

@@ -1,5 +1,7 @@
import json
from flask import url_for
from CTFd.constants import JinjaEnum, RawEnum
from CTFd.utils import get_config
@@ -63,5 +65,19 @@ class _ConfigsWrapper:
def theme_settings(self):
return json.loads(get_config("theme_settings", default="null"))
@property
def tos_or_privacy(self):
tos = bool(get_config("tos_url") or get_config("tos_text"))
privacy = bool(get_config("privacy_url") or get_config("privacy_text"))
return tos or privacy
@property
def tos_link(self):
return get_config("tos_url", default=url_for("views.tos"))
@property
def privacy_link(self):
return get_config("privacy_url", default=url_for("views.privacy"))
Configs = _ConfigsWrapper()

View File

@@ -268,7 +268,9 @@ $(() => {
theme_settings_editor.refresh();
});
$("a[href='#legal']").on("shown.bs.tab", function(_e) {
$(
"a[href='#legal'], a[href='#tos-config'], a[href='#privacy-policy-config']"
).on("shown.bs.tab", function(_e) {
$("#tos-config .CodeMirror").each(function(i, el) {
el.CodeMirror.refresh();
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -56,15 +56,17 @@
</div>
</div>
{% if Configs.tos_or_privacy %}
<div class="row pt-3">
<div class="col-md-12 text-center">
<small class="text-muted text-center">
By registering, you agree to the
<a href="{{ url_for('views.privacy') }}" target="_blank">privacy policy</a>
and <a href="{{ url_for('views.tos') }}" target="_blank">terms of service</a>
<a href="{{ Configs.privacy_link }}" rel="noopener" target="_blank">privacy policy</a>
and <a href="{{ Configs.tos_link }}" rel="noopener" target="_blank">terms of service</a>
</small>
</div>
</div>
{% endif %}
</form>
{% endwith %}
</div>