Révision 6a3e75ef
Ajouté par Serghei Mihai (congés, retour 15/05) il y a presque 8 ans
corbo/views.py | ||
---|---|---|
1 | 1 |
from datetime import datetime |
2 | 2 |
|
3 | 3 |
from django.conf import settings |
4 |
from django.core import signing |
|
4 | 5 |
from django.core.urlresolvers import reverse |
5 | 6 |
from django.views.generic import CreateView, UpdateView, DeleteView, \ |
6 | 7 |
ListView, TemplateView |
7 | 8 |
from django.contrib.syndication.views import Feed |
8 | 9 |
from django.utils.feedgenerator import Atom1Feed |
9 | 10 |
from django.utils.http import urlencode |
11 |
from django.http import Http404 |
|
10 | 12 |
|
11 | 13 |
import models |
12 | 14 |
from .forms import AnnounceForm, CategoryForm |
... | ... | |
79 | 81 |
delete_category = CategoryDeleteView.as_view() |
80 | 82 |
|
81 | 83 |
|
84 |
class UnsubscribeView(DeleteView): |
|
85 |
model = models.Subscription |
|
86 |
|
|
87 |
def get_object(self, queryset=None): |
|
88 |
data = signing.loads(self.kwargs['unsubscription_token']) |
|
89 |
try: |
|
90 |
return models.Subscription.objects.get(category__pk=data['category'], |
|
91 |
identifier=data['identifier']) |
|
92 |
except models.Subscription.DoesNotExist: |
|
93 |
raise Http404 |
|
94 |
|
|
95 |
def get_success_url(self): |
|
96 |
return reverse('unsubscription_done') |
|
97 |
|
|
98 |
unsubscribe = UnsubscribeView.as_view() |
|
99 |
|
|
100 |
|
|
101 |
class UnsubscriptionDoneView(TemplateView): |
|
102 |
template_name='corbo/unsubscription_done.html' |
|
103 |
|
|
104 |
unsubscription_done = UnsubscriptionDoneView.as_view() |
|
105 |
|
|
106 |
|
|
82 | 107 |
class ManageView(ListView): |
83 | 108 |
paginate_by = settings.ANNOUNCES_PER_PAGE |
84 | 109 |
template_name = 'corbo/manage.html' |
Formats disponibles : Unified diff
unsubscribe link (#10795)