Jump to >

djblets.privacy.consent.base

Base support for consent types, data, and requirements.

class Consent[source]

Bases: enum.Enum

Values for representing consent decisions.

UNSET = 0[source]

Consent has not been set.

GRANTED = 1[source]

Consent was granted.

DENIED = 2[source]

Consent was denied.

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.

granted

bool – Whether consent was granted (True) or denied (False).

extra_data

dict – Additional data to include that may be relevant for an audit. This can contain any information, and is up to the caller to determine.

requirement_id

unicode – The ID of a ConsentRequirement for which consent was granted or denied.

source

unicode – 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.

timestamp

datetime.datetime – The date/time when the consent was decided.

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:

ConsentData

__init__(requirement_id, granted=False, timestamp=None, source=None, extra_data=None)[source]

Initialize the consent data.

Parameters:
  • requirement_id (unicode) – The ID of a ConsentRequirement 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)[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:dict
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.

requirement_id = None[source]

The unique ID of the requirement.

name = None[source]

The name of the requirement.

summary = None[source]

A brief summary of the requirement.

intent_description = None[source]

A short description of why the requirement is needed.

data_use_description = None[source]

A short description of what data will be sent and how it will be used.

allow_text = _(u'Allow')[source]

Text to use for the allow action.

allowed_text = _(u'Allowed')[source]

Text to use for when the allow action is selected.

block_text = _(u'Block')[source]

Text to use for the block action.

blocked_text = _(u'Blocked')[source]

Text to use for when the block action is selected.

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.

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:djblets.privacy.consent.base.Consent

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:ConsentData