summaryrefslogtreecommitdiff
path: root/src/mailman/model
diff options
context:
space:
mode:
authorBarry Warsaw2014-04-14 12:12:39 -0400
committerBarry Warsaw2014-04-14 12:12:39 -0400
commitff6df86000da8fcb055101c5cede36b27cb0480a (patch)
tree6b700bb00766dda02b8742f2ca9ef10c0ba3d2ee /src/mailman/model
parentb4d3a036b5949c6945b13416615cfd356a327ee2 (diff)
parentacc302099df53474e631117351f8116727c1ceb6 (diff)
downloadmailman-ff6df86000da8fcb055101c5cede36b27cb0480a.tar.gz
mailman-ff6df86000da8fcb055101c5cede36b27cb0480a.tar.zst
mailman-ff6df86000da8fcb055101c5cede36b27cb0480a.zip
Aurélien Bompard's import-from-2.1 branch, with cleanup and fixes.
Diffstat (limited to 'src/mailman/model')
-rw-r--r--src/mailman/model/listmanager.py2
-rw-r--r--src/mailman/model/mailinglist.py1
-rw-r--r--src/mailman/model/tests/test_listmanager.py15
3 files changed, 18 insertions, 0 deletions
diff --git a/src/mailman/model/listmanager.py b/src/mailman/model/listmanager.py
index 5e260a6cd..f1c2941e0 100644
--- a/src/mailman/model/listmanager.py
+++ b/src/mailman/model/listmanager.py
@@ -34,6 +34,7 @@ from mailman.interfaces.listmanager import (
IListManager, ListAlreadyExistsError, ListCreatedEvent, ListCreatingEvent,
ListDeletedEvent, ListDeletingEvent)
from mailman.model.mailinglist import MailingList
+from mailman.model.mime import ContentFilter
from mailman.utilities.datetime import now
@@ -79,6 +80,7 @@ class ListManager:
"""See `IListManager`."""
fqdn_listname = mlist.fqdn_listname
notify(ListDeletingEvent(mlist))
+ store.find(ContentFilter, ContentFilter.mailing_list == mlist).remove()
store.remove(mlist)
notify(ListDeletedEvent(fqdn_listname))
diff --git a/src/mailman/model/mailinglist.py b/src/mailman/model/mailinglist.py
index dd7a528c3..f9d8b8488 100644
--- a/src/mailman/model/mailinglist.py
+++ b/src/mailman/model/mailinglist.py
@@ -160,6 +160,7 @@ class MailingList(Model):
max_num_recipients = Int()
member_moderation_notice = Unicode()
mime_is_default_digest = Bool()
+ # FIXME: There should be no moderator_password
moderator_password = RawStr()
newsgroup_moderation = Enum(NewsgroupModeration)
nntp_prefix_subject_too = Bool()
diff --git a/src/mailman/model/tests/test_listmanager.py b/src/mailman/model/tests/test_listmanager.py
index 152d96b9f..5d5cc8395 100644
--- a/src/mailman/model/tests/test_listmanager.py
+++ b/src/mailman/model/tests/test_listmanager.py
@@ -26,6 +26,7 @@ __all__ = [
import unittest
+from storm.locals import Store
from zope.component import getUtility
from mailman.app.lifecycle import create_list
@@ -37,6 +38,7 @@ from mailman.interfaces.messages import IMessageStore
from mailman.interfaces.requests import IListRequests
from mailman.interfaces.subscriptions import ISubscriptionService
from mailman.interfaces.usermanager import IUserManager
+from mailman.model.mime import ContentFilter
from mailman.testing.helpers import (
event_subscribers, specialized_message_from_string)
from mailman.testing.layers import ConfigLayer
@@ -126,6 +128,19 @@ Message-ID: <argon>
saved_message = getUtility(IMessageStore).get_message_by_id('<argon>')
self.assertEqual(saved_message.as_string(), msg.as_string())
+ def test_content_filters_are_deleted_when_mailing_list_is_deleted(self):
+ # When a mailing list with content filters is deleted, the filters
+ # must be deleted first or an IntegrityError will be raised.
+ filter_names = ('filter_types', 'pass_types',
+ 'filter_extensions', 'pass_extensions')
+ for fname in filter_names:
+ setattr(self._ant, fname, ['test-filter-1', 'test-filter-2'])
+ getUtility(IListManager).delete(self._ant)
+ store = Store.of(self._ant)
+ filters = store.find(ContentFilter,
+ ContentFilter.mailing_list == self._ant)
+ self.assertEqual(filters.count(), 0)
+
class TestListCreation(unittest.TestCase):