Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit f7944041 authored by Robin Tissot's avatar Robin Tissot

Adds cookie consent message.

parent 84de97b6
from django.conf import settings
def enable_cookie_consent(request):
return {'ENABLE_COOKIE_CONSENT': getattr(settings,
'ENABLE_COOKIE_CONSENT',
True)}
......@@ -95,6 +95,7 @@ TEMPLATES = [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'escriptorium.context_processors.enable_cookie_consent'
],
},
},
......@@ -302,6 +303,9 @@ THUMBNAIL_ALIASES = {
# 'jpeg': '/usr/bin/jpegoptim -S200 {filename}'
# }
ENABLE_COOKIE_CONSENT = os.getenv('ENABLE_COOKIE_CONSENT', True)
VERSIONING_DEFAULT_SOURCE = 'eScriptorium'
VERSION_DATE = os.getenv('VERSION_DATE', '<development>')
......
......@@ -97,7 +97,7 @@
{% block scripts %}
<script src="{% static 'main.js' %}" type="text/javascript"></script>
<script type="text/javascript">
const DEBUG = {% if debug %}true{% else %}false{% endif %};
const DEBUG = {% if debug %}true{% else %}false{% endif %};
</script>
{% if user.is_authenticated %} {# no need to open a socket for anonymous users, bots etc #}
<script type="text/javascript">
......@@ -108,7 +108,12 @@
{% include 'includes/messages.html' %}
{% if user.onboarding %}
<script type="text/javascript">
bootOnboarding();
bootOnboarding();
</script>
{% endif %}
{% if ENABLE_COOKIE_CONSENT %}
<script type="text/javascript">
userProfile.getCookieConsent();
</script>
{% endif %}
{% endif %}
......
......@@ -14,10 +14,12 @@ export class Alert {
if (this.links !== undefined) {
for (let i=0; i<this.links.length; i++) {
let link = $('<div>').html('<a href="'+this.links[i].src+'" >'+this.links[i].text+'</a>');
if (this.links[i].cssClass) $('a', link).addClass(this.links[i].cssClass);
$('.additional', $new).append(link).css('display', 'block');
}
}
this.$element = $new;
this.htmlElement = this.$element.get(0);
$('#alerts-container').append($new);
$new.show();
......@@ -33,6 +35,7 @@ export class Alert {
} else {
alerts[id_].incrementCounter();
}
return alerts[id_];
}
incrementCounter() {
......
......@@ -22,6 +22,20 @@ class Profile {
get(key) {
return this.settings[key];
}
getCookieConsent() {
// get cookie consent.
if (!this.get('cookie-consent')) {
let alert = Alert.add('cookie-consent',
"eScriptorium uses cookies to store the user session and local storage to save user interface preferences.",
"warning",
[{src: '', text:'Accept', cssClass: 'btn btn-outline-dark btn-sm mt-2'}]);
alert.htmlElement.querySelector('.additional a').addEventListener('click', function(ev) {
this.set('cookie-consent', true);
return false;
}.bind(this));
}
}
}
export var userProfile = new Profile();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment