-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TA#68599 [IMP] website_cookieconsent : code improvement
Adding new empty line
- Loading branch information
1 parent
9e653c9
commit 34fd1c6
Showing
10 changed files
with
210 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
from . import website | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,4 +95,4 @@ | |
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>." | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]); | ||
// } | ||
// } | ||
// }, | ||
|
||
}); |