Project

General

Profile

« Previous | Next » 

Revision 09054632

Added by Serghei Mihai over 9 years ago

prefix unsubscription link with url read from settings (#12543)

View differences:

corbo/models.py
from datetime import datetime
import logging
import urlparse
from html2text import HTML2Text
from emails.django import Message
from lxml.etree import HTML as HTMLTree
......
continue
unsubscribe_token = signing.dumps({'category': self.announce.category.pk,
'identifier': s.identifier})
unsubscribe_link = reverse('unsubscribe', kwargs={'unsubscription_token': unsubscribe_token})
unsubscribe_link = urlparse.urljoin(settings.SITE_BASE_URL, reverse('unsubscribe',
kwargs={'unsubscription_token': unsubscribe_token}))
message = template.render(Context({'unsubscribe_link': unsubscribe_link,
'content': self.announce.text}))
m.html = message
corbo/settings.py
MELLON_IDENTITY_PROVIDERS = []
# default site
SITE_BASE_URL = 'http://localhost'
local_settings_file = os.environ.get('CORBO_SETTINGS_FILE',
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
if os.path.exists(local_settings_file):
tests/test_emailing.py
import urlparse
import pytest
import json
from uuid import uuid4
......
from django.utils import timezone
from django.core.files.storage import DefaultStorage
from django.core.urlresolvers import reverse
from django.conf import settings
from corbo.models import Category, Announce, Subscription, Broadcast
from corbo.models import channel_choices
......
assert unsubscription_link in mail.outbox[0].text
mail.outbox = []
# make sure the uri schema is not in the page
resp = app.get(unsubscription_link)
resp = app.get(unsubscription_path)
assert scheme not in resp.content

Also available in: Unified diff