summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAurélien Bompard2015-09-21 00:48:20 +0200
committerBarry Warsaw2016-05-04 21:05:49 -0500
commit02bc8121d5eb027307c6d0cf716db17db40071be (patch)
tree7ca352b7de66655434a836d213b01f9e56322e59 /src
parent297abdc34b0fb7f1785465f5323ab374ec82f678 (diff)
downloadmailman-02bc8121d5eb027307c6d0cf716db17db40071be.tar.gz
mailman-02bc8121d5eb027307c6d0cf716db17db40071be.tar.zst
mailman-02bc8121d5eb027307c6d0cf716db17db40071be.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/model/tests/test_user.py5
-rw-r--r--src/mailman/model/user.py11
2 files changed, 11 insertions, 5 deletions
diff --git a/src/mailman/model/tests/test_user.py b/src/mailman/model/tests/test_user.py
index 5caabbddb..deb017620 100644
--- a/src/mailman/model/tests/test_user.py
+++ b/src/mailman/model/tests/test_user.py
@@ -157,7 +157,12 @@ class TestUser(unittest.TestCase):
mlist2.subscribe(bill, MemberRole.owner)
# Subscribe only bill's address to mlist3
mlist3.subscribe(bill.preferred_address, MemberRole.moderator)
+ # Do the absorption
self._anne.absorb(bill)
+ # check that bill has been deleted
+ self.assertEqual(len(list(self._manager.users)), 1)
+ # check that there is no leftover membership from user bill
+ self.assertEqual(len(list(self._manager.members)), 3)
# check that anne is subscribed to all lists
self.assertEqual(self._anne.memberships.member_count, 3)
memberships = {}
diff --git a/src/mailman/model/user.py b/src/mailman/model/user.py
index 3d02b2777..783d7f7b7 100644
--- a/src/mailman/model/user.py
+++ b/src/mailman/model/user.py
@@ -189,13 +189,14 @@ class User(Model):
# Merge memberships.
other_members = store.query(Member).filter(
Member.user_id == user.id)
- # (only import memberships of lists I'm not subscribed to yet)
subscribed_lists = [ m.list_id for m in self.memberships.members ]
- if subscribed_lists:
- other_members = other_members.filter(
- not_(Member.list_id.in_(subscribed_lists)))
for member in other_members:
- member.user_id = self.id
+ # Only import memberships of lists I'm not subscribed to yet,
+ # delete the rest.
+ if member.list_id not in subscribed_lists:
+ member.user_id = self.id
+ else:
+ store.delete(member)
# Merge the user preferences
self.preferences.absorb(user.preferences)
# Merge display_name, password and is_server_owner attributes.