GDPR

Icon:

<i class="fa fa-shield"></i>

Requirements:

# until we get to python 3.6 on our servers, add to 'requirements/ci.txt'
python2-secrets==1.0.5

Form Notice

The ConsentFormSettings model is (currently) only used to add a notice to a form. This notice can include a URL (and other HTML tags).

To set-up the form settings:

  1. Settings, GDPR, Form Settings

  2. Choose a slug for your form e.g. generic-form

  3. Add the text for the Form notice.

You can use the rich text editor to include HTML in the form notice e.g:

<strong>Take a look</strong> at our
<a href="/article/ilspas-privacy-policy/" target="_blank" rel="noopener noreferrer">
  Privacy Notice
</a>
for more information.

For enquiry forms, inherit from EnquiryCreateMixin:

class EnquiryCreateView(EnquiryCreateMixin, CreateView):

For other forms, inherit from ConsentMaintenanceMixin e.g:

class ApplicationCreateView(ConsentMaintenanceMixin, CreateView):

In your view, set consent_form_settings to the form settings slug e.g:

class ApplicationCreateView(ConsentMaintenanceMixin, CreateView):
    consent_form_settings = "generic-form"

If your template includes our standard _form.html it will automatically display the form_notice.

Unsubscribe

To create an unsubscribe page…

Create the view:

from base.view_utils import BaseMixin, RedirectNextMixin
from gdpr.views import UserConsentUnsubscribeUpdateMixin

class UserConsentUnsubscribeUpdateView(
    RedirectNextMixin, UserConsentUnsubscribeUpdateMixin, BaseMixin, UpdateView
):
    template_name = "example/user_consent_unsubscribe.html"

The URL for this view must capture the token e.g:

path(
    "unsubscribe/<str:token>/",
    view=UserConsentUnsubscribeUpdateView.as_view(),
    name="web.unsubscribe",
),

Create a template which includes _unsubscribe.html:

{% include 'gdpr/_unsubscribe.html' %}

Tip

This template may display a link for the Contact page of your site, so check your project has a web.contact URL.

To create an unsubscribe URL and pass it to an email template:

with transaction.atomic():
    token = UserConsentUnsubscribe.objects.create_unsubscribe_token(
        contact.user, SPECIAL_OFFERS
    )
    url = urllib.parse.urljoin(
        settings.HOST_NAME, reverse("web.unsubscribe", args=[token])
    )
    context = {
        email: {
            "name": contact.full_name,
            "unsub": url,
        }
    }
    queue_mail_template(
        contact, MAIL_TEMPLATE_NOTIFY, context
    )

Tip

Click here for information on adding the unsubscribe URL to the Mandrill Template.