Skip to content

Commit 45e9612

Browse files
authored
Merge pull request #583 from makinacorpus/add_orejime_manager
feat: Add orejime to manage cookies
2 parents bf05f72 + c5cdf3f commit 45e9612

File tree

18 files changed

+306
-29
lines changed

18 files changed

+306
-29
lines changed

atlas/atlasRoutes.py

+6
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,18 @@ def index():
207207
connection.close()
208208
session.close()
209209

210+
personal_data = False
211+
args_personal_data = request.args.get("personal_data")
212+
if args_personal_data and args_personal_data.lower() == "true":
213+
personal_data = True
214+
210215
return render_template(
211216
"templates/home/_main.html",
212217
observations=observations,
213218
mostViewTaxon=mostViewTaxon,
214219
customStatMedias=customStatMedias,
215220
lastDiscoveries=lastDiscoveries,
221+
personal_data=personal_data,
216222
)
217223

218224

atlas/configuration/config.py.example

+6-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ LANGUAGES = {
8484
#####################
8585
#####################
8686

87-
# Code de suivi des statistiques Google Analytics (si AFFICHAGE_FOOTER = True)
88-
ID_GOOGLE_ANALYTICS = "UA-xxxxxxx-xx"
89-
9087
# Utiliser et afficher le glossaire (static/custom/glossaire.json.sample)
9188
GLOSSAIRE = False
9289

@@ -261,6 +258,12 @@ PATRIMONIALITE = {
261258
}
262259
}
263260

261+
# liste des application dont "orejime" controle la dépose de cookie
262+
OREJIME_APPS = []
263+
264+
# traduction orejime (voir la doc cookie et RGPD pour comment le remplir)
265+
OREJIME_TRANSLATIONS = {}
266+
264267
#############################
265268
#### Lien custom du logo ####
266269
#############################

atlas/configuration/config_schema.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@
7777
},
7878
}
7979

80+
orijime_default_translations = {
81+
"fr": {
82+
"consentModal": {
83+
"description": "",
84+
},
85+
"purposes": {"analytics": "Analyse", "security": "Sécurité"},
86+
},
87+
"en": {
88+
"consentModal": {
89+
"description": "This is an example of how to override an existing translation already used by Orejime",
90+
},
91+
"purposes": {"analytics": "Analytics", "security": "Security"},
92+
},
93+
}
94+
8095

8196
class SecretSchemaConf(Schema):
8297
class Meta:
@@ -122,7 +137,6 @@ class Meta:
122137
URL_APPLICATION = fields.String(load_default="")
123138
DEFAULT_LANGUAGE = fields.String(load_default="fr")
124139
MULTILINGUAL = fields.Boolean(load_default=False)
125-
ID_GOOGLE_ANALYTICS = fields.String(load_default="UA-xxxxxxx-xx")
126140
ORGANISM_MODULE = fields.Boolean(load_default=False)
127141
DISPLAY_OBSERVERS = fields.Boolean(load_default=True)
128142
GLOSSAIRE = fields.Boolean(load_default=False)
@@ -131,6 +145,8 @@ class Meta:
131145
AFFICHAGE_LOGOS_HOME = fields.Boolean(load_default=True)
132146
AFFICHAGE_FOOTER = fields.Boolean(load_default=True)
133147
AFFICHAGE_RGPD = fields.Boolean(load_default=True)
148+
OREJIME_APPS = fields.List(fields.Dict(), load_default=[])
149+
OREJIME_TRANSLATIONS = fields.Dict(load_default=orijime_default_translations)
134150
AFFICHAGE_STAT_GLOBALES = fields.Boolean(load_default=True)
135151
AFFICHAGE_DERNIERES_OBS = fields.Boolean(load_default=True)
136152
AFFICHAGE_EN_CE_MOMENT = fields.Boolean(load_default=True)

atlas/static/custom/templates/footer.html.sample

+3-19
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
data-target="#modalCredits">{{ _('credits') }}</a> |
66
<a data-toggle="modal" href="#"
77
data-target="#modalMentions">{{ _('legal') }}</a>
8-
{% if configuration.AFFICHAGE_RGPD %}
8+
{% if configuration.AFFICHAGE_RGPD and configuration.OREJIME_APPS | length > 0 %}
99
|
1010
<a data-toggle="modal" href="#"
1111
data-target="#modalPersonalData">{{ _('personal_data') }}</a>
12+
| <a id="preferences-cookies" href="#" onclick="orejime.show()">{{ _('preferences_cookies') }}</a>
1213
{% endif %}
1314
</small>
1415

@@ -74,22 +75,5 @@
7475
</div>
7576
{% endif %}
7677

77-
{% if configuration.ID_GOOGLE_ANALYTICS != "UA-xxxxxxx-xx" %}
78-
<!-- Script Google Analytics -->
79-
<script>
80-
(function (i, s, o, g, r, a, m) {
81-
i['GoogleAnalyticsObject'] = r;
82-
i[r] = i[r] || function () {
83-
(i[r].q = i[r].q || []).push(arguments)
84-
}, i[r].l = 1 * new Date();
85-
a = s.createElement(o),
86-
m = s.getElementsByTagName(o)[0];
87-
a.async = 1;
88-
a.src = g;
89-
m.parentNode.insertBefore(a, m)
90-
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
78+
<!-- BLOC TRACEURS / ANALYSES VIZA COOKIES -->
9179

92-
ga('create', '{{configuration.ID_GOOGLE_ANALYTICS}}', 'auto');
93-
ga('send', 'pageview');
94-
</script>
95-
{% endif %}

atlas/static/main.js

+21
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,24 @@ if (configuration.GLOSSAIRE) {
139139
});
140140
});
141141
}
142+
143+
if (configuration.OREJIME_APPS.length > 0) {
144+
var orejimeConfig = {
145+
elementID: "orejime",
146+
appElement: "main",
147+
cookieName: "orejime",
148+
cookieExpiresAfterDays: 365,
149+
privacyPolicy: "/?personal_data=true",
150+
default: true,
151+
mustConsent: false,
152+
mustNotice: false,
153+
lang: configuration.DEFAULT_LANGUAGE,
154+
logo: false,
155+
debug: configuration.modeDebug,
156+
apps: configuration.OREJIME_APPS,
157+
categories: configuration.OREJIME_CATEGORIES
158+
}
159+
if (configuration.OREJIME_TRANSLATIONS && configuration.OREJIME_TRANSLATIONS != {}) {
160+
orejimeConfig.translations = configuration.OREJIME_TRANSLATIONS
161+
}
162+
}

