Confirm disabling all notifications (#1845)

This commit is contained in:
julia-luna
2020-11-05 18:40:53 +01:00
committed by GitHub
parent d08c811f3a
commit b51108ab22
3 changed files with 18 additions and 3 deletions

View File

@@ -0,0 +1,13 @@
{% extends "pretixcontrol/auth/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block title %}{% trans "Disable notifications" %}{% endblock %}
{% block content %}
<form action="" method="post" class="form-signin">
{% csrf_token %}
<div class="text-center">
<p>Please confirm that you no longer want to receive notifications for any of your events.</p>
<p><button type="submit" class="btn btn-primary" value="Disable notifications">Disable notifications</button></p>
</div>
</form>
{% endblock %}

View File

@@ -576,7 +576,9 @@ class User2FARegenerateEmergencyView(RecentAuthenticationRequiredMixin, Template
class UserNotificationsDisableView(TemplateView): class UserNotificationsDisableView(TemplateView):
def get(self, request, *args, **kwargs): template_name = 'pretixcontrol/user/notifications_disable.html'
def post(self, request, *args, **kwargs):
user = get_object_or_404(User, notifications_token=kwargs.get('token'), pk=kwargs.get('id')) user = get_object_or_404(User, notifications_token=kwargs.get('token'), pk=kwargs.get('id'))
user.notifications_send = False user.notifications_send = False
user.save() user.save()

View File

@@ -417,13 +417,13 @@ class UserSettingsNotificationsTest(SoupTest):
def test_disable_all_via_link(self): def test_disable_all_via_link(self):
assert self.user.notifications_send assert self.user.notifications_send
self.client.get('/control/settings/notifications/off/{}/{}/'.format(self.user.pk, self.user.notifications_token)) self.client.post('/control/settings/notifications/off/{}/{}/'.format(self.user.pk, self.user.notifications_token))
self.user.refresh_from_db() self.user.refresh_from_db()
assert not self.user.notifications_send assert not self.user.notifications_send
def test_disable_all_via_link_anonymous(self): def test_disable_all_via_link_anonymous(self):
self.client.logout() self.client.logout()
assert self.user.notifications_send assert self.user.notifications_send
self.client.get('/control/settings/notifications/off/{}/{}/'.format(self.user.pk, self.user.notifications_token)) self.client.post('/control/settings/notifications/off/{}/{}/'.format(self.user.pk, self.user.notifications_token))
self.user.refresh_from_db() self.user.refresh_from_db()
assert not self.user.notifications_send assert not self.user.notifications_send