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)
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
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
31 re_path(r
'^csv_view/$', list_views
.csv_view
, name
='csv_view'),
33 r
'^members/options/(?P<email>.+)$',
34 list_views
.list_member_options
,
35 name
='list_member_options',
38 r
'^members/(?P<role>\w+)/$',
39 list_views
.ListMembersViews
.as_view(),
42 re_path(r
'^$', list_views
.ListSummaryView
.as_view(), name
='list_summary'),
45 list_views
.ListSubscribeView
.as_view(),
46 name
='list_subscribe',
49 r
'^anonymous_subscribe$',
50 list_views
.ListAnonymousSubscribeView
.as_view(),
51 name
='list_anonymous_subscribe',
54 r
'^change_subscription$',
55 list_views
.ChangeSubscriptionView
.as_view(),
56 name
='change_subscription',
60 list_views
.ListUnsubscribeView
.as_view(),
61 name
='list_unsubscribe',
64 r
'^subscription_requests$',
65 list_views
.list_subscription_requests
,
66 name
='list_subscription_requests',
69 r
'^unsubscription_requests$',
70 list_views
.list_unsubscription_requests
,
71 name
='list_unsubscription_requests',
74 r
'^pending_confirmation$',
75 list_views
.list_pending_confirmations
,
76 name
='list_pending_confirmation',
79 r
'^handle_subscription_request/(?P<request_id>[^/]+)/$',
80 list_views
.handle_subscription_request
,
81 name
='handle_subscription_request',
85 list_views
.list_mass_subscribe
,
86 name
='mass_subscribe',
90 list_views
.ListMassRemovalView
.as_view(),
93 re_path(r
'^delete$', list_views
.list_delete
, name
='list_delete'),
96 list_views
.list_moderation
,
97 name
='list_held_messages',
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'),
106 r
'^header-matches/$',
107 list_views
.list_header_matches
,
108 name
='list_header_matches',
111 r
'^remove/(?P<role>[^/]+)/(?P<address>.+)$',
112 list_views
.remove_role
,
116 r
'^settings/(?P<visible_section>[^/]+)?$',
117 list_views
.list_settings
,
118 name
='list_settings',
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'),
128 template_views
.ListTemplateIndexView
.as_view(),
129 name
='list_template_list',
133 template_views
.ListTemplateCreateView
.as_view(),
134 name
='list_template_new',
137 r
'^templates/(?P<pk>[^/]+)?/update$',
138 template_views
.ListTemplateUpdateView
.as_view(),
139 name
='list_template_update',
142 r
'^templates/(?P<pk>[^/]+)?/delete$',
143 template_views
.ListTemplateDeleteView
.as_view(),
144 name
='list_template_delete',
149 re_path(r
'^$', list_views
.list_index
), # noqa: W605 (bogus)
151 r
'^accounts/subscriptions/$',
152 user_views
.user_subscriptions
,
153 name
='ps_user_profile',
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
162 r
'^accounts/per-subscription-preferences/$',
163 user_views
.UserSubscriptionPreferencesView
.as_view(),
164 name
='user_subscription_preferences',
167 r
'^accounts/mailmansettings/$',
168 user_views
.UserMailmanSettingsView
.as_view(),
169 name
='user_mailmansettings',
172 r
'^accounts/list-options/(?P<member_id>[^/]+)/$',
173 user_views
.UserListOptionsView
.as_view(),
174 name
='user_list_options',
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'),
180 r
'^domains/(?P<domain>[^/]+)/$',
181 domain_views
.domain_edit
,
185 r
'^domains/(?P<domain>[^/]+)/delete$',
186 domain_views
.domain_delete
,
187 name
='domain_delete',
190 r
'^domains/(?P<domain>[^/]+)/owners$',
191 domain_views
.domain_owners
,
192 name
='domain_owners',
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#
204 r
'^domains/(?P<domain>[^/]+)/templates$',
205 template_views
.DomainTemplateIndexView
.as_view(),
206 name
='domain_template_list',
209 r
'^domains/(?P<domain>[^/]+)/templates/new$',
210 template_views
.DomainTemplateCreateView
.as_view(),
211 name
='domain_template_new',
214 r
'^domains/(?P<domain>[^/]+)/templates/(?P<pk>[^/]+)/update$', # noqa: E501
215 template_views
.DomainTemplateUpdateView
.as_view(),
216 name
='domain_template_update',
219 r
'^domains/(?P<domain>[^/]+)/templates/(?P<pk>[^/]+)/delete$', # noqa: E501
220 template_views
.DomainTemplateDeleteView
.as_view(),
221 name
='domain_template_delete',
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
)),
230 system_views
.system_information
,
231 name
='system_information',
234 re_path(r
'^bans/$', system_views
.bans
, name
='global_bans'),
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',
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.
249 r
'^api/templates/(?P<context>[^/]+)/(?P<identifier>[^/]+)/(?P<name>[^/]+)', # noqa: E501
250 template_views
.get_template_data
,
251 name
='rest_template',
254 re_path(r
'users$', user_views
.list_users
, name
='list_users'),
256 r
'users/(?P<user_id>[^/]+)/manage$',
257 user_views
.manage_user
,
261 r
'users/(?P<user_id>[^/]+)/delete$',
262 user_views
.delete_user
,