Metadata-Version: 2.5
Name: entirius-django-agreements
Version: 3.0.0
Summary: Consent and agreements module for Entirius: versioned agreement texts, consent audit trail and order snapshots
Project-URL: Homepage, https://docs.entirius.com/
Project-URL: Documentation, https://github.com/entirius/entirius-django-agreements/tree/develop/docs
Project-URL: Repository, https://github.com/entirius/entirius-django-agreements
Project-URL: Changelog, https://github.com/entirius/entirius-django-agreements/blob/develop/CHANGELOG.md
Project-URL: Issues, https://github.com/entirius/entirius-django-agreements/issues
Author: Entirius
License-Expression: MPL-2.0
License-File: LICENSE
Keywords: agreements,consent,django,ecommerce,entirius,gdpr,newsletter
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.11
Requires-Dist: django>=5.0
Requires-Dist: djangorestframework-simplejwt>=5.3
Requires-Dist: djangorestframework>=3.14
Requires-Dist: drf-spectacular>=0.27
Requires-Dist: entirius-django-regional>=2.0.0
Requires-Dist: entirius-django-utils>=2.0.0
Requires-Dist: entirius-py-process-logger>=2.0.0
Requires-Dist: pydantic>=2.0
Provides-Extra: dev
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: test
Requires-Dist: dj-database-url; extra == 'test'
Requires-Dist: factory-boy; extra == 'test'
Requires-Dist: psycopg[binary]; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-django; extra == 'test'
Description-Content-Type: text/markdown

# entirius-django-agreements

A Django module for consents and legal agreements in Entirius, the open-source modular ecommerce platform. It
versions agreement texts, records every consent and objection in an append-only audit trail, and freezes the text
a customer accepted with each order. The CMS manages agreements over an admin API; the storefront uses a public API.

[![PyPI](https://img.shields.io/pypi/v/entirius-django-agreements.svg)](https://pypi.org/project/entirius-django-agreements/)
[![Python](https://img.shields.io/pypi/pyversions/entirius-django-agreements.svg)](https://pypi.org/project/entirius-django-agreements/)
[![License: MPL-2.0](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://github.com/entirius/entirius-django-agreements/blob/develop/LICENSE)

## What it does

- Defines agreements per sales channel and keeps immutable, numbered versions of their text.
- Records consents and withdrawals per email address as an append-only audit log.
- Stores a snapshot of the accepted agreement texts with every order.
- Handles newsletter signup with double opt-in confirmation links.
- Versions legal clauses per channel, legal basis and language, and records objections.
- Exports and pseudonymises personal data for GDPR requests.

## Installation

```shell
uv add entirius-django-agreements
pip install entirius-django-agreements
```

```python
INSTALLED_APPS = [
    ...
    "django_utils",
    "django_regional",
    "django_agreements",
]

# urls.py
urlpatterns = [
    path("", include("django_agreements.urls")),
]
```

No setting is required: every setting has a default. Reference:
https://github.com/entirius/entirius-django-agreements/blob/develop/docs/configuration.md

The newsletter subscribe endpoint takes a key in the `X-API-KEY` header. Where `django_access` is installed the key
is an access token with the scope `agreements.subscribe`:

```shell
python manage.py access_token create --application storefront --create-application --scope agreements.subscribe --channel default
```

Without `django_access`, the key is the value of the `AGREEMENTS_API_KEY` setting.

## Quick start

```python
from django_agreements.services.consent_service import get_consent_status, is_consented

is_consented("customer@example.com", "marketing-email")   # latest record for one agreement
get_consent_status("customer@example.com")                # every agreement slug -> granted
```

Channels are copied from the product module when it is installed:

```shell
python manage.py sync_agreement_channels
```

## Requirements

- Python 3.11 or newer, Django 5.0 or newer.
- Entirius packages pulled in: `entirius-django-utils`, `entirius-django-regional`, `entirius-py-process-logger`.

## Documentation

- Module docs: https://github.com/entirius/entirius-django-agreements/tree/develop/docs
- Entirius documentation: https://docs.entirius.com/
- Changelog: https://github.com/entirius/entirius-django-agreements/blob/develop/CHANGELOG.md

## Part of Entirius

This module runs inside the Entirius backend service (Volkanos); the leads module builds on its legal bases and consents.

- Backend service: https://github.com/entirius/entirius-service-volkanos
- Docker harness: https://github.com/entirius/entirius-zeno
- Sibling modules: https://github.com/entirius/entirius-django-regional, https://github.com/entirius/entirius-django-leads,
  https://github.com/entirius/entirius-django-access

## Development

```shell
make install     # sync dependencies (uv)
make check       # lint + format check (ruff)
make test        # test suite (pytest + pytest-django, needs PostgreSQL via DATABASE_URL)
```

Development and agent instructions: https://github.com/entirius/entirius-django-agreements/blob/develop/AGENTS.md

## License

Mozilla Public License 2.0 (MPL-2.0) — see https://github.com/entirius/entirius-django-agreements/blob/develop/LICENSE.