atlas/static/package-lock.json

+82-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

atlas/static/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"leaflet.snogylop": "^0.4.0",
3434
"leaflet.zoomhome": "^1.0.0",
3535
"lightbox2": "^2.8.2",
36+
"orejime": "^2.3.0",
3637
"popper.js": "^1.16.0",
3738
"raphael": "^2.2.0",
3839
"slick": "^1.12.2",

atlas/templates/core/assets_header.html

+4
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@
3838
<link rel="SHORTCUT ICON" href="{{ url_for('static', filename='custom/images/favicon.ico') }}">
3939
<link rel="stylesheet" href="{{url_for('static', filename='css/atlas.css') }}" />
4040

41+
<!-- GDPR -->
42+
<script src="{{url_for('static', filename='node_modules/orejime/dist/orejime.js') }}"></script>
43+
<link rel="stylesheet" href="{{url_for('static', filename='node_modules/orejime/dist/orejime.css') }}" />
44+
4145
{% endblock %}

atlas/templates/home/_main.html

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
</script>
2929
<script src="{{ url_for('static', filename='index.js') }}"></script>
3030

31+
{% if personal_data %}
32+
<script>
33+
$("#modalPersonalData").modal('show');
34+
</script>
35+
{% endif %}
36+
3137
{% endblock %}
3238

3339

0 Bytes
Binary file not shown.

atlas/translations/en/LC_MESSAGES/messages.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: PROJECT VERSION\n"
99
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10-
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
10+
"POT-Creation-Date: 2024-11-27 10:43+0100\n"
1111
"PO-Revision-Date: 2021-07-12 12:12+0200\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language: en\n"
@@ -47,6 +47,10 @@ msgstr "Legal mentions"
4747
msgid "personal_data"
4848
msgstr "Personal data"
4949

50+
#: static/custom/templates/footer.html:12
51+
msgid "preferences_cookies"
52+
msgstr "Changing cookie preferences"
53+
5054
#: static/custom/templates/footer.html:17
5155
#: static/custom/templates/footer.html.sample:17
5256
msgid "atlas.fauna.flora"
74 Bytes
Binary file not shown.

atlas/translations/fr/LC_MESSAGES/messages.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: PROJECT VERSION\n"
99
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10-
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
10+
"POT-Creation-Date: 2024-11-27 10:38+0100\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language: fr\n"
@@ -47,7 +47,11 @@ msgstr "Mentions légales"
4747
msgid "personal_data"
4848
msgstr "Données personnelles"
4949

50-
#: static/custom/templates/footer.html:17
50+
#: static/custom/templates/footer.html:12
51+
msgid "preferences_cookies"
52+
msgstr "Modifier les préférences de cookies"
53+
54+
#: static/custom/templates/footer.html:18
5155
#: static/custom/templates/footer.html.sample:17
5256
msgid "atlas.fauna.flora"
5357
msgstr "Atlas de la faune et de la flore"
0 Bytes
Binary file not shown.

atlas/translations/it/LC_MESSAGES/messages.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: PROJECT VERSION\n"
99
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10-
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
10+
"POT-Creation-Date: 2024-11-27 10:43+0100\n"
1111
"PO-Revision-Date: 2021-07-19 09:53+0200\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language: it\n"
@@ -47,6 +47,10 @@ msgstr "Nota legale"
4747
msgid "personal_data"
4848
msgstr "Dati personali"
4949

50+
#: atlas/static/custom/templates/footer.html:12
51+
msgid "preferences_cookies"
52+
msgstr ""
53+
5054
#: static/custom/templates/footer.html:17
5155
#: static/custom/templates/footer.html.sample:17
5256
msgid "atlas.fauna.flora"

docs/changelog.rst

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
🚀 **Nouveautés**
99

1010
- Ajout du lien "Données personelles" dans le pied de page (#527 @juggler31)
11+
- Ajout de la librairie Orijeme pour recueillir le consentement de l'utilisateur sur l'utilisation des cookies
1112
- Suppression du support des installations sans TaxHub
1213

1314
🐛 **Corrections**
@@ -26,6 +27,8 @@ CHANGELOG
2627

2728
⚠️ **Notes de version**
2829

30+
- Le paramètre `ID_GOOGLE_ANALYTICS` et la façon d'integrer un script google analytic sont dépréciés. Se référer à la documentation sur le RGPD et la collecte de cookies : https://github.com/PnX-SI/GeoNature-atlas/blob/master/docs/cookies_rgpd.rst
31+
2932
Si vous mettez à jour GeoNature-atlas :
3033

3134
- Ajouter l'extension unaccent à la base de données `CREATE EXTENSION IF NOT EXISTS unaccent SCHEMA "public";` (#531, #532)

0 commit comments

Comments
 (0)