djblets.privacy.consent.base¶
Base support for consent types, data, and requirements.
- class Consent(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Values for representing consent decisions.
- class ConsentData(requirement_id, granted=False, timestamp=None, source=None, extra_data=None)[source]¶
Bases:
object
Data representing a granted or denied consent for a requirement.
This tracks data about granted or denied consent for use in both setting a consent decision and for recording in an audit trail. The data tracks a number of important bits of information for later proving that consent was granted or denied at a particular point in time.
Note that this does not track unset consent. It’s only used when a decision was specifically made.
- extra_data¶
Additional data to include that may be relevant for an audit. This can contain any information, and is up to the caller to determine.
- Type:
- requirement_id¶
The ID of a
ConsentRequirement
for which consent was granted or denied.- Type:
- source¶
The source where consent was decided. This is free-form text, and may represent a URL, API endpoint, or include other additional source-identifying information.
- Type:
- timestamp¶
The date/time when the consent was decided.
- Type:
- classmethod parse_audit_info(requirement_id, data)[source]¶
Parse stored audit information.
This data may come from the database or another tracking store.
- Parameters:
- Returns:
The resulting consent data from the audit log.
- Return type:
- __init__(requirement_id, granted=False, timestamp=None, source=None, extra_data=None)[source]¶
Initialize the consent data.
- Parameters:
requirement_id (
unicode
) – The ID of aConsentRequirement
for which consent was granted or denied.granted (
bool
, optional) – Whether consent was granted (True
) or denied (False
). Defaults to denied.timestamp (
datetime.datetime
, optional) – The date/time when the consent was decided. If not specified, the current date/time will be used.source (
unicode
, optional) – The source where consent was decided. This is free-form text, and may represent a URL, API endpoint, or include other additional source-identifying information.extra_data (
dict
, optional) – Additional data to include that may be relevant for an audit. This can contain any information, and is up to the caller to determine.
- class BaseConsentRequirement[source]¶
Bases:
object
Represents an aspect of the product requiring consent.
For every piece of a product that requires consent (sending data to a tracking service, for instance), a Requirement must be registered in the
registry
.This lists information on the requirement, describing it and optionally providing a URL for learning more about it (which may point to a privacy policy).
It also contains helper functions to perform the lookups and generate consent data for this requirement.
- data_use_description = None[source]¶
A short description of what data will be sent and how it will be used.
- icons = {}[source]¶
The icons used to represent this service or topic.
This is in the form of a dictionary of icon resolution indicators (for
srcset
values) to URLs or relative static media paths.
- get_consent(user)[source]¶
Return the user’s consent decision for this requirement.
- Parameters:
user (
django.contrib.auth.models.User
) – The user who made a decision on consent for this requirement.- Returns:
The user’s consent decision for this requirement.
- Return type:
- build_consent_data(**kwargs)[source]¶
Returns ConsentData for this requirement.
- Parameters:
**kwargs (
dict
) – Positional arguments to pass toConsentData
.- Returns:
The resulting consent data for this requirement and the specified arguments.
- Return type: