Cleanup.
[mailman.git] / src / mailman / rules / docs / moderation.txt
blobb268e9d4aa7ea397258cca66a3b69ab1213b7620
1 =================
2 Member moderation
3 =================
5 Each user has a moderation flag.  When set, and the list is set to moderate
6 postings, then only members with a cleared moderation flag will be able to
7 email the list without having those messages be held for approval.  The
8 'moderation' rule determines whether the message should be moderated or not.
10     >>> mlist = create_list('_xtest@example.com')
11     >>> rule = config.rules['moderation']
12     >>> print rule.name
13     moderation
15 In the simplest case, the sender is not a member of the mailing list, so the
16 moderation rule can't match.
18     >>> msg = message_from_string("""\
19     ... From: aperson@example.org
20     ... To: _xtest@example.com
21     ... Subject: A posted message
22     ...
23     ... """)
24     >>> rule.check(mlist, msg, {})
25     False
27 Let's add the message author as a non-moderated member.
29     >>> from mailman.interfaces.usermanager import IUserManager
30     >>> from zope.component import getUtility
31     >>> user = getUtility(IUserManager).create_user(
32     ...     'aperson@example.org', 'Anne Person')
34     >>> address = list(user.addresses)[0]
35     >>> from mailman.interfaces.member import MemberRole
36     >>> member = address.subscribe(mlist, MemberRole.member)
37     >>> member.is_moderated
38     False
39     >>> rule.check(mlist, msg, {})
40     False
42 Once the member's moderation flag is set though, the rule matches.
44     >>> member.is_moderated = True
45     >>> rule.check(mlist, msg, {})
46     True
49 Non-members
50 ===========
52 There is another, related rule for matching non-members, which simply matches
53 if the sender is /not/ a member of the mailing list.
55     >>> rule = config.rules['non-member']
56     >>> print rule.name
57     non-member
59 If the sender is a member of this mailing list, the rule does not match.
61     >>> rule.check(mlist, msg, {})
62     False
64 But if the sender is not a member of this mailing list, the rule matches.
66     >>> msg = message_from_string("""\
67     ... From: bperson@example.org
68     ... To: _xtest@example.com
69     ... Subject: A posted message
70     ...
71     ... """)
72     >>> rule.check(mlist, msg, {})
73     True