Commit 8b53d15e authored by Robert's avatar Robert

Add confirm url

parent c5b86181
......@@ -27,3 +27,7 @@ class NoSubscriber(Notification):
class Subscriber(Notification):
subject = 'Abonnement'
def get_context_data(self, **kwargs):
kwargs['token'] = self.token
return super().get_context_data(**kwargs)
Jemand hat Deine E-Mail-Adresse auf {{ site.name }} angegeben.
Jemand hat Deine E-Mail-Adresse auf {{ site.name }} angegeben. Wenn Du es nicht warst, kannst Du diese Nachricht gefahrlos ignorieren.
Wenn Du Dein Abonnement der Gruppe {{ object }} kündigen möchtest, bestätige dies bitte, indem Du dem folgenden Verweis folgst:
...
{% url 'group-unsubscribe-confirm' token.secret_key as url %}{{ url|full_url }}
......@@ -18,4 +18,9 @@ urlpatterns = [
views.GroupUnsubscribeRequest.as_view(),
name='group-unsubscribe-request',
),
url(
r'^stadt/unsubscribe/confirm/(?P<secret_key>[a-z0-9]+)/$',
views.GroupUnsubscribeConfirm.as_view(),
name='group-unsubscribe-confirm',
),
]
......@@ -5,6 +5,7 @@ from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.views.generic import CreateView, DeleteView, FormView
from core.models import PermissionToken
from core.views import PermissionMixin
from features.gestalten.models import Gestalt
from features.groups.models import Group
......@@ -71,6 +72,10 @@ class GroupUnsubscribe(PermissionMixin, DeleteView):
return self.group.get_absolute_url()
class GroupUnsubscribeConfirm(PermissionMixin, DeleteView):
pass
class GroupUnsubscribeRequest(PermissionMixin, FormView):
permission_required = 'subscriptions.delete_request'
form_class = forms.UnsubscribeRequest
......@@ -80,7 +85,10 @@ class GroupUnsubscribeRequest(PermissionMixin, FormView):
email = form.cleaned_data['subscriber']
try:
subscriber = self.group.subscribers.get_by_email(email)
notifications.Subscriber(self.group).send(subscriber)
notification = notifications.Subscriber(self.group)
notification.token = PermissionToken.objects.create(
gestalt=subscriber, target=self.group, feature_key='group-unsubscribe')
notification.send(subscriber)
except Gestalt.DoesNotExist:
notifications.NoSubscriber(self.group).send(email)
info(self.request, 'Es wurde eine E-Mail an die angebene Adresse versendet.')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment