GDPR

Icon:

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

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">
  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 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="user.consent.unsubscribe",
),

Create a template which includes _unsubscribe.html:

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

Note

Make sure your project has a contact page with a web.contact URL.

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

import secrets
import urllib.parse
from django.conf import settings

token = secrets.token_urlsafe()
unsubscribe_url = urllib.parse.urljoin(
    settings.HOST_NAME,
    reverse("user.consent.unsubscribe", args=[token]),
)
# find the user consent
user_consent = UserConsent.objects.get(
    user=contact.user,
    consent__slug=SPECIAL_OFFERS,
)
# link the token to the user consent
UserConsentUnsubscribe.objects.init_user_consent_unsubscribe(
    user_consent, token
)
context = {
    contact.email: {
        "name": contact.full_name,
        "unsub": unsubscribe_url,
    }
}
queue_mail_template(contact, MAIL_TEMPLATE_NOTIFY, context)

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