0001-don-t-show-identifier-s-scheme-on-unsubscription-pag.patch
| corbo/models.py | ||
|---|---|---|
|
uuid = models.CharField(_('User identifier'), max_length=128, blank=True)
|
||
|
identifier = models.CharField(_('identifier'), max_length=128, blank=True,
|
||
|
help_text=_('ex.: mailto, homepage, ...'))
|
||
|
def get_identifier_display(self):
|
||
|
try:
|
||
|
scheme, identifier = self.identifier.split(':')
|
||
|
return identifier
|
||
|
except ValueError:
|
||
|
return self.identifier
|
||
|
class Meta:
|
||
|
unique_together = ('category', 'identifier', 'uuid')
|
||
| corbo/templates/corbo/subscription_confirm_delete.html | ||
|---|---|---|
|
{% block content %}
|
||
|
<div class="unsubscription">
|
||
|
{% blocktrans with object.category as category and object.identifier as identifier %}
|
||
|
{% blocktrans with object.category as category and object.get_identifier_display as identifier %}
|
||
|
Are you sure you want to unsubscribe {{ identifier }} from "{{ category }}"?
|
||
|
{% endblocktrans %}
|
||
|
<form method='POST'>
|
||
| corbo/views.py | ||
|---|---|---|
|
data = signing.loads(self.kwargs['unsubscription_token'])
|
||
|
try:
|
||
|
return models.Subscription.objects.get(category__pk=data['category'],
|
||
|
identifier=data['identifier'])
|
||
|
identifier=data['identifier'])
|
||
|
except models.Subscription.DoesNotExist:
|
||
|
raise Http404
|
||
| tests/test_emailing.py | ||
|---|---|---|
|
def test_unsubscription_link(app, categories, announces):
|
||
|
for category in categories:
|
||
|
uuid = uuid4()
|
||
|
email = '%s@example.net' % uuid
|
||
|
scheme = 'mailto:'
|
||
|
uri = scheme + '%s@example.net' % uuid
|
||
|
s = Subscription.objects.create(category=category,
|
||
|
identifier=email,
|
||
|
identifier=uri,
|
||
|
uuid=str(uuid))
|
||
|
for announce in announces:
|
||
|
if announce.category != category:
|
||
| ... | ... | |
|
assert broadcast.result
|
||
|
assert mail.outbox
|
||
|
signature = signing.dumps({'category': announce.category.pk,
|
||
|
'identifier': email})
|
||
|
'identifier': uri})
|
||
|
unsubscription_link = reverse('unsubscribe', kwargs={'unsubscription_token': signature})
|
||
|
assert mail.outbox[0].subject == announce.title
|
||
|
assert unsubscription_link in mail.outbox[0].html
|
||
|
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)
|
||
|
assert scheme not in resp.content
|
||