summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAurélien Bompard2015-12-15 16:22:25 +0100
committerBarry Warsaw2016-01-13 19:36:29 -0500
commit5a6344a8506ef6d2032b9c76e54b0a5c5b887e9a (patch)
tree32340e3beb04d6f051e058963014062e7f0070f6 /src
parent95446742669349777ee4101237a76395f1dfaa87 (diff)
downloadmailman-5a6344a8506ef6d2032b9c76e54b0a5c5b887e9a.tar.gz
mailman-5a6344a8506ef6d2032b9c76e54b0a5c5b887e9a.tar.zst
mailman-5a6344a8506ef6d2032b9c76e54b0a5c5b887e9a.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/interfaces/subscriptions.py3
-rw-r--r--src/mailman/model/docs/subscriptions.rst16
-rw-r--r--src/mailman/model/subscriptions.py16
3 files changed, 31 insertions, 4 deletions
diff --git a/src/mailman/interfaces/subscriptions.py b/src/mailman/interfaces/subscriptions.py
index d4626a1bc..4efa41ce5 100644
--- a/src/mailman/interfaces/subscriptions.py
+++ b/src/mailman/interfaces/subscriptions.py
@@ -109,6 +109,9 @@ class ISubscriptionService(Interface):
digest member), the member can appear multiple times in this
list.
+ The subscriber argument may contain an asterisk, which will be
+ interpreted as a joker in the search pattern.
+
:param subscriber: The email address or user id of the user getting
subscribed.
:type subscriber: string or int
diff --git a/src/mailman/model/docs/subscriptions.rst b/src/mailman/model/docs/subscriptions.rst
index 5d141d5a9..eca6ef3a6 100644
--- a/src/mailman/model/docs/subscriptions.rst
+++ b/src/mailman/model/docs/subscriptions.rst
@@ -105,6 +105,22 @@ There may be no matching memberships.
>>> list(service.find_members('dave@example.com'))
[]
+The address may contain an asterisk, which will be interpreted as a joker in
+the search pattern.
+
+ >>> for member in service.find_members('*person*'):
+ ... print(member)
+ <Member: Anne Person <aperson@example.com>
+ on ant@example.com as MemberRole.member>
+ <Member: Anne Person <aperson@example.com>
+ on ant@example.com as MemberRole.owner>
+ <Member: Bart Person <bperson@example.com>
+ on ant@example.com as MemberRole.moderator>
+ <Member: Bart Person <bperson@example.com>
+ on bee@example.com as MemberRole.owner>
+ <Member: Cris Person <cperson@example.com>
+ on cat@example.com as MemberRole.member>
+
Memberships can also be searched for by user id.
>>> for member in service.find_members(anne_1.user.user_id):
diff --git a/src/mailman/model/subscriptions.py b/src/mailman/model/subscriptions.py
index b7276b2cd..43597638f 100644
--- a/src/mailman/model/subscriptions.py
+++ b/src/mailman/model/subscriptions.py
@@ -94,10 +94,18 @@ class SubscriptionService:
if subscriber is not None:
if isinstance(subscriber, str):
# subscriber is an email address.
- q_address = q_address.filter(
- Address.email == subscriber.lower())
- q_user = q_user.join(User.addresses).filter(
- Address.email == subscriber.lower())
+ subscriber = subscriber.lower()
+ if '*' in subscriber:
+ subscriber = subscriber.replace('*', '%')
+ q_address = q_address.filter(
+ Address.email.like(subscriber))
+ q_user = q_user.join(User.addresses).filter(
+ Address.email.like(subscriber))
+ else:
+ q_address = q_address.filter(
+ Address.email == subscriber)
+ q_user = q_user.join(User.addresses).filter(
+ Address.email == subscriber)
else:
# subscriber is a user id.
q_address = q_address.join(Address.user).filter(