django-cookie-consent 0.6.0__tar.gz → 0.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_cookie_consent-0.6.0/django_cookie_consent.egg-info → django_cookie_consent-0.8.0}/PKG-INFO +6 -3
- django_cookie_consent-0.8.0/cookie_consent/__init__.py +1 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/static/cookie_consent/cookiebar.module.js +9 -16
- django_cookie_consent-0.8.0/cookie_consent/static/cookie_consent/cookiebar.module.js.map +7 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0/django_cookie_consent.egg-info}/PKG-INFO +6 -3
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/pyproject.toml +7 -10
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_javascript_cookiebar.py +1 -0
- django_cookie_consent-0.6.0/cookie_consent/__init__.py +0 -1
- django_cookie_consent-0.6.0/cookie_consent/static/cookie_consent/cookiebar.module.js.map +0 -7
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/AUTHORS +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/LICENSE +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/MANIFEST.in +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/README.md +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/admin.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/apps.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/cache.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/conf.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/fixtures/common_cookies.json +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/middleware.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/migrations/0001_initial.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/migrations/0002_auto__add_logitem.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/migrations/0003_alter_cookiegroup_varname.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/migrations/0004_cookie_natural_key.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/migrations/__init__.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/models.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/static/cookie_consent/cookiebar.js +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/templates/cookie_consent/_cookie_group.html +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/templates/cookie_consent/base.html +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/templates/cookie_consent/cookiegroup_list.html +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/templatetags/__init__.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/templatetags/cookie_consent_tags.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/urls.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/util.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/views.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/django_cookie_consent.egg-info/SOURCES.txt +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/django_cookie_consent.egg-info/dependency_links.txt +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/django_cookie_consent.egg-info/requires.txt +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/django_cookie_consent.egg-info/top_level.txt +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/setup.cfg +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_cache.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_cookie_group_model.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_cookie_model.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_legacy_javascript_cookiebar.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_middleware.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_models.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_settings.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_templatetags.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_util.py +0 -0
- {django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_views.py +0 -0
{django_cookie_consent-0.6.0/django_cookie_consent.egg-info → django_cookie_consent-0.8.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: django-cookie-consent
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Django cookie consent application
|
|
5
5
|
Author-email: Informatika Mihelac <bmihelac@mihelac.org>
|
|
6
6
|
License: Copyright (c) Bojan Mihelac and individual contributors.
|
|
@@ -35,7 +35,8 @@ Keywords: cookies,cookie-consent,cookie bar
|
|
|
35
35
|
Classifier: Development Status :: 4 - Beta
|
|
36
36
|
Classifier: Framework :: Django
|
|
37
37
|
Classifier: Framework :: Django :: 4.2
|
|
38
|
-
Classifier: Framework :: Django :: 5.
|
|
38
|
+
Classifier: Framework :: Django :: 5.1
|
|
39
|
+
Classifier: Framework :: Django :: 5.2
|
|
39
40
|
Classifier: Intended Audience :: Developers
|
|
40
41
|
Classifier: License :: OSI Approved :: BSD License
|
|
41
42
|
Classifier: Operating System :: Unix
|
|
@@ -47,6 +48,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
47
48
|
Classifier: Programming Language :: Python :: 3.10
|
|
48
49
|
Classifier: Programming Language :: Python :: 3.11
|
|
49
50
|
Classifier: Programming Language :: Python :: 3.12
|
|
51
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
50
52
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
51
53
|
Requires-Python: >=3.8
|
|
52
54
|
Description-Content-Type: text/markdown
|
|
@@ -69,6 +71,7 @@ Requires-Dist: sphinx; extra == "docs"
|
|
|
69
71
|
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
70
72
|
Provides-Extra: release
|
|
71
73
|
Requires-Dist: tbump; extra == "release"
|
|
74
|
+
Dynamic: license-file
|
|
72
75
|
|
|
73
76
|
Django cookie consent
|
|
74
77
|
=====================
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.8.0"
|
|
@@ -50,8 +50,7 @@ var loadCookieGroups = (selector) => {
|
|
|
50
50
|
};
|
|
51
51
|
var doInsertBefore = (beforeNode, newNode) => {
|
|
52
52
|
const parent = beforeNode.parentNode;
|
|
53
|
-
if (parent === null)
|
|
54
|
-
throw new Error("Reference node doesn't have a parent.");
|
|
53
|
+
if (parent === null) throw new Error("Reference node doesn't have a parent.");
|
|
55
54
|
parent.insertBefore(newNode, beforeNode);
|
|
56
55
|
};
|
|
57
56
|
var registerEvents = ({
|
|
@@ -108,20 +107,17 @@ var showCookieBar = async (options = {}) => {
|
|
|
108
107
|
// Django's default, can be overridden with settings.CSRF_HEADER_NAME
|
|
109
108
|
} = options;
|
|
110
109
|
const cookieGroups = loadCookieGroups(cookieGroupsSelector);
|
|
111
|
-
if (!cookieGroups.length)
|
|
112
|
-
return;
|
|
110
|
+
if (!cookieGroups.length) return;
|
|
113
111
|
const templateNode = document.querySelector(templateSelector);
|
|
114
112
|
if (!templateNode) {
|
|
115
113
|
throw new Error(`No (template) element found for selector '${templateSelector}'.`);
|
|
116
114
|
}
|
|
117
115
|
const doInsert = insertBefore === null ? (cookieBarNode2) => document.querySelector("body").appendChild(cookieBarNode2) : typeof insertBefore === "string" ? (cookieBarNode2) => {
|
|
118
116
|
const referenceNode = document.querySelector(insertBefore);
|
|
119
|
-
if (referenceNode === null)
|
|
120
|
-
throw new Error(`No element found for selector '${insertBefore}'.`);
|
|
117
|
+
if (referenceNode === null) throw new Error(`No element found for selector '${insertBefore}'.`);
|
|
121
118
|
doInsertBefore(referenceNode, cookieBarNode2);
|
|
122
119
|
} : (cookieBarNode2) => doInsertBefore(insertBefore, cookieBarNode2);
|
|
123
|
-
if (!statusUrl)
|
|
124
|
-
throw new Error("Missing status URL option, did you forget to pass the `statusUrl` option?");
|
|
120
|
+
if (!statusUrl) throw new Error("Missing status URL option, did you forget to pass the `statusUrl` option?");
|
|
125
121
|
const client = new FetchClient(statusUrl, csrfHeaderName);
|
|
126
122
|
const cookieStatus = await client.getCookieStatus();
|
|
127
123
|
const {
|
|
@@ -130,16 +126,12 @@ var showCookieBar = async (options = {}) => {
|
|
|
130
126
|
notAcceptedOrDeclinedCookieGroups
|
|
131
127
|
} = cookieStatus;
|
|
132
128
|
const acceptedGroups = filterCookieGroups(cookieGroups, acceptedCookieGroups);
|
|
133
|
-
if (acceptedGroups.length)
|
|
134
|
-
onAccept == null ? void 0 : onAccept(acceptedGroups);
|
|
129
|
+
if (acceptedGroups.length) onAccept == null ? void 0 : onAccept(acceptedGroups);
|
|
135
130
|
const declinedGroups = filterCookieGroups(cookieGroups, declinedCookieGroups);
|
|
136
|
-
if (declinedGroups.length)
|
|
137
|
-
|
|
138
|
-
if (!notAcceptedOrDeclinedCookieGroups.length)
|
|
139
|
-
return;
|
|
131
|
+
if (declinedGroups.length) onDecline == null ? void 0 : onDecline(declinedGroups);
|
|
132
|
+
if (!notAcceptedOrDeclinedCookieGroups.length) return;
|
|
140
133
|
const childToClone = templateNode.content.firstElementChild;
|
|
141
|
-
if (childToClone === null)
|
|
142
|
-
throw new Error("The cookie bar template element may not be empty.");
|
|
134
|
+
if (childToClone === null) throw new Error("The cookie bar template element may not be empty.");
|
|
143
135
|
const cookieBarNode = cloneNode(childToClone);
|
|
144
136
|
registerEvents({
|
|
145
137
|
client,
|
|
@@ -157,6 +149,7 @@ var showCookieBar = async (options = {}) => {
|
|
|
157
149
|
onShow == null ? void 0 : onShow();
|
|
158
150
|
};
|
|
159
151
|
export {
|
|
152
|
+
FetchClient,
|
|
160
153
|
loadCookieGroups,
|
|
161
154
|
showCookieBar
|
|
162
155
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../js/src/cookiebar.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Cookiebar functionality, as a TS/JS module.\n *\n * About modules: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules\n *\n * The code is organized here in a way to make the templates work with Django's page\n * cache. This means that anything user-specific (so different django session and even\n * cookie consent cookies) cannot be baked into the templates, as that breaks caches.\n *\n * The cookie bar operates on the following principles:\n *\n * - The developer using the library includes the desired template in their django\n * templates, using the HTML <template> element. This contains the content for the\n * cookie bar.\n * - The developer is responsible for loading some Javascript that loads this script.\n * - The main export of this script needs to be called (showCookieBar), with the\n * appropriate options.\n * - The options include the backend URLs where the retrieve data, which selectors/DOM\n * nodes to use for various functionality and the hooks to tap into the accept/decline\n * life-cycle.\n * - When a user accepts or declines (all) cookies, the call to the backend is made via\n * a fetch request, bypassing any page caches and preventing full-page reloads.\n */\n\n/**\n * A serialized cookie group.\n *\n * See the backend model method `CookieGroup.as_json()`.\n */\nexport interface CookieGroup {\n varname: string;\n name: string;\n description: string;\n is_required: boolean;\n}\n\nexport interface Options {\n statusUrl: string;\n // TODO: also accept element rather than selector?\n templateSelector: string;\n /**\n * DOM selector to the (script) tag holding the JSON-serialized cookie groups.\n *\n * This is typically rendered in a template with a template tag, e.g.\n *\n * ```django\n * {% all_cookie_groups 'cookie-consent__cookie-groups' %}\n * ```\n *\n * resulting in the selector: `'#cookie-consent__cookie-groups'`.\n */\n cookieGroupsSelector: string;\n acceptSelector: string;\n declineSelector: string;\n /**\n * Either a string (selector), DOMNode or null.\n *\n * If null, the bar is appended to the body. If provided, the node is used or looked\n * up.\n */\n insertBefore: string | HTMLElement | null;\n /**\n * Optional callback for when the cookie bar is being shown.\n *\n * You can use this to add a CSS class name to the body, for example.\n */\n onShow?: () => void;\n /**\n * Optional callback called when cookies are accepted.\n */\n onAccept?: (acceptedGroups: CookieGroup[], event?: MouseEvent) => void;\n /**\n * Optional callback called when cookies are accepted.\n */\n onDecline?: (declinedGroups: CookieGroup[], event?: MouseEvent) => void;\n /**\n * Name of the header to use for the CSRF token.\n *\n * If needed, this can be read/set via `settings.CSRF_HEADER_NAME` in the backend.\n */\n csrfHeaderName: string;\n};\n\nexport interface CookieStatus {\n csrftoken: string;\n /**\n * Backend endpoint to POST to to accept the cookie groups.\n */\n acceptUrl: string;\n /**\n * Backend endpoint to POST to to decline the cookie groups.\n */\n declineUrl: string;\n /**\n * Array of accepted cookie group varnames.\n */\n acceptedCookieGroups: string[];\n /**\n * Array of declined cookie group varnames.\n */\n declinedCookieGroups: string[];\n /**\n * Array of undecided cookie group varnames.\n */\n notAcceptedOrDeclinedCookieGroups: string[];\n}\n\nconst DEFAULT_FETCH_HEADERS: Record<string, string> = {\n 'X-Cookie-Consent-Fetch': '1'\n};\n\n/**\n * A simple wrapper around window.fetch that understands the django-cookie-consent\n * backend endpoints.\n *\n * @private - while exported, use at your own risk. This class is not part of the\n * public API covered by SemVer.\n */\nexport class FetchClient {\n protected statusUrl: string;\n protected csrfHeaderName: string;\n protected cookieStatus: CookieStatus | null;\n\n constructor(statusUrl: string, csrfHeaderName: string) {\n this.statusUrl = statusUrl;\n this.csrfHeaderName = csrfHeaderName;\n this.cookieStatus = null;\n }\n\n async getCookieStatus(): Promise<CookieStatus> {\n if (this.cookieStatus === null) {\n const response = await window.fetch(\n this.statusUrl,\n {\n method: 'GET',\n credentials: 'same-origin',\n headers: DEFAULT_FETCH_HEADERS,\n }\n );\n this.cookieStatus = await response.json();\n }\n\n // type checker sanity check\n if (this.cookieStatus === null) {\n throw new Error('Unexpectedly received null cookie status');\n }\n return this.cookieStatus;\n };\n\n async saveCookiesStatusBackend (urlProperty: 'acceptUrl' | 'declineUrl') {\n const cookieStatus = await this.getCookieStatus();\n const url = cookieStatus[urlProperty];\n if (!url) {\n throw new Error(`Missing url for ${urlProperty} - was the cookie status not loaded properly?`);\n }\n\n await window.fetch(url, {\n method: 'POST',\n credentials: 'same-origin',\n headers: {\n ...DEFAULT_FETCH_HEADERS,\n [this.csrfHeaderName]: cookieStatus.csrftoken\n }\n });\n }\n}\n\n/**\n * Read the JSON script node contents and parse the content as JSON.\n *\n * The result is the list of available/configured cookie groups.\n * Use the status URL to get the accepted/declined status for an individual user.\n */\nexport const loadCookieGroups = (selector: string): CookieGroup[] => {\n const node = document.querySelector<HTMLScriptElement>(selector);\n if (!node) {\n throw new Error(`No cookie groups (script) tag found, using selector: '${selector}'`);\n }\n return JSON.parse(node.innerText);\n};\n\nconst doInsertBefore = (beforeNode: HTMLElement, newNode: Node): void => {\n const parent = beforeNode.parentNode;\n if (parent === null) throw new Error('Reference node doesn\\'t have a parent.');\n parent.insertBefore(newNode, beforeNode);\n}\n\ntype RegisterEventsOptions = Pick<\n Options,\n 'acceptSelector' | 'onAccept' | 'declineSelector' | 'onDecline'\n> & Pick<\n CookieStatus,\n 'acceptedCookieGroups' | 'declinedCookieGroups' | 'notAcceptedOrDeclinedCookieGroups'\n> & {\n client: FetchClient,\n cookieBarNode: Element;\n cookieGroups: CookieGroup[];\n}\n\n/**\n * Register the accept/decline event handlers.\n *\n * Note that we can't just set the decline or accept cookie purely client-side, as the\n * cookie possibly has the httpOnly flag set.\n */\nconst registerEvents = ({\n client,\n cookieBarNode,\n cookieGroups,\n acceptSelector,\n onAccept,\n declineSelector,\n onDecline,\n acceptedCookieGroups: accepted,\n declinedCookieGroups: declined,\n notAcceptedOrDeclinedCookieGroups: undecided,\n}: RegisterEventsOptions): void => {\n\n const acceptNode = cookieBarNode.querySelector<HTMLElement>(acceptSelector);\n if (acceptNode) {\n acceptNode.addEventListener('click', event => {\n event.preventDefault();\n const acceptedGroups = filterCookieGroups(cookieGroups, accepted.concat(undecided));\n onAccept?.(acceptedGroups, event);\n // trigger async action, but don't wait for completion\n client.saveCookiesStatusBackend('acceptUrl');\n cookieBarNode.parentNode!.removeChild(cookieBarNode);\n });\n }\n\n const declineNode = cookieBarNode.querySelector<HTMLElement>(declineSelector);\n if (declineNode) {\n declineNode.addEventListener('click', event => {\n event.preventDefault();\n const declinedGroups = filterCookieGroups(cookieGroups, declined.concat(undecided));\n onDecline?.(declinedGroups, event);\n // trigger async action, but don't wait for completion\n client.saveCookiesStatusBackend('declineUrl');\n cookieBarNode.parentNode!.removeChild(cookieBarNode);\n });\n }\n};\n\n/**\n * Filter the cookie groups down to a subset of specified varnames.\n */\nconst filterCookieGroups = (cookieGroups: CookieGroup[], varNames: string[]) => {\n return cookieGroups.filter(group => varNames.includes(group.varname));\n};\n\n// See https://github.com/microsoft/TypeScript/issues/283\nfunction cloneNode<T extends Node>(node: T) {\n return <T>node.cloneNode(true);\n}\n\nexport const showCookieBar = async (options: Partial<Options> = {}): Promise<void> => {\n const {\n templateSelector = '#cookie-consent__cookie-bar',\n cookieGroupsSelector = '#cookie-consent__cookie-groups',\n acceptSelector = '.cookie-consent__accept',\n declineSelector = '.cookie-consent__decline',\n insertBefore = null,\n onShow,\n onAccept,\n onDecline,\n statusUrl = '',\n csrfHeaderName = 'X-CSRFToken', // Django's default, can be overridden with settings.CSRF_HEADER_NAME\n } = options;\n\n const cookieGroups = loadCookieGroups(cookieGroupsSelector);\n\n // no cookie groups -> abort, nothing to do\n if (!cookieGroups.length) return;\n\n const templateNode = document.querySelector<HTMLTemplateElement>(templateSelector);\n if (!templateNode) {\n throw new Error(`No (template) element found for selector '${templateSelector}'.`)\n }\n\n // insert before a given node, if specified, or append to the body as default behaviour\n const doInsert = insertBefore === null\n ? (cookieBarNode: Node) => document.querySelector('body')!.appendChild(cookieBarNode)\n : typeof insertBefore === 'string'\n ? (cookieBarNode: Node) => {\n const referenceNode = document.querySelector<HTMLElement>(insertBefore);\n if (referenceNode === null) throw new Error(`No element found for selector '${insertBefore}'.`)\n doInsertBefore(referenceNode, cookieBarNode);\n }\n : (cookieBarNode: Node) => doInsertBefore(insertBefore, cookieBarNode)\n ;\n\n if (!statusUrl) throw new Error('Missing status URL option, did you forget to pass the `statusUrl` option?');\n\n const client = new FetchClient(statusUrl, csrfHeaderName);\n const cookieStatus = await client.getCookieStatus();\n\n // calculate the cookie groups to invoke the callbacks. We deliberately fire those\n // without awaiting so that our cookie bar is shown/hidden as soon as possible.\n const {\n acceptedCookieGroups,\n declinedCookieGroups,\n notAcceptedOrDeclinedCookieGroups\n } = cookieStatus;\n\n const acceptedGroups = filterCookieGroups(cookieGroups, acceptedCookieGroups);\n if (acceptedGroups.length) onAccept?.(acceptedGroups);\n const declinedGroups = filterCookieGroups(cookieGroups, declinedCookieGroups);\n if (declinedGroups.length) onDecline?.(declinedGroups);\n\n // there are no (more) cookie groups to accept, don't show the bar\n if (!notAcceptedOrDeclinedCookieGroups.length) return;\n\n // grab the contents from the template node and add them to the DOM, optionally\n // calling the onShow callback\n const childToClone = templateNode.content.firstElementChild;\n if (childToClone === null) throw new Error('The cookie bar template element may not be empty.');\n const cookieBarNode = cloneNode(childToClone);\n registerEvents({\n client,\n cookieBarNode,\n cookieGroups,\n acceptSelector,\n onAccept,\n declineSelector,\n onDecline,\n acceptedCookieGroups,\n declinedCookieGroups,\n notAcceptedOrDeclinedCookieGroups,\n });\n doInsert(cookieBarNode);\n onShow?.();\n};\n"],
|
|
5
|
+
"mappings": ";AA2GA,IAAM,wBAAgD;AAAA,EACpD,0BAA0B;AAC5B;AASO,IAAM,cAAN,MAAkB;AAAA,EAKvB,YAAY,WAAmB,gBAAwB;AACrD,SAAK,YAAY;AACjB,SAAK,iBAAiB;AACtB,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,MAAM,kBAAyC;AAC7C,QAAI,KAAK,iBAAiB,MAAM;AAC9B,YAAM,WAAW,MAAM,OAAO;AAAA,QAC5B,KAAK;AAAA,QACL;AAAA,UACE,QAAQ;AAAA,UACR,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AACA,WAAK,eAAe,MAAM,SAAS,KAAK;AAAA,IAC1C;AAGA,QAAI,KAAK,iBAAiB,MAAM;AAC9B,YAAM,IAAI,MAAM,0CAA0C;AAAA,IAC5D;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,yBAA0B,aAAyC;AACvE,UAAM,eAAe,MAAM,KAAK,gBAAgB;AAChD,UAAM,MAAM,aAAa,WAAW;AACpC,QAAI,CAAC,KAAK;AACR,YAAM,IAAI,MAAM,mBAAmB,WAAW,+CAA+C;AAAA,IAC/F;AAEA,UAAM,OAAO,MAAM,KAAK;AAAA,MACtB,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS;AAAA,QACP,GAAG;AAAA,QACH,CAAC,KAAK,cAAc,GAAG,aAAa;AAAA,MACtC;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAQO,IAAM,mBAAmB,CAAC,aAAoC;AACnE,QAAM,OAAO,SAAS,cAAiC,QAAQ;AAC/D,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,yDAAyD,QAAQ,GAA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AAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,WAAS,aAAa;AACtB;AACF;",
|
|
6
|
+
"names": ["cookieBarNode"]
|
|
7
|
+
}
|
{django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0/django_cookie_consent.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: django-cookie-consent
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Django cookie consent application
|
|
5
5
|
Author-email: Informatika Mihelac <bmihelac@mihelac.org>
|
|
6
6
|
License: Copyright (c) Bojan Mihelac and individual contributors.
|
|
@@ -35,7 +35,8 @@ Keywords: cookies,cookie-consent,cookie bar
|
|
|
35
35
|
Classifier: Development Status :: 4 - Beta
|
|
36
36
|
Classifier: Framework :: Django
|
|
37
37
|
Classifier: Framework :: Django :: 4.2
|
|
38
|
-
Classifier: Framework :: Django :: 5.
|
|
38
|
+
Classifier: Framework :: Django :: 5.1
|
|
39
|
+
Classifier: Framework :: Django :: 5.2
|
|
39
40
|
Classifier: Intended Audience :: Developers
|
|
40
41
|
Classifier: License :: OSI Approved :: BSD License
|
|
41
42
|
Classifier: Operating System :: Unix
|
|
@@ -47,6 +48,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
47
48
|
Classifier: Programming Language :: Python :: 3.10
|
|
48
49
|
Classifier: Programming Language :: Python :: 3.11
|
|
49
50
|
Classifier: Programming Language :: Python :: 3.12
|
|
51
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
50
52
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
51
53
|
Requires-Python: >=3.8
|
|
52
54
|
Description-Content-Type: text/markdown
|
|
@@ -69,6 +71,7 @@ Requires-Dist: sphinx; extra == "docs"
|
|
|
69
71
|
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
70
72
|
Provides-Extra: release
|
|
71
73
|
Requires-Dist: tbump; extra == "release"
|
|
74
|
+
Dynamic: license-file
|
|
72
75
|
|
|
73
76
|
Django cookie consent
|
|
74
77
|
=====================
|
|
@@ -4,7 +4,6 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "django-cookie-consent"
|
|
7
|
-
version = "0.6.0"
|
|
8
7
|
description = "Django cookie consent application"
|
|
9
8
|
authors = [
|
|
10
9
|
{name = "Informatika Mihelac", email = "bmihelac@mihelac.org"}
|
|
@@ -16,7 +15,8 @@ classifiers = [
|
|
|
16
15
|
"Development Status :: 4 - Beta",
|
|
17
16
|
"Framework :: Django",
|
|
18
17
|
"Framework :: Django :: 4.2",
|
|
19
|
-
"Framework :: Django :: 5.
|
|
18
|
+
"Framework :: Django :: 5.1",
|
|
19
|
+
"Framework :: Django :: 5.2",
|
|
20
20
|
"Intended Audience :: Developers",
|
|
21
21
|
"License :: OSI Approved :: BSD License",
|
|
22
22
|
"Operating System :: Unix",
|
|
@@ -28,6 +28,7 @@ classifiers = [
|
|
|
28
28
|
"Programming Language :: Python :: 3.10",
|
|
29
29
|
"Programming Language :: Python :: 3.11",
|
|
30
30
|
"Programming Language :: Python :: 3.12",
|
|
31
|
+
"Programming Language :: Python :: 3.13",
|
|
31
32
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
32
33
|
]
|
|
33
34
|
requires-python = ">=3.8"
|
|
@@ -35,6 +36,7 @@ dependencies = [
|
|
|
35
36
|
"django>=4.2",
|
|
36
37
|
"django-appconf",
|
|
37
38
|
]
|
|
39
|
+
dynamic = ["version"]
|
|
38
40
|
|
|
39
41
|
[project.urls]
|
|
40
42
|
Documentation = "https://django-cookie-consent.readthedocs.io/en/latest/"
|
|
@@ -63,6 +65,9 @@ release = [
|
|
|
63
65
|
"tbump",
|
|
64
66
|
]
|
|
65
67
|
|
|
68
|
+
[tool.setuptools.dynamic]
|
|
69
|
+
version = {attr = "cookie_consent.__version__"}
|
|
70
|
+
|
|
66
71
|
[tool.setuptools.packages.find]
|
|
67
72
|
include = ["cookie_consent*"]
|
|
68
73
|
namespaces = true
|
|
@@ -82,14 +87,6 @@ markers = [
|
|
|
82
87
|
"e2e: mark tests as end-to-end tests, using playwright (deselect with '-m \"not e2e\"')",
|
|
83
88
|
]
|
|
84
89
|
|
|
85
|
-
[tool.bumpversion]
|
|
86
|
-
current_version = "0.1.0"
|
|
87
|
-
files = [
|
|
88
|
-
{filename = "pyproject.toml"},
|
|
89
|
-
{filename = "README.rst"},
|
|
90
|
-
{filename = "docs/conf.py"},
|
|
91
|
-
]
|
|
92
|
-
|
|
93
90
|
[tool.coverage.run]
|
|
94
91
|
branch = true
|
|
95
92
|
source = ["cookie_consent"]
|
{django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_javascript_cookiebar.py
RENAMED
|
@@ -71,6 +71,7 @@ def test_cookiebar_not_shown_anymore_after_accept_or_decline(btn_text: str, page
|
|
|
71
71
|
def test_on_accept_handler_runs_on_load(page: Page, live_server):
|
|
72
72
|
accept_button = page.get_by_role("button", name="Accept")
|
|
73
73
|
accept_button.click()
|
|
74
|
+
page.wait_for_load_state("networkidle")
|
|
74
75
|
# wait for fetch calls to complete & avoid test race conditions...
|
|
75
76
|
share_button = page.get_by_role("button", name="SHARE")
|
|
76
77
|
expect(share_button).to_be_visible()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.6.0"
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../js/src/cookiebar.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Cookiebar functionality, as a TS/JS module.\n *\n * About modules: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules\n *\n * The code is organized here in a way to make the templates work with Django's page\n * cache. This means that anything user-specific (so different django session and even\n * cookie consent cookies) cannot be baked into the templates, as that breaks caches.\n *\n * The cookie bar operates on the following principles:\n *\n * - The developer using the library includes the desired template in their django\n * templates, using the HTML <template> element. This contains the content for the\n * cookie bar.\n * - The developer is responsible for loading some Javascript that loads this script.\n * - The main export of this script needs to be called (showCookieBar), with the\n * appropriate options.\n * - The options include the backend URLs where the retrieve data, which selectors/DOM\n * nodes to use for various functionality and the hooks to tap into the accept/decline\n * life-cycle.\n * - When a user accepts or declines (all) cookies, the call to the backend is made via\n * a fetch request, bypassing any page caches and preventing full-page reloads.\n */\n\n/**\n * A serialized cookie group.\n *\n * See the backend model method `CookieGroup.as_json()`.\n */\nexport interface CookieGroup {\n varname: string;\n name: string;\n description: string;\n is_required: boolean;\n}\n\nexport interface Options {\n statusUrl: string;\n // TODO: also accept element rather than selector?\n templateSelector: string;\n /**\n * DOM selector to the (script) tag holding the JSON-serialized cookie groups.\n *\n * This is typically rendered in a template with a template tag, e.g.\n *\n * ```django\n * {% all_cookie_groups 'cookie-consent__cookie-groups' %}\n * ```\n *\n * resulting in the selector: `'#cookie-consent__cookie-groups'`.\n */\n cookieGroupsSelector: string;\n acceptSelector: string;\n declineSelector: string;\n /**\n * Either a string (selector), DOMNode or null.\n *\n * If null, the bar is appended to the body. If provided, the node is used or looked\n * up.\n */\n insertBefore: string | HTMLElement | null;\n /**\n * Optional callback for when the cookie bar is being shown.\n *\n * You can use this to add a CSS class name to the body, for example.\n */\n onShow?: () => void;\n /**\n * Optional callback called when cookies are accepted.\n */\n onAccept?: (acceptedGroups: CookieGroup[], event?: MouseEvent) => void;\n /**\n * Optional callback called when cookies are accepted.\n */\n onDecline?: (declinedGroups: CookieGroup[], event?: MouseEvent) => void;\n /**\n * Name of the header to use for the CSRF token.\n *\n * If needed, this can be read/set via `settings.CSRF_HEADER_NAME` in the backend.\n */\n csrfHeaderName: string;\n};\n\nexport interface CookieStatus {\n csrftoken: string;\n /**\n * Backend endpoint to POST to to accept the cookie groups.\n */\n acceptUrl: string;\n /**\n * Backend endpoint to POST to to decline the cookie groups.\n */\n declineUrl: string;\n /**\n * Array of accepted cookie group varnames.\n */\n acceptedCookieGroups: string[];\n /**\n * Array of declined cookie group varnames.\n */\n declinedCookieGroups: string[];\n /**\n * Array of undecided cookie group varnames.\n */\n notAcceptedOrDeclinedCookieGroups: string[];\n}\n\nconst DEFAULT_FETCH_HEADERS: Record<string, string> = {\n 'X-Cookie-Consent-Fetch': '1'\n};\n\nclass FetchClient {\n protected statusUrl: string;\n protected csrfHeaderName: string;\n protected cookieStatus: CookieStatus | null;\n\n constructor(statusUrl: string, csrfHeaderName: string) {\n this.statusUrl = statusUrl;\n this.csrfHeaderName = csrfHeaderName;\n this.cookieStatus = null;\n }\n\n async getCookieStatus(): Promise<CookieStatus> {\n if (this.cookieStatus === null) {\n const response = await window.fetch(\n this.statusUrl,\n {\n method: 'GET',\n credentials: 'same-origin',\n headers: DEFAULT_FETCH_HEADERS,\n }\n );\n this.cookieStatus = await response.json();\n }\n\n // type checker sanity check\n if (this.cookieStatus === null) {\n throw new Error('Unexpectedly received null cookie status');\n }\n return this.cookieStatus;\n };\n\n async saveCookiesStatusBackend (urlProperty: 'acceptUrl' | 'declineUrl') {\n const cookieStatus = await this.getCookieStatus();\n const url = cookieStatus[urlProperty];\n if (!url) {\n throw new Error(`Missing url for ${urlProperty} - was the cookie status not loaded properly?`);\n }\n\n await window.fetch(url, {\n method: 'POST',\n credentials: 'same-origin',\n headers: {\n ...DEFAULT_FETCH_HEADERS,\n [this.csrfHeaderName]: cookieStatus.csrftoken\n }\n });\n }\n}\n\n/**\n * Read the JSON script node contents and parse the content as JSON.\n *\n * The result is the list of available/configured cookie groups.\n * Use the status URL to get the accepted/declined status for an individual user.\n */\nexport const loadCookieGroups = (selector: string): CookieGroup[] => {\n const node = document.querySelector<HTMLScriptElement>(selector);\n if (!node) {\n throw new Error(`No cookie groups (script) tag found, using selector: '${selector}'`);\n }\n return JSON.parse(node.innerText);\n};\n\nconst doInsertBefore = (beforeNode: HTMLElement, newNode: Node): void => {\n const parent = beforeNode.parentNode;\n if (parent === null) throw new Error('Reference node doesn\\'t have a parent.');\n parent.insertBefore(newNode, beforeNode);\n}\n\ntype RegisterEventsOptions = Pick<\n Options,\n 'acceptSelector' | 'onAccept' | 'declineSelector' | 'onDecline'\n> & Pick<\n CookieStatus,\n 'acceptedCookieGroups' | 'declinedCookieGroups' | 'notAcceptedOrDeclinedCookieGroups'\n> & {\n client: FetchClient,\n cookieBarNode: Element;\n cookieGroups: CookieGroup[];\n}\n\n/**\n * Register the accept/decline event handlers.\n *\n * Note that we can't just set the decline or accept cookie purely client-side, as the\n * cookie possibly has the httpOnly flag set.\n */\nconst registerEvents = ({\n client,\n cookieBarNode,\n cookieGroups,\n acceptSelector,\n onAccept,\n declineSelector,\n onDecline,\n acceptedCookieGroups: accepted,\n declinedCookieGroups: declined,\n notAcceptedOrDeclinedCookieGroups: undecided,\n}: RegisterEventsOptions): void => {\n\n const acceptNode = cookieBarNode.querySelector<HTMLElement>(acceptSelector);\n if (acceptNode) {\n acceptNode.addEventListener('click', event => {\n event.preventDefault();\n const acceptedGroups = filterCookieGroups(cookieGroups, accepted.concat(undecided));\n onAccept?.(acceptedGroups, event);\n // trigger async action, but don't wait for completion\n client.saveCookiesStatusBackend('acceptUrl');\n cookieBarNode.parentNode!.removeChild(cookieBarNode);\n });\n }\n\n const declineNode = cookieBarNode.querySelector<HTMLElement>(declineSelector);\n if (declineNode) {\n declineNode.addEventListener('click', event => {\n event.preventDefault();\n const declinedGroups = filterCookieGroups(cookieGroups, declined.concat(undecided));\n onDecline?.(declinedGroups, event);\n // trigger async action, but don't wait for completion\n client.saveCookiesStatusBackend('declineUrl');\n cookieBarNode.parentNode!.removeChild(cookieBarNode);\n });\n }\n};\n\n/**\n * Filter the cookie groups down to a subset of specified varnames.\n */\nconst filterCookieGroups = (cookieGroups: CookieGroup[], varNames: string[]) => {\n return cookieGroups.filter(group => varNames.includes(group.varname));\n};\n\n// See https://github.com/microsoft/TypeScript/issues/283\nfunction cloneNode<T extends Node>(node: T) {\n return <T>node.cloneNode(true);\n}\n\nexport const showCookieBar = async (options: Partial<Options> = {}): Promise<void> => {\n const {\n templateSelector = '#cookie-consent__cookie-bar',\n cookieGroupsSelector = '#cookie-consent__cookie-groups',\n acceptSelector = '.cookie-consent__accept',\n declineSelector = '.cookie-consent__decline',\n insertBefore = null,\n onShow,\n onAccept,\n onDecline,\n statusUrl = '',\n csrfHeaderName = 'X-CSRFToken', // Django's default, can be overridden with settings.CSRF_HEADER_NAME\n } = options;\n\n const cookieGroups = loadCookieGroups(cookieGroupsSelector);\n\n // no cookie groups -> abort, nothing to do\n if (!cookieGroups.length) return;\n\n const templateNode = document.querySelector<HTMLTemplateElement>(templateSelector);\n if (!templateNode) {\n throw new Error(`No (template) element found for selector '${templateSelector}'.`)\n }\n\n // insert before a given node, if specified, or append to the body as default behaviour\n const doInsert = insertBefore === null\n ? (cookieBarNode: Node) => document.querySelector('body')!.appendChild(cookieBarNode)\n : typeof insertBefore === 'string'\n ? (cookieBarNode: Node) => {\n const referenceNode = document.querySelector<HTMLElement>(insertBefore);\n if (referenceNode === null) throw new Error(`No element found for selector '${insertBefore}'.`)\n doInsertBefore(referenceNode, cookieBarNode);\n }\n : (cookieBarNode: Node) => doInsertBefore(insertBefore, cookieBarNode)\n ;\n\n if (!statusUrl) throw new Error('Missing status URL option, did you forget to pass the `statusUrl` option?');\n\n const client = new FetchClient(statusUrl, csrfHeaderName);\n const cookieStatus = await client.getCookieStatus();\n\n // calculate the cookie groups to invoke the callbacks. We deliberately fire those\n // without awaiting so that our cookie bar is shown/hidden as soon as possible.\n const {\n acceptedCookieGroups,\n declinedCookieGroups,\n notAcceptedOrDeclinedCookieGroups\n } = cookieStatus;\n\n const acceptedGroups = filterCookieGroups(cookieGroups, acceptedCookieGroups);\n if (acceptedGroups.length) onAccept?.(acceptedGroups);\n const declinedGroups = filterCookieGroups(cookieGroups, declinedCookieGroups);\n if (declinedGroups.length) onDecline?.(declinedGroups);\n\n // there are no (more) cookie groups to accept, don't show the bar\n if (!notAcceptedOrDeclinedCookieGroups.length) return;\n\n // grab the contents from the template node and add them to the DOM, optionally\n // calling the onShow callback\n const childToClone = templateNode.content.firstElementChild;\n if (childToClone === null) throw new Error('The cookie bar template element may not be empty.');\n const cookieBarNode = cloneNode(childToClone);\n registerEvents({\n client,\n cookieBarNode,\n cookieGroups,\n acceptSelector,\n onAccept,\n declineSelector,\n onDecline,\n acceptedCookieGroups,\n declinedCookieGroups,\n notAcceptedOrDeclinedCookieGroups,\n });\n doInsert(cookieBarNode);\n onShow?.();\n};\n"],
|
|
5
|
-
"mappings": ";AA2GA,IAAM,wBAAgD;AAAA,EACpD,0BAA0B;AAC5B;AAEA,IAAM,cAAN,MAAkB;AAAA,EAKhB,YAAY,WAAmB,gBAAwB;AACrD,SAAK,YAAY;AACjB,SAAK,iBAAiB;AACtB,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,MAAM,kBAAyC;AAC7C,QAAI,KAAK,iBAAiB,MAAM;AAC9B,YAAM,WAAW,MAAM,OAAO;AAAA,QAC5B,KAAK;AAAA,QACL;AAAA,UACE,QAAQ;AAAA,UACR,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AACA,WAAK,eAAe,MAAM,SAAS,KAAK;AAAA,IAC1C;AAGA,QAAI,KAAK,iBAAiB,MAAM;AAC9B,YAAM,IAAI,MAAM,0CAA0C;AAAA,IAC5D;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,yBAA0B,aAAyC;AACvE,UAAM,eAAe,MAAM,KAAK,gBAAgB;AAChD,UAAM,MAAM,aAAa,WAAW;AACpC,QAAI,CAAC,KAAK;AACR,YAAM,IAAI,MAAM,mBAAmB,WAAW,+CAA+C;AAAA,IAC/F;AAEA,UAAM,OAAO,MAAM,KAAK;AAAA,MACtB,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS;AAAA,QACP,GAAG;AAAA,QACH,CAAC,KAAK,cAAc,GAAG,aAAa;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e,aAAa,QAAQ;AAC1C,MAAI,iBAAiB;AAAM,UAAM,IAAI,MAAM,mDAAmD;AAC9F,QAAM,gBAAgB,UAAU,YAAY;AAC5C,iBAAe;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,WAAS,aAAa;AACtB;AACF;",
|
|
6
|
-
"names": ["cookieBarNode"]
|
|
7
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/migrations/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/cookie_consent/templatetags/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_cookie_consent-0.6.0 → django_cookie_consent-0.8.0}/tests/test_cookie_group_model.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|