X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/e852900e42eb0bde98daf7070d84816e44c3308e..2c101e78aee8cd3ccf3f24a0ecaa22fa77593c5c:/src/messaging/views.py?ds=sidebyside
diff --git a/src/messaging/views.py b/src/messaging/views.py
index 6ea1a4098..b4dbc2693 100644
--- a/src/messaging/views.py
+++ b/src/messaging/views.py
@@ -2,17 +2,16 @@ import json
from django.http import JsonResponse
from django.urls import reverse
from django.shortcuts import render
-from django.utils.translation import ugettext as _
from django.views.decorators import cache
-from django.views.generic import UpdateView
+from django.views.generic import DetailView, UpdateView
from . import models
-from .states import states
+from .states import Level, states
def describe(value):
if hasattr(value, '_meta'):
meta = value._meta
- return _('''a %(verbose_name)s object.''') % {
+ return '''objekt typu %(verbose_name)s.''' % {
'docs_url': reverse('django-admindocs-models-detail', args=(meta.app_label, meta.model_name)),
'verbose_name': meta.verbose_name,
}
@@ -33,7 +32,7 @@ def state_info(request, slug):
"contact": contact,
}
ctx.update(state(test=True).get_context(contact))
- help_text = '%s:
' % _('Context')
+ help_text = 'Kontekst:
'
for k, v in ctx.items():
help_text += '
{{ %s }}
â %s
' % (k, describe(v))
@@ -46,5 +45,19 @@ class OptOutView(UpdateView):
model = models.Contact
slug_url_kwarg = 'key'
slug_field = 'key'
- fields = ['level']
+ fields = []
+
+ def get_success_url(self):
+ return reverse('messaging_optout_ok', args=[self.object.key])
+
+ def form_valid(self, form):
+ self.object.ascend(Level.OPT_OUT)
+ return super().form_valid(form)
+
+
+class OptOutOkView(DetailView):
+ model = models.Contact
+ slug_url_kwarg = 'key'
+ slug_field = 'key'
+