Merge branch 'issue-1144' into 'master'
[mailman.git] / src / mailman / utilities / urls.py
blobda8559fb45fa6145acd45082d0c9ff7759de5628
1 # Copyright (C) 2023 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
5 # GNU Mailman is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
8 # any later version.
10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
15 # You should have received a copy of the GNU General Public License along with
16 # GNU Mailman. If not, see <https://www.gnu.org/licenses/>.
18 """Utilities to generate web urls for Email templates."""
20 from mailman.config import config
21 from mailman.utilities.string import expand
24 def web_urls(d, mlist):
25 """Generate web urls for the MailingList templates."""
26 base_url = mlist.domain.base_url
27 if base_url is None:
28 return d
30 substitutions = {
31 'base_url': base_url,
32 'list_id': mlist.list_id,
33 'domain': mlist.mail_host,
36 for key in config.urlpatterns:
37 d[f'{key}_url'] = expand(config.urlpatterns[key], extras=substitutions)