Skip to content

Commit

Permalink
TA#68599 [IMP] website_cookieconsent : code improvement
Browse files Browse the repository at this point in the history
Adding new empty line
  • Loading branch information
lanto-razafindrabe committed Sep 6, 2024
1 parent 9e653c9 commit 34fd1c6
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 66 deletions.
27 changes: 16 additions & 11 deletions website_cookieconsent/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
===================
=====================
Website CookieConsent
===================
=====================

This module integrates Odoo website with [Orestbida's CookieConsent plugin](https://github.com/orestbida/cookieconsent).

Expand All @@ -15,9 +15,9 @@ Configuration
To configure this module, you need to:

# . Go to **Website > Configuration > Settings**
# . Search 'CookieConsent' option.
# . Toggle 'Use CookieConsent'.
# . Click on "Save" button.
# . Search `CookieConsent` option.
# . Toggle `Use CookieConsent`.
# . Click on `Save` button.

.. image:: static/description/cookieconsent.png

Expand All @@ -26,17 +26,22 @@ To configure this module, you need to:
Notes
=====

The files inside '/static/src/js', '/static/src/css' and '/static/src/i18n' are the default configuration, stylesheets
The files inside `/static/src/js`, `/static/src/css` and `/static/src/i18n` are the default configuration, stylesheets
and locales used by CookieConsent.

The [upstream maintainer](https://github.com/orestbida/cookieconsent) offers a [playground](https://playground.cookieconsent.orestbida.com/)
to test the extent of the customization.

Credits
=======
Notice
======

Authors
For the version 1.0.0, the configuration is only for the default native website.

~~~~~~~
Contributors
============

* Numigi
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)

More information
================
* Meet us at https://bit.ly/numigi-com
1 change: 1 addition & 0 deletions website_cookieconsent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models

Check notice on line 4 in website_cookieconsent/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

website_cookieconsent/__init__.py#L4

'.models' imported but unused (F401)
4 changes: 3 additions & 1 deletion website_cookieconsent/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"name": "Website CookieConsent",
"summary": "CookieConsent integration",
"category": "Website",
"version": "14.0.1.1.0",
"version": "14.0.1.0.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
"license": "AGPL-3",
"depends": ["website"],
"data": [
Expand Down
48 changes: 44 additions & 4 deletions website_cookieconsent/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,56 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-04 00:38+0000\n"
"PO-Revision-Date: 2024-09-04 00:38+0000\n"
"POT-Creation-Date: 2024-09-06 02:52+0000\n"
"PO-Revision-Date: 2024-09-06 02:52+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: website_cookieconsent
#: model:ir.model,name:website_cookieconsent.model_res_config_settings
msgid "Config Settings"
msgstr "Paramètres"

#. module: website_cookieconsent
#: model:ir.model.fields,field_description:website_cookieconsent.field_res_config_settings__display_name
#: model:ir.model.fields,field_description:website_cookieconsent.field_website__display_name
msgid "Display Name"
msgstr "Nom affiché"

#. module: website_cookieconsent
#: model_terms:ir.ui.view,arch_db:website_cookieconsent.res_config_settings_view_form
msgid "Add CookieConsent functionality"
msgstr "Ajouter la fonction CookieConsent"
msgid "Display a cookie banner on your website"
msgstr "Afficher une bannière de cookies sur votre site web"

#. module: website_cookieconsent
#: model:ir.model.fields,help:website_cookieconsent.field_res_config_settings__website_cookieconsent_enabled
#: model:ir.model.fields,help:website_cookieconsent.field_website__cookieconsent_enabled
msgid "Display a cookie banner on your website."
msgstr "Afficher une bannière de cookies sur votre site web."

#. module: website_cookieconsent
#: model:ir.model.fields,field_description:website_cookieconsent.field_res_config_settings__id
#: model:ir.model.fields,field_description:website_cookieconsent.field_website__id
msgid "ID"
msgstr ""

#. module: website_cookieconsent
#: model:ir.model.fields,field_description:website_cookieconsent.field_res_config_settings____last_update
#: model:ir.model.fields,field_description:website_cookieconsent.field_website____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

#. module: website_cookieconsent
#: model:ir.model.fields,field_description:website_cookieconsent.field_res_config_settings__website_cookieconsent_enabled
#: model:ir.model.fields,field_description:website_cookieconsent.field_website__cookieconsent_enabled
msgid "Use CookieConsent"
msgstr "Utiliser CookieConsent"

#. module: website_cookieconsent
#: model:ir.model,name:website_cookieconsent.model_website
msgid "Website"
msgstr "Site web"
3 changes: 3 additions & 0 deletions website_cookieconsent/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import res_config_settings

Check notice on line 4 in website_cookieconsent/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

website_cookieconsent/models/__init__.py#L4

'.res_config_settings' imported but unused (F401)
from . import website

Check notice on line 5 in website_cookieconsent/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

website_cookieconsent/models/__init__.py#L5

'.website' imported but unused (F401)
18 changes: 6 additions & 12 deletions website_cookieconsent/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
from odoo import api, fields, models
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
from odoo import fields, models

@api.depends("website_id.cookieconsent_enabled")
def _compute_cookieconsent_enabled(self):
for record in self:
record.update({"cookieconsent_enabled": True})

def _inverse_cookieconsent_enabled(self):
for record in self:
record.website_id.update({"cookieconsent_enabled": False})
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

website_cookieconsent_enabled = fields.Boolean(
related="website_id.cookieconsent_enabled",
string="Use CookieConsent",
compute="_compute_cookieconsent_enabled",
inverse="_inverse_cookieconsent_enabled",
readonly=False,
)
7 changes: 5 additions & 2 deletions website_cookieconsent/models/website.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class Website(models.Model):
_inherit = "website"

cookieconsent_enabled = fields.Boolean(
string="Use CookieConsent",
help="Display a cookie banner on your website."
string="Use CookieConsent", help="Display a cookie banner on your website."
)
2 changes: 1 addition & 1 deletion website_cookieconsent/static/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@
}
]
}
}
}
98 changes: 98 additions & 0 deletions website_cookieconsent/static/src/i18n/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"consentModal": {
"title": "Avant de continuer",
"description": "Notre site utilise des cookies essentiels pour améliorer votre expérience de navigation, vous garder connecté et des cookies de suivi pour comprendre comment vous interagissez avec lui.",
"acceptAllBtn": "Tout accepter",
"acceptNecessaryBtn": "Tout rejeter",
"showPreferencesBtn": "Gérer les préférences"
},
"preferencesModal": {
"title": "Centre de consentement aux cookies",
"acceptAllBtn": "Tout accepter",
"acceptNecessaryBtn": "Tout rejeter",
"savePreferencesBtn": "Enregistrer les préférences",
"closeIconLabel": "Fermer",
"sections": [
{
"title": "Utilisation des cookies",
"description": "Nous utilisons des cookies pour assurer les fonctionnalités de base de notre site et améliorer votre expérience en ligne. Vous pouvez choisir pour chaque catégorie de vous inscrire ou de vous désinscrire à tout moment. Vos préférences en matière de cookies peuvent être gérées en visitant notre politique de cookies."
},
{
"title": "Cookies strictement nécessaires",
"description": "Fournir et maintenir des services, comme suivre les pannes ou vous garder connecté.",
"linkedCategory": "nécessaire",
"cookieTable": {
"headers": {
"name": "Nom",
"domain": "Service",
"description": "Description",
"expiration": "Expiration"
},
"body": [
{
"name": "session_id",
"domain": "Site Web",
"description": "Cookie défini par le site actuel.",
"expiration": "90 jours"
},
{
"name": "tz",
"domain": "Site Web",
"description": "Détecte le fuseau horaire de votre navigateur.",
"expiration": "N/A"
},
{
"name": "frontend_lang",
"domain": "Site Web",
"description": "Détecte la langue de votre navigateur.",
"expiration": "N/A"
},
{
"name": "cc_cookie",
"domain": "Site Web",
"description": "Stocke votre consentement aux cookies.",
"expiration": "N/A"
}
]
}
},
{
"title": "Cookies d'analyse",
"description": "Ces cookies permettent au site de se souvenir des choix que vous avez faits dans le passé.",
"linkedCategory": "analyse",
"cookieTable": {
"headers": {
"name": "Nom",
"domain": "Service",
"description": "Description",
"expiration": "Expiration"
},
"body": [
{
"name": "_pk_id",
"domain": "Analyse",
"description": "Cookie défini par <a href=\"#das\">Analytics</a>.",
"expiration": "13 mois"
},
{
"name": "_pk_ses",
"domain": "Analyse",
"description": "Cookie défini par <a href=\"#das\">Analytics</a>.",
"expiration": "30 minutes"
},
{
"name": "foo",
"domain": "Salutations",
"description": "Cookie défini par <a href=\"#das\">Greetings</a>.",
"expiration": "N/A"
}
]
}
},
{
"title": "Plus d'informations",
"description": "Pour toute question concernant notre politique sur les cookies et vos choix, veuillez <a class=\"cc-link\" href=\"#yourdomain.com\">nous contacter</a>."
}
]
}
}
68 changes: 33 additions & 35 deletions website_cookieconsent/static/src/js/config.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
import "https://cdn.jsdelivr.net/gh/orestbida/[email protected]/dist/cookieconsent.umd.js";

