djblets.privacy.consent.base¶
Base support for consent types, data, and requirements.
- class ConsentData(requirement_id, granted=False, timestamp=None, source=None, extra_data=None)[source]¶
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
unicode
- 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
unicode
- 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
requirement_id (unicode) – The ID of a
ConsentRequirement
for which consent was granted or denied.data (dict) – The deserialized data to parse.
- Returns
The resulting consent data from the audit log.
- Return type
- serialize_audit_info(identifier)[source]¶
Serialize the consent data for audit tracking.
- Parameters
identifier (unicode) – The identifier to store along with the rest of the data, to help identify the data subject at that point in time. This is considered opaque, and is up to the consent tracker.
- Returns
Serialized data for the audit log.
- Return type
- class BaseConsentRequirement[source]¶
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 to
ConsentData
.- Returns
The resulting consent data for this requirement and the specified arguments.
- Return type