Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add orejime to manage cookies #583

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions atlas/atlasRoutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,18 @@ def index():
connection.close()
session.close()

personal_data = False
args_personal_data = request.args.get("personal_data")
if args_personal_data and args_personal_data.lower() == "true":
personal_data = True

return render_template(
"templates/home/_main.html",
observations=observations,
mostViewTaxon=mostViewTaxon,
customStatMedias=customStatMedias,
lastDiscoveries=lastDiscoveries,
personal_data=personal_data,
)


Expand Down
9 changes: 6 additions & 3 deletions atlas/configuration/config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ LANGUAGES = {
#####################
#####################

# Code de suivi des statistiques Google Analytics (si AFFICHAGE_FOOTER = True)
ID_GOOGLE_ANALYTICS = "UA-xxxxxxx-xx"

# Utiliser et afficher le glossaire (static/custom/glossaire.json.sample)
GLOSSAIRE = False

Expand Down Expand Up @@ -261,6 +258,12 @@ PATRIMONIALITE = {
}
}

# liste des application dont "orejime" controle la dépose de cookie
OREJIME_APPS = []

# traduction orejime (voir la doc cookie et RGPD pour comment le remplir)
OREJIME_TRANSLATIONS = {}

#############################
#### Lien custom du logo ####
#############################
Expand Down
18 changes: 17 additions & 1 deletion atlas/configuration/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@
},
}

orijime_default_translations = {
"fr": {
"consentModal": {
"description": "",
},
"purposes": {"analytics": "Analyse", "security": "Sécurité"},
},
"en": {
"consentModal": {
"description": "This is an example of how to override an existing translation already used by Orejime",
},
"purposes": {"analytics": "Analytics", "security": "Security"},
},
}


class SecretSchemaConf(Schema):
class Meta:
Expand Down Expand Up @@ -122,7 +137,6 @@ class Meta:
URL_APPLICATION = fields.String(load_default="")
DEFAULT_LANGUAGE = fields.String(load_default="fr")
MULTILINGUAL = fields.Boolean(load_default=False)
ID_GOOGLE_ANALYTICS = fields.String(load_default="UA-xxxxxxx-xx")
ORGANISM_MODULE = fields.Boolean(load_default=False)
DISPLAY_OBSERVERS = fields.Boolean(load_default=True)
GLOSSAIRE = fields.Boolean(load_default=False)
Expand All @@ -131,6 +145,8 @@ class Meta:
AFFICHAGE_LOGOS_HOME = fields.Boolean(load_default=True)
AFFICHAGE_FOOTER = fields.Boolean(load_default=True)
AFFICHAGE_RGPD = fields.Boolean(load_default=True)
OREJIME_APPS = fields.List(fields.Dict(), load_default=[])
OREJIME_TRANSLATIONS = fields.Dict(load_default=orijime_default_translations)
AFFICHAGE_STAT_GLOBALES = fields.Boolean(load_default=True)
AFFICHAGE_DERNIERES_OBS = fields.Boolean(load_default=True)
AFFICHAGE_EN_CE_MOMENT = fields.Boolean(load_default=True)
Expand Down
22 changes: 3 additions & 19 deletions atlas/static/custom/templates/footer.html.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
data-target="#modalCredits">{{ _('credits') }}</a> |
<a data-toggle="modal" href="#"
data-target="#modalMentions">{{ _('legal') }}</a>
{% if configuration.AFFICHAGE_RGPD %}
{% if configuration.AFFICHAGE_RGPD and configuration.OREJIME_APPS | length > 0 %}
|
<a data-toggle="modal" href="#"
data-target="#modalPersonalData">{{ _('personal_data') }}</a>
| <a id="preferences-cookies" href="#" onclick="orejime.show()">{{ _('preferences_cookies') }}</a>
{% endif %}
</small>

Expand Down Expand Up @@ -74,22 +75,5 @@
</div>
{% endif %}

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

ga('create', '{{configuration.ID_GOOGLE_ANALYTICS}}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
21 changes: 21 additions & 0 deletions atlas/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,24 @@ if (configuration.GLOSSAIRE) {
});
});
}

