diff options
Diffstat (limited to 'src/mailman/model')
| -rw-r--r-- | src/mailman/model/mailinglist.py | 3 | ||||
| -rw-r--r-- | src/mailman/model/roster.py | 4 | ||||
| -rw-r--r-- | src/mailman/model/workflowstate.py | 66 |
3 files changed, 69 insertions, 4 deletions
diff --git a/src/mailman/model/mailinglist.py b/src/mailman/model/mailinglist.py index cef272437..f04c534e1 100644 --- a/src/mailman/model/mailinglist.py +++ b/src/mailman/model/mailinglist.py @@ -38,7 +38,7 @@ from mailman.interfaces.domain import IDomainManager from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.mailinglist import ( IAcceptableAlias, IAcceptableAliasSet, IListArchiver, IListArchiverSet, - IMailingList, Personalization, ReplyToMunging) + IMailingList, Personalization, ReplyToMunging, SubscriptionPolicy) from mailman.interfaces.member import ( AlreadySubscribedError, MemberRole, MissingPreferredAddressError, SubscriptionEvent) @@ -183,6 +183,7 @@ class MailingList(Model): send_goodbye_message = Column(Boolean) send_welcome_message = Column(Boolean) subject_prefix = Column(Unicode) + subscription_policy = Column(Enum(SubscriptionPolicy)) topics = Column(PickleType) topics_bodylines_limit = Column(Integer) topics_enabled = Column(Boolean) diff --git a/src/mailman/model/roster.py b/src/mailman/model/roster.py index 91211c665..ef24d896b 100644 --- a/src/mailman/model/roster.py +++ b/src/mailman/model/roster.py @@ -99,9 +99,7 @@ class AbstractRoster: @dbconnection def get_member(self, store, address): """See `IRoster`.""" - results = store.query(Member).filter( - Member.list_id == self._mlist.list_id, - Member.role == self.role, + results = self._query().filter( Address.email == address, Member.address_id == Address.id) if results.count() == 0: diff --git a/src/mailman/model/workflowstate.py b/src/mailman/model/workflowstate.py new file mode 100644 index 000000000..229a2240b --- /dev/null +++ b/src/mailman/model/workflowstate.py @@ -0,0 +1,66 @@ +# Copyright (C) 2007-2015 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/>. + +"""Model for workflow states.""" + +__all__ = [ + 'WorkflowState', + 'WorkflowStateManager', + ] + + +from mailman.database.model import Model +from mailman.database.transaction import dbconnection +from mailman.interfaces.workflowstate import ( + IWorkflowState, IWorkflowStateManager) +from sqlalchemy import Column, Unicode +from zope.interface import implementer + + + +@implementer(IWorkflowState) +class WorkflowState(Model): + """Workflow states.""" + + __tablename__ = 'workflowstate' + + name = Column(Unicode, primary_key=True) + key = Column(Unicode, primary_key=True) + step = Column(Unicode) + data = Column(Unicode) + + + +@implementer(IWorkflowStateManager) +class WorkflowStateManager: + """See `IWorkflowStateManager`.""" + + @dbconnection + def save(self, store, name, key, step=None, data=None): + """See `IWorkflowStateManager`.""" + state = store.query(WorkflowState).get((name, key)) + if state is None: + state = store.add(WorkflowState( + name=name, key=key, step=step, data=data)) + else: + state.step = step + state.data = data + + @dbconnection + def restore(self, store, name, key): + """See `IWorkflowStateManager`.""" + return store.query(WorkflowState).get((name, key)) |
