Commit bf301876 authored by Abhilash Raj's avatar Abhilash Raj
Browse files

Add a private mailing list style.

parent b2644bc0
......@@ -256,6 +256,7 @@ available, and which is the default style.
... print('{}: {}'.format(style['name'], style['description']))
legacy-announce: Announce only mailing list style.
legacy-default: Ordinary discussion mailing list style.
private-default: Discussion mailing list style with private archives.
When creating a list, if we don't specify a style to apply, the default style
is used. However, we can provide a style name in the POST data to choose a
......
......@@ -443,12 +443,17 @@ class TestListStyles(unittest.TestCase):
# Remove the variable data.
json.pop('http_etag')
self.assertEqual(json, {
'style_names': ['legacy-announce', 'legacy-default'],
'style_names': [
'legacy-announce', 'legacy-default', 'private-default'
],
'styles': [
{'name': 'legacy-announce',
'description': 'Announce only mailing list style.'},
{'name': 'legacy-default',
'description': 'Ordinary discussion mailing list style.'}
'description': 'Ordinary discussion mailing list style.'},
{'name': 'private-default',
'description': 'Discussion mailing list style with ' +
'private archives.'},
],
'default': 'legacy-default'
})
......
......@@ -192,6 +192,16 @@ class Public:
mlist.archive_policy = ArchivePolicy.public
@public
class Private:
"""Settings for private mailing lists."""
def apply(self, mailing_list):
mlist = mailing_list
mlist.advertised = False
mlist.archive_policy = ArchivePolicy.private
@public
class Announcement:
"""Settings for announce-only lists."""
......
......@@ -21,7 +21,7 @@ from mailman.core.i18n import _
from mailman.interfaces.styles import IStyle
from mailman.styles.base import (
Announcement, BasicOperation, Bounces, Discussion, Identity, Moderation,
Public)
Private, Public)
from public import public
from zope.interface import implementer
......@@ -64,3 +64,23 @@ class LegacyAnnounceOnly(
Public.apply(self, mailing_list)
Announcement.apply(self, mailing_list)
Moderation.apply(self, mailing_list)
@public
@implementer(IStyle)
class PrivateDefaultStyle(
Identity, BasicOperation, Bounces, Private, Discussion, Moderation):
"""Style for mailing-lists with private archives."""
name = 'private-default'
description = _('Discussion mailing list style with private archives.')
def apply(self, mailing_list):
"""See `IStyle`."""
Identity.apply(self, mailing_list)
BasicOperation.apply(self, mailing_list)
Bounces.apply(self, mailing_list)
Private.apply(self, mailing_list)
Discussion.apply(self, mailing_list)
Moderation.apply(self, mailing_list)
......@@ -23,6 +23,7 @@ To start with, there are a few legacy styles.
... print(style.name)
legacy-announce
legacy-default
private-default
When you create a mailing list through the low-level `IListManager` API, no
style is applied.
......@@ -65,6 +66,7 @@ All registered styles are returned in alphabetical order by style name.
a-test-style
legacy-announce
legacy-default
private-default
You can also ask the style manager for the style, by name.
......@@ -83,6 +85,7 @@ You can unregister a style, making it unavailable in the future.
... print(style.name)
legacy-announce
legacy-default
private-default
Asking for a missing style returns None.
......
......@@ -19,6 +19,8 @@
import unittest
from mailman.app.lifecycle import create_list
from mailman.interfaces.archiver import ArchivePolicy
from mailman.interfaces.styles import (
DuplicateStyleError, IStyle, IStyleManager)
from mailman.testing.layers import ConfigLayer
......@@ -62,3 +64,18 @@ class TestStyle(unittest.TestCase):
# You cannot unregister a style that hasn't yet been registered.
self.assertRaises(KeyError,
self.manager.unregister, DummyStyle())
class TestPrivateDefaultStyle(unittest.TestCase):
"""Test PrivateDefaultStyle."""
layer = ConfigLayer
def setUp(self):
self.mlist = create_list('test-list@example.com')
self.manager = getUtility(IStyleManager)
def test_private_default(self):
self.manager.get('private-default').apply(self.mlist)
self.assertEqual(self.mlist.advertised, False)
self.assertEqual(self.mlist.archive_policy, ArchivePolicy.private)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment