djblets.privacy.consent.base¶
Base support for consent types, data, and requirements.
- class Consent(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
Values for representing consent decisions.
- UNSET = 0¶
Consent has not been set.
- GRANTED = 1¶
Consent was granted.
- DENIED = 2¶
Consent was denied.
- class ConsentData(requirement_id, granted=False, timestamp=None, source=None, extra_data=None)¶
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)¶
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)¶
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.
- serialize_audit_info(identifier)¶
Serialize the consent data for audit tracking.
- class BaseConsentRequirement¶
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.
- requirement_id = None¶
The unique ID of the requirement.
- name = None¶
The name of the requirement.
- summary = None¶
A brief summary of the requirement.
- intent_description = None¶
A short description of why the requirement is needed.
- data_use_description = None¶
A short description of what data will be sent and how it will be used.
- allow_text = 'Allow'¶
Text to use for the allow action.
- allowed_text = 'Allowed'¶
Text to use for when the allow action is selected.
- block_text = 'Block'¶
Text to use for the block action.
- blocked_text = 'Blocked'¶
Text to use for when the block action is selected.
- icons = {}¶
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)¶
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)¶
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: