Add forms for displaying and gathering consent.

Review Request #9925 — Created May 11, 2018 and submitted — Latest diff uploaded




This introduces a new djblets.privacy.consent.forms module, which
features fields, widgets, and form mixins for prompting for consent.
Along with the rest of the consent functionality, it's now very easy
for applications to offer users options on how to manage their own
personal data.

ConsentRequirementField (and its corresponding widget) displays an
informative field for a single ConsentRequirement. It clearly lists
a summary of the requirement, an optional icon representing it, a
description of the intended usage, and a description of what data would
be sent. Two buttons, "Allow" and "Block," are available to allow usage
of their private data for the feature or to block usage.

MultiConsentRequirementsField wraps multiple
ConsentRequirementFields, one for each requirement provided (or one
for each one registered in the registry). This is intended for forms
that want to offer all (or many) options at once.

ConsentFormMixin can be mixed into other forms, and will construct a
MultiConsentRequirementsField on initialization. It provides a handful
of methods to override for controlling data going into the field, and a
save_consent() method to save and record the choices made.

ConsentConfigPageFormMixin is used for configforms, and provides
default implementations of the methods needed by ConsentFormMixin. It
also automatically handles the saving, and adds a message to display
on the form when saved. This is the easiest way to provide consent
information to users.

Unit tests pass.

Manually and thoroughly tested this form, allowing and blocking
consent for multiple options and testing results. Tested validation
logic and resulting data in the database on success.