Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNU Mailman
Mailman Core
Commits
bf301876
Commit
bf301876
authored
Jun 06, 2018
by
Abhilash Raj
Browse files
Add a private mailing list style.
parent
b2644bc0
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/mailman/rest/docs/lists.rst
View file @
bf301876
...
...
@@ -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
View file @
bf301876
...
...
@@ -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
View file @
bf301876
...
...
@@ -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."""
...
...
src/mailman/styles/default.py
View file @
bf301876
...
...
@@ -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
View file @
bf301876
...
...
@@ -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
View file @
bf301876
...
...
@@ -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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment