Remove the mailman.interface magic. Use the more specific interface imports.
[mailman.git] / mailman / rules / docs / moderation.txt
blob5e002a850bc3ee1e0c1a38e993908a4f58549813
1 Member moderation
2 =================
4 Each user has a moderation flag.  When set, and the list is set to moderate
5 postings, then only members with a cleared moderation flag will be able to
6 email the list without having those messages be held for approval.  The
7 'moderation' rule determines whether the message should be moderated or not.
9     >>> mlist = config.db.list_manager.create(u'_xtest@example.com')
10     >>> rule = config.rules['moderation']
11     >>> rule.name
12     'moderation'
14 In the simplest case, the sender is not a member of the mailing list, so the
15 moderation rule can't match.
17     >>> msg = message_from_string("""\
18     ... From: aperson@example.org
19     ... To: _xtest@example.com
20     ... Subject: A posted message
21     ...
22     ... """)
23     >>> rule.check(mlist, msg, {})
24     False
26 Let's add the message author as a non-moderated member.
28     >>> user = config.db.user_manager.create_user(
29     ...     u'aperson@example.org', u'Anne Person')
30     >>> address = list(user.addresses)[0]
31     >>> from mailman.interfaces.member import MemberRole
32     >>> member = address.subscribe(mlist, MemberRole.member)
33     >>> member.is_moderated
34     False
35     >>> rule.check(mlist, msg, {})
36     False
38 Once the member's moderation flag is set though, the rule matches.
40     >>> member.is_moderated = True
41     >>> rule.check(mlist, msg, {})
42     True
45 Non-members
46 -----------
48 There is another, related rule for matching non-members, which simply matches
49 if the sender is /not/ a member of the mailing list.
51     >>> rule = config.rules['non-member']
52     >>> rule.name
53     'non-member'
55 If the sender is a member of this mailing list, the rule does not match.
57     >>> rule.check(mlist, msg, {})
58     False
60 But if the sender is not a member of this mailing list, the rule matches.
62     >>> msg = message_from_string("""\
63     ... From: bperson@example.org
64     ... To: _xtest@example.com
65     ... Subject: A posted message
66     ...
67     ... """)
68     >>> rule.check(mlist, msg, {})
69     True