Abhilash Raj pushed to branch master at GNU Mailman / Mailman Core

Commits:
bf301876 by Abhilash Raj at 2018-06-06T05:19:23Z
Add a private mailing list style.

- - - - -
4942e6c9 by Abhilash Raj at 2018-06-06T05:19:23Z
Merge branch 'globin/mailman-private-style' into 'master'

Add a private mailing list style.

See merge request mailman/mailman!399
- - - - -


6 changed files:

- src/mailman/rest/docs/lists.rst
- src/mailman/rest/tests/test_lists.py
- src/mailman/styles/base.py
- src/mailman/styles/default.py
- src/mailman/styles/docs/styles.rst
- src/mailman/styles/tests/test_styles.py


Changes:

=====================================
src/mailman/rest/docs/lists.rst
=====================================
--- a/src/mailman/rest/docs/lists.rst
+++ b/src/mailman/rest/docs/lists.rst
@@ -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


=====================================
src/mailman/rest/tests/test_lists.py
=====================================
--- a/src/mailman/rest/tests/test_lists.py
+++ b/src/mailman/rest/tests/test_lists.py
@@ -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'
             })


=====================================
src/mailman/styles/base.py
=====================================
--- a/src/mailman/styles/base.py
+++ b/src/mailman/styles/base.py
@@ -193,6 +193,16 @@ class 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."""
 


=====================================
src/mailman/styles/default.py
=====================================
--- a/src/mailman/styles/default.py
+++ b/src/mailman/styles/default.py
@@ -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)


=====================================
src/mailman/styles/docs/styles.rst
=====================================
--- a/src/mailman/styles/docs/styles.rst
+++ b/src/mailman/styles/docs/styles.rst
@@ -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.
 


=====================================
src/mailman/styles/tests/test_styles.py
=====================================
--- a/src/mailman/styles/tests/test_styles.py
+++ b/src/mailman/styles/tests/test_styles.py
@@ -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-l...@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)



View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/b2644bc0204a5ba67857a825df8026c6fe5d2fd9...4942e6c9d85c8e17a06ffd8c2c9df9b59865e772

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/b2644bc0204a5ba67857a825df8026c6fe5d2fd9...4942e6c9d85c8e17a06ffd8c2c9df9b59865e772
You're receiving this email because of your account on gitlab.com.
_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to