summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/database/schema/mm_20120407000000.py24
-rw-r--r--src/mailman/database/schema/sqlite_20120407000000_01.sql6
-rw-r--r--src/mailman/database/tests/test_migrations.py91
-rw-r--r--src/mailman/handlers/docs/rfc-2369.rst6
-rw-r--r--src/mailman/handlers/rfc_2369.py2
-rw-r--r--src/mailman/interfaces/mailinglist.py10
-rw-r--r--src/mailman/model/mailinglist.py2
-rw-r--r--src/mailman/rest/configuration.py2
-rw-r--r--src/mailman/rest/docs/configuration.rst16
-rw-r--r--src/mailman/styles/default.py2
-rw-r--r--src/mailman/testing/testing.cfg6
-rw-r--r--src/mailman/utilities/importer.py5
-rw-r--r--src/mailman/utilities/tests/test_import.py4
13 files changed, 135 insertions, 41 deletions
diff --git a/src/mailman/database/schema/mm_20120407000000.py b/src/mailman/database/schema/mm_20120407000000.py
index 9ed99e225..95b56c939 100644
--- a/src/mailman/database/schema/mm_20120407000000.py
+++ b/src/mailman/database/schema/mm_20120407000000.py
@@ -76,20 +76,26 @@ def upgrade_sqlite(database, store, version, module_path):
database.load_schema(
store, version, 'sqlite_{0}_01.sql'.format(version), module_path)
results = store.execute(
- 'SELECT id, news_prefix_subject_too, news_moderation, '
+ 'SELECT id, include_list_post_header, '
+ 'news_prefix_subject_too, news_moderation, '
'archive, archive_private FROM mailinglist;')
for value in results:
- id, news_prefix, news_moderation, archive, archive_private = value
+ (id, list_post,
+ news_prefix, news_moderation,
+ archive, archive_private) = value
# Figure out what the new archive_policy column value should be.
store.execute(
'UPDATE ml_backup SET '
- ' newsgroup_moderation = {0}, '
- ' nntp_prefix_subject_too = {1}, '
- ' archive_policy = {2} '
- 'WHERE id = {3};'.format(news_moderation,
- news_prefix,
- archive_policy(archive, archive_private),
- id))
+ ' allow_list_posts = {0}, '
+ ' newsgroup_moderation = {1}, '
+ ' nntp_prefix_subject_too = {2}, '
+ ' archive_policy = {3} '
+ 'WHERE id = {4};'.format(
+ list_post,
+ news_moderation,
+ news_prefix,
+ archive_policy(archive, archive_private),
+ id))
store.execute('DROP TABLE mailinglist;')
store.execute('ALTER TABLE ml_backup RENAME TO mailinglist;')
diff --git a/src/mailman/database/schema/sqlite_20120407000000_01.sql b/src/mailman/database/schema/sqlite_20120407000000_01.sql
index 58201fb9b..e5d3a39ff 100644
--- a/src/mailman/database/schema/sqlite_20120407000000_01.sql
+++ b/src/mailman/database/schema/sqlite_20120407000000_01.sql
@@ -10,22 +10,26 @@
-- REM archive
-- REM archive_private
-- REM archive_volume_frequency
+-- REM include_list_post_header
-- REM news_moderation
-- REM news_prefix_subject_too
-- REM nntp_host
--
-- THESE COLUMNS ARE ADDED BY THE PYTHON MIGRATION LAYER:
+-- ADD allow_list_posts
-- ADD archive_policy
-- ADD newsgroup_moderation
-- ADD nntp_prefix_subject_too
+
-- LP: #971013
+-- LP: #967238
CREATE TABLE ml_backup(
id INTEGER NOT NULL,
-- List identity
list_name TEXT,
mail_host TEXT,
- include_list_post_header BOOLEAN,
+ allow_list_posts BOOLEAN,
include_rfc2369_headers BOOLEAN,
-- Attributes not directly modifiable via the web u/i
created_at TIMESTAMP,
diff --git a/src/mailman/database/tests/test_migrations.py b/src/mailman/database/tests/test_migrations.py
index c0ff80f74..6ad648623 100644
--- a/src/mailman/database/tests/test_migrations.py
+++ b/src/mailman/database/tests/test_migrations.py
@@ -21,9 +21,9 @@ from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
- 'TestMigration20120407ArchiveData',
- 'TestMigration20120407Data',
+ 'TestMigration20120407MigratedData',
'TestMigration20120407Schema',
+ 'TestMigration20120407UnchangedData',
]
@@ -38,6 +38,7 @@ from mailman.interfaces.domain import IDomainManager
from mailman.interfaces.archiver import ArchivePolicy
from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.mailinglist import IAcceptableAliasSet
+from mailman.interfaces.nntp import NewsgroupModeration
from mailman.testing.helpers import temporary_db
from mailman.testing.layers import ConfigLayer
@@ -51,6 +52,7 @@ class MigrationTestBase(unittest.TestCase):
table mailinglist:
* news_moderation -> newsgroup_moderation
* news_prefix_subject_too -> nntp_prefix_subject_too
+ * include_list_post_header -> allow_list_posts
* ADD archive_policy
* REMOVE archive
* REMOVE archive_private
@@ -79,7 +81,8 @@ class TestMigration20120407Schema(MigrationTestBase):
self._database.load_migrations('20120406999999')
self._database.store.commit()
# Verify that the database has not yet been migrated.
- for missing in ('archive_policy',
+ for missing in ('allow_list_posts',
+ 'archive_policy',
'nntp_prefix_subject_too'):
self.assertRaises(DatabaseError,
self._database.store.execute,
@@ -88,6 +91,7 @@ class TestMigration20120407Schema(MigrationTestBase):
for present in ('archive',
'archive_private',
'archive_volume_frequency',
+ 'include_list_post_header',
'news_moderation',
'news_prefix_subject_too',
'nntp_host'):
@@ -104,7 +108,8 @@ class TestMigration20120407Schema(MigrationTestBase):
self._database.load_migrations('20120406999999')
self._database.load_migrations('20120407000000')
# Verify that the database has been migrated.
- for present in ('archive_policy',
+ for present in ('allow_list_posts',
+ 'archive_policy',
'nntp_prefix_subject_too'):
# This should not produce an exception. Is there some better test
# that we can perform?
@@ -113,6 +118,7 @@ class TestMigration20120407Schema(MigrationTestBase):
for missing in ('archive',
'archive_private',
'archive_volume_frequency',
+ 'include_list_post_header',
'news_moderation',
'news_prefix_subject_too',
'nntp_host'):
@@ -123,7 +129,7 @@ class TestMigration20120407Schema(MigrationTestBase):
-class TestMigration20120407Data(MigrationTestBase):
+class TestMigration20120407UnchangedData(MigrationTestBase):
"""Test non-migrated data."""
def setUp(self):
@@ -186,7 +192,7 @@ class TestMigration20120407Data(MigrationTestBase):
-class TestMigration20120407ArchiveData(MigrationTestBase):
+class TestMigration20120407MigratedData(MigrationTestBase):
"""Test affected migration data."""
def setUp(self):
@@ -254,3 +260,76 @@ class TestMigration20120407ArchiveData(MigrationTestBase):
with temporary_db(self._database):
mlist = getUtility(IListManager).get('test@example.com')
self.assertEqual(mlist.archive_policy, ArchivePolicy.public)
+
+ def test_news_moderation_none(self):
+ # Test that news_moderation becomes newsgroup_moderation.
+ self._database.store.execute(
+ 'UPDATE mailinglist SET news_moderation = 0 '
+ 'WHERE id = 1;')
+ self._upgrade()
+ with temporary_db(self._database):
+ mlist = getUtility(IListManager).get('test@example.com')
+ self.assertEqual(mlist.newsgroup_moderation,
+ NewsgroupModeration.none)
+
+ def test_news_moderation_open_moderated(self):
+ # Test that news_moderation becomes newsgroup_moderation.
+ self._database.store.execute(
+ 'UPDATE mailinglist SET news_moderation = 1 '
+ 'WHERE id = 1;')
+ self._upgrade()
+ with temporary_db(self._database):
+ mlist = getUtility(IListManager).get('test@example.com')
+ self.assertEqual(mlist.newsgroup_moderation,
+ NewsgroupModeration.open_moderated)
+
+ def test_news_moderation_moderated(self):
+ # Test that news_moderation becomes newsgroup_moderation.
+ self._database.store.execute(
+ 'UPDATE mailinglist SET news_moderation = 2 '
+ 'WHERE id = 1;')
+ self._upgrade()
+ with temporary_db(self._database):
+ mlist = getUtility(IListManager).get('test@example.com')
+ self.assertEqual(mlist.newsgroup_moderation,
+ NewsgroupModeration.moderated)
+
+ def test_nntp_prefix_subject_too_false(self):
+ # Test that news_prefix_subject_too becomes nntp_prefix_subject_too.
+ self._database.store.execute(
+ 'UPDATE mailinglist SET news_prefix_subject_too = {0} '
+ 'WHERE id = 1;'.format(self._database.FALSE))
+ self._upgrade()
+ with temporary_db(self._database):
+ mlist = getUtility(IListManager).get('test@example.com')
+ self.assertFalse(mlist.nntp_prefix_subject_too)
+
+ def test_nntp_prefix_subject_too_true(self):
+ # Test that news_prefix_subject_too becomes nntp_prefix_subject_too.
+ self._database.store.execute(
+ 'UPDATE mailinglist SET news_prefix_subject_too = {0} '
+ 'WHERE id = 1;'.format(self._database.TRUE))
+ self._upgrade()
+ with temporary_db(self._database):
+ mlist = getUtility(IListManager).get('test@example.com')
+ self.assertTrue(mlist.nntp_prefix_subject_too)
+
+ def test_allow_list_posts_false(self):
+ # Test that include_list_post_header -> allow_list_posts.
+ self._database.store.execute(
+ 'UPDATE mailinglist SET include_list_post_header = {0} '
+ 'WHERE id = 1;'.format(self._database.FALSE))
+ self._upgrade()
+ with temporary_db(self._database):
+ mlist = getUtility(IListManager).get('test@example.com')
+ self.assertFalse(mlist.allow_list_posts)
+
+ def test_allow_list_posts_true(self):
+ # Test that include_list_post_header -> allow_list_posts.
+ self._database.store.execute(
+ 'UPDATE mailinglist SET include_list_post_header = {0} '
+ 'WHERE id = 1;'.format(self._database.TRUE))
+ self._upgrade()
+ with temporary_db(self._database):
+ mlist = getUtility(IListManager).get('test@example.com')
+ self.assertTrue(mlist.allow_list_posts)
diff --git a/src/mailman/handlers/docs/rfc-2369.rst b/src/mailman/handlers/docs/rfc-2369.rst
index 875603f88..7eda388c1 100644
--- a/src/mailman/handlers/docs/rfc-2369.rst
+++ b/src/mailman/handlers/docs/rfc-2369.rst
@@ -86,7 +86,7 @@ Discussion lists, to which any subscriber can post, also have a `List-Post`
header which contains the `mailto:` URL used to send messages to the list.
>>> mlist.include_rfc2369_headers = True
- >>> mlist.include_list_post_header = True
+ >>> mlist.allow_list_posts = True
>>> msg = message_from_string("""\
... From: aperson@example.com
...
@@ -108,7 +108,7 @@ Because the general membership cannot post to these mailing lists, the list
owner can set a flag which adds a special `List-Post` header value, according
to RFC 2369.
- >>> mlist.include_list_post_header = False
+ >>> mlist.allow_list_posts = False
>>> msg = message_from_string("""\
... From: aperson@example.com
...
@@ -132,7 +132,7 @@ List-Id header
If the mailing list has a description, then it is included in the ``List-Id``
header.
- >>> mlist.include_list_post_header = True
+ >>> mlist.allow_list_posts = True
>>> mlist.description = 'My test mailing list'
>>> msg = message_from_string("""\
... From: aperson@example.com
diff --git a/src/mailman/handlers/rfc_2369.py b/src/mailman/handlers/rfc_2369.py
index ea7b9e8dc..43eb30acd 100644
--- a/src/mailman/handlers/rfc_2369.py
+++ b/src/mailman/handlers/rfc_2369.py
@@ -78,7 +78,7 @@ def process(mlist, msg, msgdata):
# misnamed. RFC 2369 requires a value of NO if posting is not
# allowed, i.e. for an announce-only list.
list_post = ('<mailto:{0}>'.format(mlist.posting_address)
- if mlist.include_list_post_header
+ if mlist.allow_list_posts
else 'NO')
headers['List-Post'] = list_post
# Add RFC 2369 and 5064 archiving headers, if archiving is enabled.
diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py
index 485fa92bc..5f7c556b1 100644
--- a/src/mailman/interfaces/mailinglist.py
+++ b/src/mailman/interfaces/mailinglist.py
@@ -103,9 +103,13 @@ class IMailingList(Interface):
mailing lists, or in headers, and so forth. It should be as succinct
as you can get it, while still identifying what the list is.""")
- include_list_post_header = Attribute(
- """Flag specifying whether to include the RFC 2369 List-Post header.
- This is usually set to True, except for announce-only lists.""")
+ allow_list_posts = Attribute(
+ """Flag specifying posts to the list are generally allowed.
+
+ This controls the value of the RFC 2369 List-Post header. This is
+ usually set to True, except for announce-only lists. When False, the
+ List-Post is set to NO as per the RFC.
+ """)
include_rfc2369_headers = Attribute(
"""Flag specifying whether to include any RFC 2369 header, including
diff --git a/src/mailman/model/mailinglist.py b/src/mailman/model/mailinglist.py
index 294daa566..fde82f997 100644
--- a/src/mailman/model/mailinglist.py
+++ b/src/mailman/model/mailinglist.py
@@ -80,7 +80,7 @@ class MailingList(Model):
# List identity
list_name = Unicode()
mail_host = Unicode()
- include_list_post_header = Bool()
+ allow_list_posts = Bool()
include_rfc2369_headers = Bool()
advertised = Bool()
anonymous_list = Bool()
diff --git a/src/mailman/rest/configuration.py b/src/mailman/rest/configuration.py
index d6b27cc6c..68a85c061 100644
--- a/src/mailman/rest/configuration.py
+++ b/src/mailman/rest/configuration.py
@@ -183,7 +183,7 @@ ATTRIBUTES = dict(
fqdn_listname=GetterSetter(None),
generic_nonmember_action=GetterSetter(int),
mail_host=GetterSetter(None),
- include_list_post_header=GetterSetter(as_boolean),
+ allow_list_posts=GetterSetter(as_boolean),
include_rfc2369_headers=GetterSetter(as_boolean),
join_address=GetterSetter(None),
last_post_at=GetterSetter(None),
diff --git a/src/mailman/rest/docs/configuration.rst b/src/mailman/rest/docs/configuration.rst
index 676b3426c..8194356e2 100644
--- a/src/mailman/rest/docs/configuration.rst
+++ b/src/mailman/rest/docs/configuration.rst
@@ -20,6 +20,7 @@ All readable attributes for a list are available on a sub-resource.
admin_notify_mchanges: False
administrivia: True
advertised: True
+ allow_list_posts: True
anonymous_list: False
autorespond_owner: none
autorespond_postings: none
@@ -42,7 +43,6 @@ All readable attributes for a list are available on a sub-resource.
fqdn_listname: test-one@example.com
generic_nonmember_action: 1
http_etag: "..."
- include_list_post_header: True
include_rfc2369_headers: True
join_address: test-one-join@example.com
last_post_at: None
@@ -91,7 +91,7 @@ all the writable attributes in one request.
... display_name='Fnords',
... description='This is my mailing list',
... include_rfc2369_headers=False,
- ... include_list_post_header=False,
+ ... allow_list_posts=False,
... digest_size_threshold=10.5,
... posting_pipeline='virgin',
... filter_content=True,
@@ -119,6 +119,7 @@ These values are changed permanently.
admin_notify_mchanges: True
administrivia: False
advertised: False
+ allow_list_posts: False
anonymous_list: True
autorespond_owner: respond_and_discard
autorespond_postings: respond_and_continue
@@ -139,7 +140,6 @@ These values are changed permanently.
display_name: Fnords
filter_content: True
...
- include_list_post_header: False
include_rfc2369_headers: False
...
posting_pipeline: virgin
@@ -171,7 +171,7 @@ must be included. It is an error to leave one or more out...
... display_name='Fnords',
... description='This is my mailing list',
... include_rfc2369_headers=False,
- ... include_list_post_header=False,
+ ... allow_list_posts=False,
... digest_size_threshold=10.5,
... posting_pipeline='virgin',
... filter_content=True,
@@ -211,7 +211,7 @@ must be included. It is an error to leave one or more out...
... display_name='Fnords',
... description='This is my mailing list',
... include_rfc2369_headers=False,
- ... include_list_post_header=False,
+ ... allow_list_posts=False,
... digest_size_threshold=10.5,
... posting_pipeline='virgin',
... filter_content=True,
@@ -244,7 +244,7 @@ It is also an error to spell an attribute value incorrectly...
... display_name='Fnords',
... description='This is my mailing list',
... include_rfc2369_headers=False,
- ... include_list_post_header=False,
+ ... allow_list_posts=False,
... digest_size_threshold=10.5,
... posting_pipeline='virgin',
... filter_content=True,
@@ -276,7 +276,7 @@ It is also an error to spell an attribute value incorrectly...
... display_name='Fnords',
... description='This is my mailing list',
... include_rfc2369_headers=False,
- ... include_list_post_header=False,
+ ... allow_list_posts=False,
... digest_size_threshold=10.5,
... posting_pipeline='dummy',
... filter_content=True,
@@ -308,7 +308,7 @@ It is also an error to spell an attribute value incorrectly...
... display_name='Fnords',
... description='This is my mailing list',
... include_rfc2369_headers=False,
- ... include_list_post_header=False,
+ ... allow_list_posts=False,
... digest_size_threshold=10.5,
... posting_pipeline='virgin',
... filter_content=True,
diff --git a/src/mailman/styles/default.py b/src/mailman/styles/default.py
index 6108831b7..21da19aa5 100644
--- a/src/mailman/styles/default.py
+++ b/src/mailman/styles/default.py
@@ -56,7 +56,7 @@ class DefaultStyle:
mlist.display_name = mlist.list_name.capitalize()
mlist.list_id = '{0.list_name}.{0.mail_host}'.format(mlist)
mlist.include_rfc2369_headers = True
- mlist.include_list_post_header = True
+ mlist.allow_list_posts = True
# Most of these were ripped from the old MailList.InitVars() method.
mlist.volume = 1
mlist.post_id = 1
diff --git a/src/mailman/testing/testing.cfg b/src/mailman/testing/testing.cfg
index 0be01298b..141d74a8f 100644
--- a/src/mailman/testing/testing.cfg
+++ b/src/mailman/testing/testing.cfg
@@ -18,9 +18,9 @@
# A testing configuration.
# For testing against PostgreSQL.
-[database]
-class: mailman.database.postgresql.PostgreSQLDatabase
-url: postgres://barry:barry@localhost/mailman
+# [database]
+# class: mailman.database.postgresql.PostgreSQLDatabase
+# url: postgres://barry:barry@localhost/mailman
[mailman]
site_owner: noreply@example.com
diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py
index 7c562e331..6cdba0de3 100644
--- a/src/mailman/utilities/importer.py
+++ b/src/mailman/utilities/importer.py
@@ -17,7 +17,7 @@
"""Importer routines."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -56,6 +56,7 @@ TYPES = dict(
# Attribute names in Mailman 2 which are renamed in Mailman 3.
NAME_MAPPINGS = dict(
host_name='mail_host',
+ include_list_post_header='allow_list_posts',
real_name='display_name',
)
@@ -85,5 +86,5 @@ def import_config_pck(mlist, config_dict):
try:
setattr(mlist, key, value)
except TypeError:
- print >> sys.stderr, 'Type conversion error:', key
+ print('Type conversion error:', key, file=sys.stderr)
raise
diff --git a/src/mailman/utilities/tests/test_import.py b/src/mailman/utilities/tests/test_import.py
index 58a51e61b..6013649f7 100644
--- a/src/mailman/utilities/tests/test_import.py
+++ b/src/mailman/utilities/tests/test_import.py
@@ -62,8 +62,8 @@ class TestBasicImport(unittest.TestCase):
self.assertEqual(self._mlist.mail_host, 'heresy.example.org')
def test_rfc2369_headers(self):
- self._mlist.include_list_post_header = False
+ self._mlist.allow_list_posts = False
self._mlist.include_rfc2369_headers = False
self._import()
- self.assertTrue(self._mlist.include_list_post_header)
+ self.assertTrue(self._mlist.allow_list_posts)
self.assertTrue(self._mlist.include_rfc2369_headers)