Merge branch 'weblate-gnu-mailman-postorius' into 'master'
[mailman-postorious.git] / src / postorius / urls.py
blob1e9cb9d9362fc76a365009615d72ae31c204e762
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 1998-2023 by the Free Software Foundation, Inc.
4 # This file is part of Postorius.
6 # Postorius is free software: you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free
8 # Software Foundation, either version 3 of the License, or (at your option)
9 # any later version.
11 # Postorius is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 # more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Postorius. If not, see <http://www.gnu.org/licenses/>.
19 from django.conf.urls import include
20 from django.urls import re_path
22 from postorius.views import domain as domain_views
23 from postorius.views import list as list_views
24 from postorius.views import rest as rest_views
25 from postorius.views import system as system_views
26 from postorius.views import template as template_views
27 from postorius.views import user as user_views
30 list_patterns = [
31 re_path(r'^csv_view/$', list_views.csv_view, name='csv_view'),
32 re_path(
33 r'^members/options/(?P<email>.+)$',
34 list_views.list_member_options,
35 name='list_member_options',
37 re_path(
38 r'^members/(?P<role>\w+)/$',
39 list_views.ListMembersViews.as_view(),
40 name='list_members',
42 re_path(r'^$', list_views.ListSummaryView.as_view(), name='list_summary'),
43 re_path(
44 r'^subscribe$',
45 list_views.ListSubscribeView.as_view(),
46 name='list_subscribe',
48 re_path(
49 r'^anonymous_subscribe$',
50 list_views.ListAnonymousSubscribeView.as_view(),
51 name='list_anonymous_subscribe',
53 re_path(
54 r'^change_subscription$',
55 list_views.ChangeSubscriptionView.as_view(),
56 name='change_subscription',
58 re_path(
59 r'^unsubscribe/$',
60 list_views.ListUnsubscribeView.as_view(),
61 name='list_unsubscribe',
63 re_path(
64 r'^subscription_requests$',
65 list_views.list_subscription_requests,
66 name='list_subscription_requests',
68 re_path(
69 r'^unsubscription_requests$',
70 list_views.list_unsubscription_requests,
71 name='list_unsubscription_requests',
73 re_path(
74 r'^pending_confirmation$',
75 list_views.list_pending_confirmations,
76 name='list_pending_confirmation',
78 re_path(
79 r'^handle_subscription_request/(?P<request_id>[^/]+)/$',
80 list_views.handle_subscription_request,
81 name='handle_subscription_request',
83 re_path(
84 r'^mass_subscribe/$',
85 list_views.list_mass_subscribe,
86 name='mass_subscribe',
88 re_path(
89 r'^mass_removal/$',
90 list_views.ListMassRemovalView.as_view(),
91 name='mass_removal',
93 re_path(r'^delete$', list_views.list_delete, name='list_delete'),
94 re_path(
95 r'^held_messages$',
96 list_views.list_moderation,
97 name='list_held_messages',
99 re_path(
100 r'^held_messages/moderate$',
101 list_views.moderate_held_message,
102 name='moderate_held_message',
104 re_path(r'^bans/$', list_views.list_bans, name='list_bans'),
105 re_path(
106 r'^header-matches/$',
107 list_views.list_header_matches,
108 name='list_header_matches',
110 re_path(
111 r'^remove/(?P<role>[^/]+)/(?P<address>.+)$',
112 list_views.remove_role,
113 name='remove_role',
115 re_path(
116 r'^settings/(?P<visible_section>[^/]+)?$',
117 list_views.list_settings,
118 name='list_settings',
120 re_path(
121 r'^unsubscribe_all$',
122 list_views.remove_all_subscribers,
123 name='unsubscribe_all',
125 re_path(r'^confirm/$', list_views.confirm_token, name='confirm_token'),
126 re_path(
127 r'^templates$',
128 template_views.ListTemplateIndexView.as_view(),
129 name='list_template_list',
131 re_path(
132 r'^templates/new$',
133 template_views.ListTemplateCreateView.as_view(),
134 name='list_template_new',
136 re_path(
137 r'^templates/(?P<pk>[^/]+)?/update$',
138 template_views.ListTemplateUpdateView.as_view(),
139 name='list_template_update',
141 re_path(
142 r'^templates/(?P<pk>[^/]+)?/delete$',
143 template_views.ListTemplateDeleteView.as_view(),
144 name='list_template_delete',
148 urlpatterns = [
149 re_path(r'^$', list_views.list_index), # noqa: W605 (bogus)
150 re_path(
151 r'^accounts/subscriptions/$',
152 user_views.user_subscriptions,
153 name='ps_user_profile',
155 re_path(
156 r'^accounts/per-address-preferences/$',
157 user_views.UserAddressPreferencesView.as_view(),
158 name='user_address_preferences',
160 # if this URL changes, update Mailman's Member.options_url
161 re_path(
162 r'^accounts/per-subscription-preferences/$',
163 user_views.UserSubscriptionPreferencesView.as_view(),
164 name='user_subscription_preferences',
166 re_path(
167 r'^accounts/mailmansettings/$',
168 user_views.UserMailmanSettingsView.as_view(),
169 name='user_mailmansettings',
171 re_path(
172 r'^accounts/list-options/(?P<member_id>[^/]+)/$',
173 user_views.UserListOptionsView.as_view(),
174 name='user_list_options',
176 # /domains/
177 re_path(r'^domains/$', domain_views.domain_index, name='domain_index'),
178 re_path(r'^domains/new/$', domain_views.domain_new, name='domain_new'),
179 re_path(
180 r'^domains/(?P<domain>[^/]+)/$',
181 domain_views.domain_edit,
182 name='domain_edit',
184 re_path(
185 r'^domains/(?P<domain>[^/]+)/delete$',
186 domain_views.domain_delete,
187 name='domain_delete',
189 re_path(
190 r'^domains/(?P<domain>[^/]+)/owners$',
191 domain_views.domain_owners,
192 name='domain_owners',
194 re_path(
195 r'^domains/(?P<domain>[^/]+)/owners/(?P<user_id>.+)/remove$',
196 domain_views.remove_owners,
197 name='remove_domain_owner',
199 # Ideally, these paths should be accessible by domain_owners, however,
200 # we don't have good ways to check that, so for now, this views are
201 # protected by superuser privileges.
202 # I know it is bad, but this will be fixed soon. See postorius#
203 re_path(
204 r'^domains/(?P<domain>[^/]+)/templates$',
205 template_views.DomainTemplateIndexView.as_view(),
206 name='domain_template_list',
208 re_path(
209 r'^domains/(?P<domain>[^/]+)/templates/new$',
210 template_views.DomainTemplateCreateView.as_view(),
211 name='domain_template_new',
213 re_path(
214 r'^domains/(?P<domain>[^/]+)/templates/(?P<pk>[^/]+)/update$', # noqa: E501
215 template_views.DomainTemplateUpdateView.as_view(),
216 name='domain_template_update',
218 re_path(
219 r'^domains/(?P<domain>[^/]+)/templates/(?P<pk>[^/]+)/delete$', # noqa: E501
220 template_views.DomainTemplateDeleteView.as_view(),
221 name='domain_template_delete',
223 # /lists/
224 re_path(r'^lists/$', list_views.list_index, name='list_index'),
225 re_path(r'^lists/new/$', list_views.list_new, name='list_new'),
226 re_path(r'^lists/(?P<list_id>[^/]+)/', include(list_patterns)),
227 # /system/
228 re_path(
229 r'^system/$',
230 system_views.system_information,
231 name='system_information',
233 # /bans/
234 re_path(r'^bans/$', system_views.bans, name='global_bans'),
235 # /api/
236 re_path(
237 r'^api/list/(?P<list_id>[^/]+)/held_message/(?P<held_id>\d+)/$', # noqa: E501
238 rest_views.get_held_message,
239 name='rest_held_message',
241 re_path(
242 r'^api/list/(?P<list_id>[^/]+)/held_message/(?P<held_id>\d+)/'
243 r'attachment/(?P<attachment_id>\d+)/$',
244 rest_views.get_attachment_for_held_message,
245 name='rest_attachment_for_held_message',
247 # URL configuration for templates.
248 re_path(
249 r'^api/templates/(?P<context>[^/]+)/(?P<identifier>[^/]+)/(?P<name>[^/]+)', # noqa: E501
250 template_views.get_template_data,
251 name='rest_template',
253 # users.
254 re_path(r'users$', user_views.list_users, name='list_users'),
255 re_path(
256 r'users/(?P<user_id>[^/]+)/manage$',
257 user_views.manage_user,
258 name='manage_user',
260 re_path(
261 r'users/(?P<user_id>[^/]+)/delete$',
262 user_views.delete_user,
263 name='delete_user',