Commit c7e16cce authored by Robert's avatar Robert

Add unsubscribe confirm view

parent 8b53d15e
Pipeline #1266 failed with stage
in 1 minute and 39 seconds
{% extends 'stadt/stadt.html' %}
{% block title %}Abonnement - {{ block.super }}{% endblock %}
{% block menu %}{% menu 'group' view.group %}{% endblock %}
{% block breadcrumb %}{% breadcrumb view.group 'Abonnement' %}{% endblock %}
{% block heading_title_text %}Abonnenment{% endblock %}
{% block sidebar %}
{% include 'associations/_sidebar_entity.html' with entity=view.group %}
{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
<p>Möchtest Du Dein Abonnement der Gruppe <em>{{ view.group }}</em> kündigen?</p>
<button class="btn btn-primary">Abonnement kündigen</button>
</form>
{% endblock %}
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:
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 }}
from django.db import IntegrityError
from django.contrib.messages import info
from django.contrib.messages import success, info
from django.contrib.messages.views import SuccessMessageMixin
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
......@@ -59,12 +59,14 @@ class GroupSubscribe(SuccessMessageMixin, PermissionMixin, CreateView):
class GroupUnsubscribe(PermissionMixin, DeleteView):
permission_required = 'subscriptions.delete'
model = Subscription
template_name = 'subscriptions/delete.html'
def get_object(self):
return self.request.user.gestalt.subscriptions.filter(
return self.gestalt.subscriptions.filter(
subscribed_to_type=self.group.content_type, subscribed_to_id=self.group.id)
def get_permission_object(self):
self.gestalt = self.request.user.gestalt if self.request.user.is_authenticated else None
self.group = get_object_or_404(Group, pk=self.kwargs.get('group_pk'))
return self.group
......@@ -72,8 +74,26 @@ class GroupUnsubscribe(PermissionMixin, DeleteView):
return self.group.get_absolute_url()
class GroupUnsubscribeConfirm(PermissionMixin, DeleteView):
pass
class GroupUnsubscribeConfirm(GroupUnsubscribe):
def delete(self, *args, **kwargs):
success(
self.request,
'Dein Abonnement wurde gekündigt. Du erhältst zukünftig keine '
'Benachrichtigungen mehr für diese Gruppe.')
return super().delete(*args, **kwargs)
def get_permission_object(self):
token = get_object_or_404(
PermissionToken, feature_key='group-unsubscribe',
secret_key=self.kwargs.get('secret_key'))
self.gestalt = token.gestalt
self.group = token.target
return self.group
def has_permission(self):
obj = self.get_permission_object()
perms = self.get_permission_required()
return self.gestalt.user.has_perms(perms, obj)
class GroupUnsubscribeRequest(PermissionMixin, FormView):
......
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