1 # -*- coding: utf-8 -*-
2 # Copyright (C) 1998-2021 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'),
32 re_path(r
'^members/options/(?P<email>.+)$',
33 list_views
.list_member_options
,
34 name
='list_member_options'),
35 re_path(r
'^members/(?P<role>\w+)/$',
36 list_views
.ListMembersViews
.as_view(),
38 re_path(r
'^$', list_views
.ListSummaryView
.as_view(),
40 re_path(r
'^subscribe$', list_views
.ListSubscribeView
.as_view(),
41 name
='list_subscribe'),
42 re_path(r
'^anonymous_subscribe$',
43 list_views
.ListAnonymousSubscribeView
.as_view(),
44 name
='list_anonymous_subscribe'),
45 re_path(r
'^change_subscription$',
46 list_views
.ChangeSubscriptionView
.as_view(),
47 name
='change_subscription'),
48 re_path(r
'^unsubscribe/$', list_views
.ListUnsubscribeView
.as_view(),
49 name
='list_unsubscribe'),
50 re_path(r
'^subscription_requests$',
51 list_views
.list_subscription_requests
,
52 name
='list_subscription_requests'),
53 re_path(r
'^unsubscription_requests$',
54 list_views
.list_unsubscription_requests
,
55 name
='list_unsubscription_requests'),
56 re_path(r
'^pending_confirmation$',
57 list_views
.list_pending_confirmations
,
58 name
='list_pending_confirmation'),
59 re_path(r
'^handle_subscription_request/(?P<request_id>[^/]+)/$',
60 list_views
.handle_subscription_request
,
61 name
='handle_subscription_request'),
62 re_path(r
'^mass_subscribe/$', list_views
.list_mass_subscribe
,
63 name
='mass_subscribe'),
64 re_path(r
'^mass_removal/$', list_views
.ListMassRemovalView
.as_view(),
66 re_path(r
'^delete$', list_views
.list_delete
, name
='list_delete'),
67 re_path(r
'^held_messages$', list_views
.list_moderation
,
68 name
='list_held_messages'),
69 re_path(r
'^held_messages/moderate$',
70 list_views
.moderate_held_message
,
71 name
='moderate_held_message'),
72 re_path(r
'^bans/$', list_views
.list_bans
, name
='list_bans'),
73 re_path(r
'^header-matches/$', list_views
.list_header_matches
,
74 name
='list_header_matches'),
75 re_path(r
'^remove/(?P<role>[^/]+)/(?P<address>.+)$',
76 list_views
.remove_role
,
78 re_path(r
'^settings/(?P<visible_section>[^/]+)?$',
79 list_views
.list_settings
,
80 name
='list_settings'),
81 re_path(r
'^unsubscribe_all$', list_views
.remove_all_subscribers
,
82 name
='unsubscribe_all'),
83 re_path(r
'^confirm/$', list_views
.confirm_token
,
84 name
='confirm_token'),
85 re_path(r
'^templates$',
86 template_views
.ListTemplateIndexView
.as_view(),
87 name
='list_template_list'),
88 re_path(r
'^templates/new$',
89 template_views
.ListTemplateCreateView
.as_view(),
90 name
='list_template_new'),
91 re_path(r
'^templates/(?P<pk>[^/]+)?/update$',
92 template_views
.ListTemplateUpdateView
.as_view(),
93 name
='list_template_update'),
94 re_path(r
'^templates/(?P<pk>[^/]+)?/delete$',
95 template_views
.ListTemplateDeleteView
.as_view(),
96 name
='list_template_delete')
100 re_path(r
'^$', list_views
.list_index
), # noqa: W605 (bogus)
101 re_path(r
'^accounts/subscriptions/$',
102 user_views
.user_subscriptions
,
103 name
='ps_user_profile'),
104 re_path(r
'^accounts/per-address-preferences/$',
105 user_views
.UserAddressPreferencesView
.as_view(),
106 name
='user_address_preferences'),
107 # if this URL changes, update Mailman's Member.options_url
108 re_path(r
'^accounts/per-subscription-preferences/$',
109 user_views
.UserSubscriptionPreferencesView
.as_view(),
110 name
='user_subscription_preferences'),
111 re_path(r
'^accounts/mailmansettings/$',
112 user_views
.UserMailmanSettingsView
.as_view(),
113 name
='user_mailmansettings'),
114 re_path(r
'^accounts/list-options/(?P<member_id>[^/]+)/$',
115 user_views
.UserListOptionsView
.as_view(),
116 name
='user_list_options'),
118 re_path(r
'^domains/$', domain_views
.domain_index
,
119 name
='domain_index'),
120 re_path(r
'^domains/new/$', domain_views
.domain_new
,
122 re_path(r
'^domains/(?P<domain>[^/]+)/$', domain_views
.domain_edit
,
124 re_path(r
'^domains/(?P<domain>[^/]+)/delete$',
125 domain_views
.domain_delete
,
126 name
='domain_delete'),
127 re_path(r
'^domains/(?P<domain>[^/]+)/owners$',
128 domain_views
.domain_owners
,
129 name
='domain_owners'),
130 re_path(r
'^domains/(?P<domain>[^/]+)/owners/(?P<user_id>.+)/remove$',
131 domain_views
.remove_owners
,
132 name
='remove_domain_owner'),
133 # Ideally, these paths should be accessible by domain_owners, however,
134 # we don't have good ways to check that, so for now, this views are
135 # protected by superuser privileges.
136 # I know it is bad, but this will be fixed soon. See postorius#
137 re_path(r
'^domains/(?P<domain>[^/]+)/templates$',
138 template_views
.DomainTemplateIndexView
.as_view(),
139 name
='domain_template_list'),
140 re_path(r
'^domains/(?P<domain>[^/]+)/templates/new$',
141 template_views
.DomainTemplateCreateView
.as_view(),
142 name
='domain_template_new'),
143 re_path(r
'^domains/(?P<domain>[^/]+)/templates/(?P<pk>[^/]+)/update$', # noqa: E501
144 template_views
.DomainTemplateUpdateView
.as_view(),
145 name
='domain_template_update'),
146 re_path(r
'^domains/(?P<domain>[^/]+)/templates/(?P<pk>[^/]+)/delete$', # noqa: E501
147 template_views
.DomainTemplateDeleteView
.as_view(),
148 name
='domain_template_delete'),
150 re_path(r
'^lists/$', list_views
.list_index
, name
='list_index'),
151 re_path(r
'^lists/new/$', list_views
.list_new
, name
='list_new'),
152 re_path(r
'^lists/(?P<list_id>[^/]+)/', include(list_patterns
)),
155 re_path(r
'^system/$', system_views
.system_information
,
156 name
='system_information'),
159 re_path(r
'^bans/$', system_views
.bans
, name
='global_bans'),
162 re_path(r
'^api/list/(?P<list_id>[^/]+)/held_message/(?P<held_id>\d+)/$', # noqa: E501
163 rest_views
.get_held_message
, name
='rest_held_message'),
164 re_path(r
'^api/list/(?P<list_id>[^/]+)/held_message/(?P<held_id>\d+)/'
165 r
'attachment/(?P<attachment_id>\d+)/$',
166 rest_views
.get_attachment_for_held_message
,
167 name
='rest_attachment_for_held_message'),
168 # URL configuration for templates.
169 re_path(r
'^api/templates/(?P<context>[^/]+)/(?P<identifier>[^/]+)/(?P<name>[^/]+)', # noqa: E501
170 template_views
.get_template_data
,
171 name
='rest_template'),
175 user_views
.list_users
,
177 re_path(r
'users/(?P<user_id>[^/]+)/manage$',
178 user_views
.manage_user
,