Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits:
3a134d55 by Mark Sapiro at 2019-05-08T13:57:43Z
Correct import of *_these_nonmembers action for nonmembers following a member.
- - - - -
a873fc56 by Mark Sapiro at 2019-05-08T13:57:43Z
Merge branch 'import' into 'master'
Correct import of *_these_nonmembers action for nonmembers following a member.
Closes #580
See merge request mailman/mailman!510
- - - - -
3 changed files:
- src/mailman/docs/NEWS.rst
- src/mailman/utilities/importer.py
- src/mailman/utilities/tests/test_import.py
Changes:
=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -31,6 +31,8 @@ Command line
``*_these_nonmembers`` list attributes. (Closes #588)
* The ``mailman import21`` command now imports nonmember accept actions as
``Action.defer`` rather than ``Action.accept``. (Closes #579)
+* The ``mailman import21`` command now correctly imports ``*_these_nonmembers``
+ actions for nonmembers following a member in the list. (closes #580)
REST
----
=====================================
src/mailman/utilities/importer.py
=====================================
@@ -569,6 +569,7 @@ def _import_roster(mlist, config_dict, members, role,
action=None):
validator = getUtility(IEmailValidator)
roster = mlist.get_roster(role)
skipped = []
+ action_arg = action
for email in members:
# For owners and members, the emails can have a mixed case, so
# lowercase them all.
@@ -651,6 +652,10 @@ def _import_roster(mlist, config_dict, members, role,
action=None):
# Either this was set right above or in the function's arguments
# for nonmembers.
member.moderation_action = action
+ # We need to restore the action argument in case we changed it
+ # above so the changed action is not applied to the remaining
+ # members.
+ action = action_arg
# Other preferences.
if prefs is not None:
# AcknowledgePosts
=====================================
src/mailman/utilities/tests/test_import.py
=====================================
@@ -1161,6 +1161,19 @@ class TestRosterImport(unittest.TestCase):
self.assertEqual(len(list_prop), 1)
self.assertTrue(all(addr.startswith('^') for addr in list_prop))
+ def test_nonmember_following_member(self):
+ self._pckdict['hold_these_nonmembers'] = [
+ '[email protected]',
+ '[email protected]',
+ ]
+ self._pckdict['members']['[email protected]'] = 0
+ self._pckdict['user_options'] = {'[email protected]': 1}
+ import_config_pck(self._mlist, self._pckdict)
+ member = self._mlist.nonmembers.get_member('[email protected]')
+ self.assertEqual(member.moderation_action, Action.defer)
+ member = self._mlist.nonmembers.get_member('[email protected]')
+ self.assertEqual(member.moderation_action, Action.hold)
+
class TestPreferencesImport(unittest.TestCase):
"""Preferences get imported too."""
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/34a2e87b7a441af70e9147ecf02d2cd1dc25147b...a873fc5647977ad573e073a4a5d70dc6d08f3bba
--
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/34a2e87b7a441af70e9147ecf02d2cd1dc25147b...a873fc5647977ad573e073a4a5d70dc6d08f3bba
You're receiving this email because of your account on gitlab.com.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org