if (configuration.OREJIME_APPS.length > 0) {
var orejimeConfig = {
elementID: "orejime",
appElement: "main",
cookieName: "orejime",
cookieExpiresAfterDays: 365,
privacyPolicy: "/?personal_data=true",
default: true,
mustConsent: false,
mustNotice: false,
lang: configuration.DEFAULT_LANGUAGE,
logo: false,
debug: configuration.modeDebug,
apps: configuration.OREJIME_APPS,
categories: configuration.OREJIME_CATEGORIES
}
if (configuration.OREJIME_TRANSLATIONS && configuration.OREJIME_TRANSLATIONS != {}) {
orejimeConfig.translations = configuration.OREJIME_TRANSLATIONS
}
}
84 changes: 82 additions & 2 deletions atlas/static/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions atlas/static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"leaflet.snogylop": "^0.4.0",
"leaflet.zoomhome": "^1.0.0",
"lightbox2": "^2.8.2",
"orejime": "^2.3.0",
"popper.js": "^1.16.0",
"raphael": "^2.2.0",
"slick": "^1.12.2",
Expand Down
4 changes: 4 additions & 0 deletions atlas/templates/core/assets_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@
<link rel="SHORTCUT ICON" href="{{ url_for('static', filename='custom/images/favicon.ico') }}">
<link rel="stylesheet" href="{{url_for('static', filename='css/atlas.css') }}" />

<!-- GDPR -->
<script src="{{url_for('static', filename='node_modules/orejime/dist/orejime.js') }}"></script>
<link rel="stylesheet" href="{{url_for('static', filename='node_modules/orejime/dist/orejime.css') }}" />

{% endblock %}
6 changes: 6 additions & 0 deletions atlas/templates/home/_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
</script>
<script src="{{ url_for('static', filename='index.js') }}"></script>

{% if personal_data %}
<script>
$("#modalPersonalData").modal('show');
</script>
{% endif %}

{% endblock %}


Expand Down
Binary file modified atlas/translations/en/LC_MESSAGES/messages.mo
Binary file not shown.
6 changes: 5 additions & 1 deletion atlas/translations/en/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
"POT-Creation-Date: 2024-11-27 10:43+0100\n"
"PO-Revision-Date: 2021-07-12 12:12+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
Expand Down Expand Up @@ -47,6 +47,10 @@ msgstr "Legal mentions"
msgid "personal_data"
msgstr "Personal data"

#: static/custom/templates/footer.html:12
msgid "preferences_cookies"
msgstr "Changing cookie preferences"

#: static/custom/templates/footer.html:17
#: static/custom/templates/footer.html.sample:17
msgid "atlas.fauna.flora"
Expand Down
Binary file modified atlas/translations/fr/LC_MESSAGES/messages.mo
Binary file not shown.
8 changes: 6 additions & 2 deletions atlas/translations/fr/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
"POT-Creation-Date: 2024-11-27 10:38+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr\n"
Expand Down Expand Up @@ -47,7 +47,11 @@ msgstr "Mentions légales"
msgid "personal_data"
msgstr "Données personnelles"

#: static/custom/templates/footer.html:17
#: static/custom/templates/footer.html:12
msgid "preferences_cookies"
msgstr "Modifier les préférences de cookies"

#: static/custom/templates/footer.html:18
#: static/custom/templates/footer.html.sample:17
msgid "atlas.fauna.flora"
msgstr "Atlas de la faune et de la flore"
Expand Down
Binary file modified atlas/translations/it/LC_MESSAGES/messages.mo
Binary file not shown.
6 changes: 5 additions & 1 deletion atlas/translations/it/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-27 10:32+0200\n"
"POT-Creation-Date: 2024-11-27 10:43+0100\n"
"PO-Revision-Date: 2021-07-19 09:53+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: it\n"
Expand Down Expand Up @@ -47,6 +47,10 @@ msgstr "Nota legale"
msgid "personal_data"
msgstr "Dati personali"

#: atlas/static/custom/templates/footer.html:12
msgid "preferences_cookies"
msgstr ""

#: static/custom/templates/footer.html:17
#: static/custom/templates/footer.html.sample:17
msgid "atlas.fauna.flora"
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
🚀 **Nouveautés**

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

🐛 **Corrections**
Expand All @@ -26,6 +27,8 @@ CHANGELOG

⚠️ **Notes de version**

- 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

Si vous mettez à jour GeoNature-atlas :

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