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']
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
23 >>> rule.check(mlist, msg, {})
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
35 >>> rule.check(mlist, msg, {})
38 Once the member's moderation flag is set though, the rule matches.
40 >>> member.is_moderated = True
41 >>> rule.check(mlist, msg, {})
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']
55 If the sender is a member of this mailing list, the rule does not match.
57 >>> rule.check(mlist, msg, {})
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
68 >>> rule.check(mlist, msg, {})