Skip to content

Commit

Permalink
Merge pull request #226 from euphorie/scrum-1638-mailing-list-path
Browse files Browse the repository at this point in the history
Mailing Lists JSON extensions
  • Loading branch information
reinhardt authored Jan 24, 2024
2 parents 7fcc41c + 3f357d9 commit 98b6ec9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Changelog
9.0.6 (unreleased)
------------------

- Nothing changed yet.
- Mailing lists: Allow searching for path. Show path in result.
(`#1638 <https://github.com/syslabcom/scrum/issues/1638>`_)
[reinhardt]


9.0.5 (2024-01-08)
Expand Down
12 changes: 11 additions & 1 deletion src/osha/oira/client/browser/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ def __call__(self):
class MailingListsJson(BaseJson):
"""Mailing lists (countries and tools, in the future also sectors)"""

def _get_entry(self, list_id, title):
encoded_title = b64encode(title.encode("utf-8")).decode("utf-8")
return {
"id": "|".join((list_id, encoded_title)),
"text": f"{title} ({list_id})" if "/" in list_id else title,
}

@property
def results(self):
"""List of "mailing list" path/names.
Expand Down Expand Up @@ -118,7 +125,10 @@ def results(self):

# Filter for query string if given. Else return all results.
if q:
query["Title"] = f"*{q}*"
if "/" not in q:
query["Title"] = f"*{q}*"
else:
query["path"] = "/".join((query["path"], q))

brains = catalog(**query)

Expand Down

0 comments on commit 98b6ec9

Please sign in to comment.