Unsubscribe url + view

This commit is contained in:
Seb 2020-05-07 13:54:25 +10:00
parent eef617ff8a
commit 67bf96aaae
4 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<html>
<body>
<div style='width: 100%, height: 100%; text-align: center; margin-top: 120px;'>
<p>The email '{{ contact.email }}' has been unsubscribed from {{ site.site_name }}'s mailing list.</p><br/>
<p>If this was a mistake head back to the <a href="{{ site.root_page.full_url }}">site</a> to resubscribe.</p>
</div>
</body>
</html>

9
birdsong/urls.py Normal file
View File

@ -0,0 +1,9 @@
from django.urls import path
from .views import unsubscribe
app_name = 'birdsong'
urlpatterns = [
path('unsubscribe/<int:user_id>/', unsubscribe.unsubscribe_user, name='unsubscribe')
]

View File

@ -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')

View File

@ -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,
}
)