CookieConsent.run({
disablePageInteraction: false,
guiOptions: {
consentModal: {
layout: "box",
position: "bottom left",
},
},
disablePageInteraction: false,

categories: {
necessary: {
enabled: true, // this category is enabled by default
readOnly: true, // this category cannot be disabled
},
analytics: {},
ads: {},
},
guiOptions: {
consentModal: {
layout: "box",
position: "bottom left",
},
},

categories: {
necessary: {
enabled: true, // this category is enabled by default
readOnly: true, // this category cannot be disabled
},
analytics: {},
ads: {},
},

language: {
default: "en",
translations: {
en: async () => {
const res = await fetch(
"/website_cookieconsent/static/src/i18n/en.json"
);
return await res.json();
language: {
default: "en",
translations: {
en: async () => {
const res = await fetch(
"/website_cookieconsent/static/src/i18n/en.json"
);
return await res.json();
},
fr: async () => {
const res = await fetch(
"/website_cookieconsent/static/src/i18n/fr.json"
);
return await res.json();
},
},
},
},
},
// Used for Matomo
// onChange: ({ changedCategories }) => {
// if (changedCategories.includes("analytics")) {
// if (!CookieConsent.acceptedCategory("analytics")) {
// _paq.push(["forgetConsentGiven"]);
// } else {
// _paq.push(["setConsentGiven"]);
// }
// }
// },

});

0 comments on commit 34fd1c6

Please sign in to comment.