# 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 . """""" 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')