diff --git a/birdsong/templates/unsubscribe.html b/birdsong/templates/unsubscribe.html new file mode 100644 index 0000000..b3e8dba --- /dev/null +++ b/birdsong/templates/unsubscribe.html @@ -0,0 +1,8 @@ + + +
+

The email '{{ contact.email }}' has been unsubscribed from {{ site.site_name }}'s mailing list.


+

If this was a mistake head back to the site to resubscribe.

+
+ + \ No newline at end of file diff --git a/birdsong/urls.py b/birdsong/urls.py new file mode 100644 index 0000000..0b4ae60 --- /dev/null +++ b/birdsong/urls.py @@ -0,0 +1,9 @@ +from django.urls import path +from .views import unsubscribe + + +app_name = 'birdsong' + +urlpatterns = [ + path('unsubscribe//', unsubscribe.unsubscribe_user, name='unsubscribe') +] diff --git a/birdsong/views/actions.py b/birdsong/views/actions.py index e0d8ac0..a9f4580 100644 --- a/birdsong/views/actions.py +++ b/birdsong/views/actions.py @@ -5,6 +5,7 @@ from wagtail.contrib.modeladmin.helpers.url import AdminURLHelper from birdsong.models import Receipt, Contact + def redirect_helper(campaign): url_helper = AdminURLHelper(type(campaign)) campaign_list_url = url_helper.get_action_url('index') diff --git a/birdsong/views/unsubscribe.py b/birdsong/views/unsubscribe.py new file mode 100644 index 0000000..ff20ab1 --- /dev/null +++ b/birdsong/views/unsubscribe.py @@ -0,0 +1,32 @@ +from django.conf import settings +from django.shortcuts import get_object_or_404, render +from wagtail.core.models import Site + +from birdsong.models import Contact + + +def unsubscribe_user(request, user_id): + contact = get_object_or_404(Contact, id=user_id) + # contact.delete() + + site = Site.find_for_request(request) + + template = getattr( + settings, + 'BIRDSONG_UNSUBSCRIBE_TEMPLATE', + 'unsubscribe.html' + ) + + return render( + request, template, context={ + 'site': site, + 'contact': contact, + } + ) + + + + + + +