Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Double opt-in #40

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f999374
added double opt-in
Nov 29, 2022
d12e394
removed comments
Nov 30, 2022
d23709b
newsletter signup-block
Nov 30, 2022
c27ead5
signup-block
Dec 1, 2022
c50ee1b
Merge branch 'master' of https://github.com/unicode-it/wagtail-birdsong
Dec 1, 2022
96e502d
Merge branch 'master' into newsletter-signup
Dec 1, 2022
45741e0
update template path
Dec 1, 2022
5e28aaf
change formatting
Dec 1, 2022
a923326
Merge pull request #1 from unicode-it/newsletter-signup
unicode-it Dec 1, 2022
fd25f8a
hotfix signup view
Dec 1, 2022
d8fafe9
template hotfix
Dec 1, 2022
4a9502b
added campaign_usubscribe_success to as a dynamic setting so it's cho…
Dec 1, 2022
2643540
added migration
Dec 1, 2022
6989a13
removed old styling
Dec 1, 2022
6d9dc62
filtered contacts for confirmation
Dec 1, 2022
fbf5c6d
reverted reformatting of code
Dec 14, 2022
007546d
changed migration dependencies because it did not work with wagtail 4.0
Dec 15, 2022
3f611d4
bugfix
Dec 21, 2022
1ed9bc9
same email adress cannot have multiple entries in database
Dec 21, 2022
4d00d4f
added http to confirmation link
Dec 21, 2022
6fce854
used site.root_url in url building so it contains http/s
Dec 22, 2022
71ff008
added migrations
Dec 22, 2022
7273f06
added translation
Jan 16, 2023
6fe5524
first translations
Jan 19, 2023
b8f85be
merged with pull request raph146
Jan 19, 2023
1b10865
wip
Jan 26, 2023
ce393c4
Merge remote-tracking branch 'upstream/master'
Jan 31, 2023
7783b3c
Merge branch 'master' into feature/opt-in-translations
Jan 31, 2023
446c8b9
removed fuzzy from german po file
Feb 1, 2023
44299b2
Merge pull request #2 from unicode-it/feature/opt-in-translations
unicode-it Feb 14, 2023
b21f910
added feature flag to make double opt in optional
Feb 28, 2023
f0eea81
organized imports with isort
Feb 28, 2023
a8182a7
Merge pull request #3 from unicode-it/feature/feature_flag
unicode-it Feb 28, 2023
9831d63
added doi feature flag to readme
Feb 28, 2023
772c9af
Merge pull request #4 from unicode-it/update_doc
unicode-it Feb 28, 2023
fbd4e15
upstream migrations plus new one with changes
Mar 9, 2023
0d7dcdb
fix: errors when first deploying db due to missing doi settings in db
Mar 9, 2023
2a66299
organized imports
Mar 9, 2023
ef8a404
rewrote doi part in readme
Mar 9, 2023
3181aed
migrations for pr
Mar 9, 2023
6075000
- fixed bugs
Mar 16, 2023
6d372d4
- worked in review
Mar 20, 2023
776229b
extended readme double opt-in and birdsong settings
Mar 21, 2023
ddaac9a
refactor signup block + template
Mar 27, 2023
35d89a2
fixed type and updated translations
Mar 27, 2023
c7d1ebf
Merge branch 'master' into pr_branch
unicode-it Mar 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,34 @@ Included in birdsong is a basic way for contacts to unsubscribe, just include th
</mj-section>
{% endblock email_body %}

Birdsong settings
=================


The website's admin can set settings with regard to

- redirects
- double opt-in

If a redirect is set, the original template will not be used anymore.


.. image:: docs/birdsong-settings.png
:width: 900
:alt: Screenshot

Double opt in
=============

For security reasons it is better if a double opt-in is used for subscription.
It assures sending the campaign only to people who agreed to it and follows the regulations of EU's GDPR.
The double opt-in feature can be enabled in 'Birdsong settings' in the admin menu.
The subscribing person will receive an e-mail with a link for confirmation.
Unconfirmed contacts older than a week are deleted, when a campaign is saved, so when creating, editing or copying.


**!! Warning !!**
By enabling this feature without garantueeing that field ``is_confirmed`` is ``True`` of the old contacts, the ones who are older than a week will be deleted when campaign saving is triggered!

Future features:
----------------
Expand All @@ -255,3 +281,4 @@ Future features:
- Backends other thans SMTP for sending emails so analytics can be gathered (email opened, bounced etc)
- Reloading the preview on edit
- Broader permissions for campaigns (send, preview, test send)
spot
2 changes: 1 addition & 1 deletion birdsong/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
default_app_config = 'birdsong.apps.WagtailBirdsongApp'
default_app_config = "birdsong.apps.WagtailBirdsongApp"
8 changes: 8 additions & 0 deletions birdsong/apps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from django.apps import AppConfig
from django.db.models.signals import post_save



class WagtailBirdsongApp(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = 'birdsong'
label = 'birdsong'
verbose_name = 'Wagtail Birdsong'

def ready(self):
from .signals import clean_unconfirmed_contacts
from .models import Campaign
for subclass in Campaign.__subclasses__():
post_save.connect(clean_unconfirmed_contacts, sender=subclass)
33 changes: 27 additions & 6 deletions birdsong/backends/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from django.db import close_old_connections, transaction
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.html import format_html
from django.utils.translation import gettext as _

from birdsong.models import Campaign, CampaignStatus, Contact
from birdsong.utils import send_mass_html_mail
Expand All @@ -22,6 +24,7 @@ def __init__(self, campaign_pk, contact_pks, messages):
self.messages = messages

def run(self):

try:
logger.info(f"Sending {len(self.messages)} emails")
send_mass_html_mail(self.messages)
Expand Down Expand Up @@ -52,16 +55,34 @@ def send_campaign(self, request, campaign, contacts, test_send=False):
campaign.get_context(request, contact),
)
messages.append({
'subject': campaign.subject,
'body': content,
'from_email': self.from_email,
'to': [contact.email],
'reply_to': [self.reply_to],
})
"subject": campaign.subject,
"body": content,
"from_email": self.from_email,
"to": [contact.email],
"reply_to": [self.reply_to],
})
if test_send:
# Don't mark as complete, don't worry about threading
send_mass_html_mail(messages)
else:
campaign_thread = SendCampaignThread(
campaign.pk, [c.pk for c in contacts], messages)
campaign_thread.start()

def send_confirmation(self, request, contact, url):
from birdsong.models import BirdsongSettings

settings = BirdsongSettings.load(request_or_site=request)

body = settings.confirmation_email_body + format_html(
_('\nClick <a href="{}">here</a>!'), url
)

message = {
"subject": settings.confirmation_email_subject,
"body": body,
"from_email": self.from_email,
"to": [contact.email],
"reply_to": [self.reply_to],
}
send_mass_html_mail([message])
25 changes: 25 additions & 0 deletions birdsong/blocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.utils.html import mark_safe
from django.utils.translation import gettext_lazy as _
from wagtail.core import blocks


Expand All @@ -13,3 +14,27 @@ class DefaultBlocks(UnwrappedStreamBlock):
rich_text = blocks.RichTextBlock(
template='birdsong/mail/blocks/richtext.html',
features=['h3', 'h4', 'bold', 'italic', 'link', 'ul', 'ol', 'document-link'])


class NewsletterSubscriptionBlock(blocks.StructBlock):
"""streamfield block for newsletter subscription on wagtail pages."""

headline = blocks.CharBlock(verbose_name=_('Headline'), max_length=80)
subtext = blocks.CharBlock(
verbose_name=_('Subtext'), max_length=150, required=False
)
button_label = blocks.CharBlock(label=_('Button label'), max_length=50)
privacy_text = blocks.RichTextBlock(
label=_('Privacy Disclaimer'), max_length=500,
features=[
'bold',
'italic',
'link',
]
)


class Meta:
template = 'birdsong/site/blocks/signup.html'
icon = 'mail'
label = _('Newsletter subscription')
8 changes: 8 additions & 0 deletions birdsong/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django import forms
from birdsong.models import Contact


class ContactForm(forms.ModelForm):
class Meta:
model = Contact
fields = ('email',)
Binary file added birdsong/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
Loading