1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
# Copyright (C) 2015-2017 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
""""""
from mailman.core.i18n import _
from mailman.interfaces.workflows import ISubscriptionWorkflow
from mailman.workflows.common import (ConfirmationMixin, ModerationMixin,
SubscriptionBase, VerificationMixin)
from public import public
from zope.interface import implementer
@public
@implementer(ISubscriptionWorkflow)
class OpenSubscriptionPolicy(SubscriptionBase, VerificationMixin):
""""""
name = 'sub-policy-open'
description = _('An open subscription policy, only requires verification.')
initial_state = 'prepare'
save_attributes = (
'verified',
'address_key',
'subscriber_key',
'user_key',
'token_owner_key',
)
def __init__(self, mlist, subscriber=None, *,
pre_verified=False):
"""
:param mlist:
:param subscriber: The user or address to subscribe.
:type subscriber: ``IUser`` or ``IAddress``
:param pre_verified: A flag indicating whether the subscriber's email
address should be considered pre-verified. Normally a never
before seen email address must be verified by mail-back
confirmation. Setting this flag to True automatically verifies
such addresses without the mail-back. (A confirmation message may
still be sent under other conditions.)
:type pre_verified: bool
"""
SubscriptionBase.__init__(self, mlist, subscriber)
VerificationMixin.__init__(self, pre_verified=pre_verified)
def _step_prepare(self):
self.push('do_subscription')
self.push('verification_checks')
self.push('sanity_checks')
@public
@implementer(ISubscriptionWorkflow)
class ConfirmSubscriptionPolicy(SubscriptionBase, ConfirmationMixin,
VerificationMixin):
""""""
name = 'sub-policy-confirm'
description = _('An subscription policy that requires confirmation.')
initial_state = 'prepare'
save_attributes = (
'verified',
'confirmed',
'address_key',
'subscriber_key',
'user_key',
'token_owner_key',
)
def __init__(self, mlist, subscriber=None, *,
pre_verified=False, pre_confirmed=False):
"""
:param mlist:
:param subscriber: The user or address to subscribe.
:type subscriber: ``IUser`` or ``IAddress``
:param pre_verified: A flag indicating whether the subscriber's email
address should be considered pre-verified. Normally a never
before seen email address must be verified by mail-back
confirmation. Setting this flag to True automatically verifies
such addresses without the mail-back. (A confirmation message may
still be sent under other conditions.)
:type pre_verified: bool
:param pre_confirmed: A flag indicating whether, when required by the
subscription policy, a subscription request should be considered
pre-confirmed. Normally in such cases, a mail-back confirmation
message is sent to the subscriber, which must be positively
acknowledged by some manner. Setting this flag to True
automatically confirms the subscription request. (A confirmation
message may still be sent under other conditions.)
:type pre_confirmed: bool
"""
SubscriptionBase.__init__(self, mlist, subscriber)
VerificationMixin.__init__(self, pre_verified=pre_verified)
ConfirmationMixin.__init__(self, pre_confirmed=pre_confirmed)
def _step_prepare(self):
self.push('do_subscription')
self.push('confirmation_checks')
self.push('verification_checks')
self.push('sanity_checks')
@public
@implementer(ISubscriptionWorkflow)
class ModerationSubscriptionPolicy(SubscriptionBase, ModerationMixin,
VerificationMixin):
""""""
name = 'sub-policy-moderate'
description = _('A subscription policy that requires moderation.')
initial_state = 'prepare'
save_attributes = (
'approved',
'verified',
'address_key',
'subscriber_key',
'user_key',
'token_owner_key',
)
def __init__(self, mlist, subscriber=None, *,
pre_verified=False, pre_approved=False):
"""
:param mlist:
:param subscriber: The user or address to subscribe.
:type subscriber: ``IUser`` or ``IAddress``
:param pre_verified: A flag indicating whether the subscriber's email
address should be considered pre-verified. Normally a never
before seen email address must be verified by mail-back
confirmation. Setting this flag to True automatically verifies
such addresses without the mail-back. (A confirmation message may
still be sent under other conditions.)
:type pre_verified: bool
:param pre_approved: A flag indicating whether, when required by the
subscription policy, a subscription request should be considered
pre-approved. Normally in such cases, the list administrator is
notified that an approval is necessary, which must be positively
acknowledged in some manner. Setting this flag to True
automatically approves the subscription request.
:type pre_approved: bool
"""
SubscriptionBase.__init__(self, mlist, subscriber)
VerificationMixin.__init__(self, pre_verified=pre_verified)
ModerationMixin.__init__(self, pre_approved=pre_approved)
def _step_prepare(self):
self.push('do_subscription')
self.push('moderation_checks')
self.push('verification_checks')
self.push('sanity_checks')
@public
@implementer(ISubscriptionWorkflow)
class ConfirmModerationSubscriptionPolicy(SubscriptionBase, ConfirmationMixin,
ModerationMixin, VerificationMixin):
""""""
name = 'sub-policy-confirm-moderate'
description = _(
'A subscription policy that requires moderation after confirmation.')
initial_state = 'prepare'
save_attributes = (
'approved',
'confirmed',
'verified',
'address_key',
'subscriber_key',
'user_key',
'token_owner_key',
)
def __init__(self, mlist, subscriber=None, *,
pre_verified=False, pre_confirmed=False, pre_approved=False):
"""
:param mlist:
:param subscriber: The user or address to subscribe.
:type subscriber: ``IUser`` or ``IAddress``
:param pre_verified: A flag indicating whether the subscriber's email
address should be considered pre-verified. Normally a never
before seen email address must be verified by mail-back
confirmation. Setting this flag to True automatically verifies
such addresses without the mail-back. (A confirmation message may
still be sent under other conditions.)
:type pre_verified: bool
:param pre_confirmed: A flag indicating whether, when required by the
subscription policy, a subscription request should be considered
pre-confirmed. Normally in such cases, a mail-back confirmation
message is sent to the subscriber, which must be positively
acknowledged by some manner. Setting this flag to True
automatically confirms the subscription request. (A confirmation
message may still be sent under other conditions.)
:type pre_confirmed: bool
:param pre_approved: A flag indicating whether, when required by the
subscription policy, a subscription request should be considered
pre-approved. Normally in such cases, the list administrator is
notified that an approval is necessary, which must be positively
acknowledged in some manner. Setting this flag to True
automatically approves the subscription request.
:type pre_approved: bool
"""
SubscriptionBase.__init__(self, mlist, subscriber)
VerificationMixin.__init__(self, pre_verified=pre_verified)
ConfirmationMixin.__init__(self, pre_confirmed=pre_confirmed)
ModerationMixin.__init__(self, pre_approved=pre_approved)
def _step_prepare(self):
self.push('do_subscription')
self.push('moderation_checks')
self.push('confirmation_checks')
self.push('verification_checks')
self.push('sanity_checks')
|