Commit d5139fad authored by Mark Sapiro's avatar Mark Sapiro

Merge branch 'patch-1' into 'master'

Add option to list membership containing only addresses and not display names.

See merge request !656
parents 576407f2 39f5bf70
Pipeline #153652348 passed with stage
in 17 minutes and 24 seconds
......@@ -39,7 +39,8 @@ from zope.component import getUtility
from zope.interface import implementer
def display_members(ctx, mlist, role, regular, digest, nomail, outfp):
def display_members(ctx, mlist, role, regular, digest,
nomail, outfp, email_only):
# Which type of digest recipients should we display?
if digest == 'any':
digest_types = [
......@@ -103,8 +104,11 @@ def display_members(ctx, mlist, role, regular, digest, nomail, outfp):
member = roster.get_member(address.email)
if member.delivery_status not in status_types:
continue
print(formataddr((address.display_name, address.original_email)),
file=outfp)
if email_only:
print(address.original_email, file=outfp)
else:
print(formataddr((address.display_name, address.original_email)),
file=outfp)
@transactional
......@@ -294,6 +298,12 @@ def sync_members(mlist, sync_infp, no_change):
is_flag=True, default=False,
help=_("""\
[output filter] Display only regular delivery members."""))
@click.option(
'--email-only', '-e', 'email_only',
is_flag=True, default=False,
help=("""\
[output filter] Display member addresses only, without the display name.
"""))
@click.option(
'--no-change', '-N', 'no_change',
is_flag=True, default=False,
......@@ -324,7 +334,7 @@ def sync_members(mlist, sync_infp, no_change):
@click.argument('listspec')
@click.pass_context
def members(ctx, add_infp, del_infp, sync_infp, outfp,
role, regular, no_change, digest, nomail, listspec):
role, regular, no_change, digest, nomail, listspec, email_only):
mlist = getUtility(IListManager).get(listspec)
if mlist is None:
ctx.fail(_('No such list: $listspec'))
......@@ -335,7 +345,8 @@ def members(ctx, add_infp, del_infp, sync_infp, outfp,
elif sync_infp is not None:
sync_members(mlist, sync_infp, no_change)
else:
display_members(ctx, mlist, role, regular, digest, nomail, outfp)
display_members(ctx, mlist, role, regular,
digest, nomail, outfp, email_only)
@public
......
......@@ -321,3 +321,11 @@ class TestCLIMembers(unittest.TestCase):
lines = infp.readlines()
self.assertEqual(len(lines), 1)
self.assertEqual(lines[0], '[email protected]\n')
def test_email_only(self):
subscribe(self._mlist, 'Anne')
subscribe(self._mlist, 'Bart')
result = self._command.invoke(members, (
'--email-only', 'ant.example.com'))
self.assertEqual(result.output,
'[email protected]\n[email protected]\n')
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