diff options
| author | Aurélien Bompard | 2016-05-19 17:06:58 +0200 |
|---|---|---|
| committer | Barry Warsaw | 2016-10-26 08:39:07 -0400 |
| commit | 72197b0ca012c55b290230d846c6a65314c6fe05 (patch) | |
| tree | bf2c1ee87c02592ca37d717033b44c6180b84524 /src/mailman/rest/lists.py | |
| parent | 6c1e74d93212ee6922ea8500dbecb4cf2eff1114 (diff) | |
| download | mailman-72197b0ca012c55b290230d846c6a65314c6fe05.tar.gz mailman-72197b0ca012c55b290230d846c6a65314c6fe05.tar.zst mailman-72197b0ca012c55b290230d846c6a65314c6fe05.zip | |
Diffstat (limited to 'src/mailman/rest/lists.py')
| -rw-r--r-- | src/mailman/rest/lists.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mailman/rest/lists.py b/src/mailman/rest/lists.py index c3919c001..3d2ed072c 100644 --- a/src/mailman/rest/lists.py +++ b/src/mailman/rest/lists.py @@ -107,7 +107,16 @@ class _ListBase(CollectionMixin): def _get_collection(self, request): """See `CollectionMixin`.""" - return list(getUtility(IListManager)) + return self._filter_lists( + request, list(getUtility(IListManager))) + + def _filter_lists(self, request, lists): + """Filter a collection using query parameters.""" + only_advertised = request.get_param_as_bool('only_advertised') + if only_advertised: + return [l for l in lists if l.advertised] + else: + return lists @public @@ -299,7 +308,8 @@ class ListsForDomain(_ListBase): def _get_collection(self, request): """See `CollectionMixin`.""" - return list(self._domain.mailing_lists) + return self._filter_lists( + request, list(self._domain.mailing_lists)) @public |
