Révision 09054632
Ajouté par Serghei Mihai il y a plus de 7 ans
corbo/models.py | ||
---|---|---|
1 | 1 |
from datetime import datetime |
2 | 2 |
import logging |
3 |
import urlparse |
|
3 | 4 |
from html2text import HTML2Text |
4 | 5 |
from emails.django import Message |
5 | 6 |
from lxml.etree import HTML as HTMLTree |
... | ... | |
91 | 92 |
continue |
92 | 93 |
unsubscribe_token = signing.dumps({'category': self.announce.category.pk, |
93 | 94 |
'identifier': s.identifier}) |
94 |
unsubscribe_link = reverse('unsubscribe', kwargs={'unsubscription_token': unsubscribe_token}) |
|
95 |
unsubscribe_link = urlparse.urljoin(settings.SITE_BASE_URL, reverse('unsubscribe', |
|
96 |
kwargs={'unsubscription_token': unsubscribe_token})) |
|
95 | 97 |
message = template.render(Context({'unsubscribe_link': unsubscribe_link, |
96 | 98 |
'content': self.announce.text})) |
97 | 99 |
m.html = message |
corbo/settings.py | ||
---|---|---|
138 | 138 |
|
139 | 139 |
MELLON_IDENTITY_PROVIDERS = [] |
140 | 140 |
|
141 |
# default site |
|
142 |
SITE_BASE_URL = 'http://localhost' |
|
143 |
|
|
141 | 144 |
local_settings_file = os.environ.get('CORBO_SETTINGS_FILE', |
142 | 145 |
os.path.join(os.path.dirname(__file__), 'local_settings.py')) |
143 | 146 |
if os.path.exists(local_settings_file): |
tests/test_emailing.py | ||
---|---|---|
1 |
import urlparse |
|
1 | 2 |
import pytest |
2 | 3 |
import json |
3 | 4 |
from uuid import uuid4 |
... | ... | |
11 | 12 |
from django.utils import timezone |
12 | 13 |
from django.core.files.storage import DefaultStorage |
13 | 14 |
from django.core.urlresolvers import reverse |
15 |
from django.conf import settings |
|
14 | 16 |
|
15 | 17 |
from corbo.models import Category, Announce, Subscription, Broadcast |
16 | 18 |
from corbo.models import channel_choices |
... | ... | |
120 | 122 |
assert unsubscription_link in mail.outbox[0].text |
121 | 123 |
mail.outbox = [] |
122 | 124 |
# make sure the uri schema is not in the page |
123 |
resp = app.get(unsubscription_link)
|
|
125 |
resp = app.get(unsubscription_path)
|
|
124 | 126 |
assert scheme not in resp.content |
Formats disponibles : Unified diff
prefix unsubscription link with url read from settings (#12543)