Commit 3bcfdc47 authored by Florian Fuchs's avatar Florian Fuchs

Changes related to the subscription policy additions in the mailman core package:

    * Subscribing to lists now allows to set the pre_verfified, pre_confirmed and pre_approved flags.
    * Disposal of subscription requests has been added. 
parent 596f0df1
......@@ -2,13 +2,14 @@
NEWS for mailman.client
=======================
1.0.0b1 (2015-xx-xx)
====================
1.0.0 (2015-xx-xx)
==================
* Port to Python 3.4.
* Run test suite with `tox`.
* Use vcrpy for HTTP testing.
* Add list archiver access.
* Add subscription moderation
1.0.0a1 (2014-03-15)
......
......@@ -425,7 +425,6 @@ class _List:
@property
def requests(self):
"""Return a list of dicts with subscription requests."""
response, content = self._connection.call(
'lists/{0}/requests'.format(self.fqdn_listname), None, 'GET')
if 'entries' not in content:
......@@ -434,17 +433,21 @@ class _List:
entries = []
for entry in content['entries']:
request = dict(email=entry['email'],
address=entry['email'], # Deprecated.
delivery_mode=entry['delivery_mode'],
display_name=entry['display_name'],
language=entry['language'],
password=entry['password'],
request_id=entry['request_id'],
request_date=entry['when'],
type=entry['type'])
token=entry['token'],
token_owner=entry['token_owner'],
list_id=entry['list_id'],
request_date=entry['when'])
entries.append(request)
return entries
def manage_request(self, token, action):
"""
accept|reject|discard|defer a subscription request.
"""
response, content = self._connection.call(
'lists/{0}/requests/{1}'.format(self.list_id, token),
{'action': action})
@property
def archivers(self):
"""
......
......@@ -696,10 +696,75 @@ Subscription requests can be accessed through the list object's
>>> print(confirm_first.settings['subscription_policy'])
moderate
Initially there are no requests:
Initially there are no requests, so let's to subscribe someone to the
list. We'll get a token back.
>>> test_one.requests
>>> confirm_first.requests
[]
>>> data = confirm_first.subscribe('groucho@example.com',
... pre_verified=True,
... pre_confirmed=True)
>>> print(data['token_owner'])
moderator
Now the request shows up in the list of requests:
>>> import time; time.sleep(5)
>>> len(confirm_first.requests)
1
>>> request_1 = confirm_first.requests[0]
>>> print(request_1['email'])
groucho@example.com
>>> print (request_1['token'] is not None)
True
>>> print(request_1['token_owner'])
moderator
>>> print(request_1['request_date'] is not None)
True
>>> print(request_1['list_id'])
confirm-first.example.com
Subscription requests can be accepted, deferred, rejected or
discarded using the request token.
>>> data = confirm_first.subscribe('harpo@example.com',
... pre_verified=True,
... pre_confirmed=True)
>>> data = confirm_first.subscribe('zeppo@example.com',
... pre_verified=True,
... pre_confirmed=True)
>>> len(confirm_first.requests)
3
Let's accept Groucho:
>>> confirm_first.manage_request(request_1['token'], 'accept')
>>> len(confirm_first.requests)
2
>>> request_2 = confirm_first.requests[0]
>>> print(request_2['email'])
harpo@example.com
>>> request_3 = confirm_first.requests[1]
>>> print(request_3['email'])
zeppo@example.com
Let's reject Harpo:
>>> confirm_first.manage_request(request_2['token'], 'reject')
>>> len(confirm_first.requests)
1
Let's discard Zeppo's request:
>>> confirm_first.manage_request(request_3['token'], 'discard')
>>> len(confirm_first.requests)
0
Message Moderation
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment