comparison rhodecode/config/routing.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl

Imported some of the GPLv3'd changes from RhodeCode v2.2.5. This imports changes between changesets 21af6c4eab3d and 6177597791c2 in RhodeCode's original repository, including only changes to Python files and HTML. RhodeCode clearly licensed its changes to these files under GPLv3 in their /LICENSE file, which states the following: The Python code and integrated HTML are licensed under the GPLv3 license. (See: https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE or http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE for an online copy of that LICENSE file) Conservancy reviewed these changes and confirmed that they can be licensed as a whole to the Kallithea project under GPLv3-only. While some of the contents committed herein are clearly licensed GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the statement above from RhodeCode indicates that they intend GPLv3-only as their license, per GPLv3ยง14 and other relevant sections of GPLv3.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:03:13 -0400
parents a1bc4af25ec5
children 31e119cb02ef
comparison
equal deleted inserted replaced
4115:8b7294a804a0 4116:ffd45b185016
1 # -*- coding: utf-8 -*-
2 # This program is free software: you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation, either version 3 of the License, or
5 # (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1 """ 14 """
2 Routes configuration 15 Routes configuration
3 16
4 The more specific and detailed routes should be defined first so they 17 The more specific and detailed routes should be defined first so they
5 may take precedent over the more generic routes. For more information 18 may take precedent over the more generic routes. For more information
6 refer to the routes manual at http://routes.groovie.org/docs/ 19 refer to the routes manual at http://routes.groovie.org/docs/
7 """ 20 """
21
8 from __future__ import with_statement 22 from __future__ import with_statement
9 from routes import Mapper 23 from routes import Mapper
10 24
11 # prefix for non repository related links needs to be prefixed with `/` 25 # prefix for non repository related links needs to be prefixed with `/`
12 ADMIN_PREFIX = '/_admin' 26 ADMIN_PREFIX = '/_admin'
13 27
14 28
15 def make_map(config): 29 def make_map(config):
16 """Create, configure and return the routes Mapper""" 30 """Create, configure and return the routes Mapper"""
17 rmap = Mapper(directory=config['pylons.paths']['controllers'], 31 rmap = Mapper(directory=config['pylons.paths']['controllers'],
18 always_scan=config['debug']) 32 always_scan=config['debug'])
19 rmap.minimization = False 33 rmap.minimization = False
20 rmap.explicit = False 34 rmap.explicit = False
21 35
22 from rhodecode.lib.utils import is_valid_repo 36 from rhodecode.lib.utils import (is_valid_repo, is_valid_repo_group,
23 from rhodecode.lib.utils import is_valid_repos_group 37 get_repo_by_id)
24 38
25 def check_repo(environ, match_dict): 39 def check_repo(environ, match_dict):
26 """ 40 """
27 check for valid repository for proper 404 handling 41 check for valid repository for proper 404 handling
28 42
29 :param environ: 43 :param environ:
30 :param match_dict: 44 :param match_dict:
31 """ 45 """
32 from rhodecode.model.db import Repository
33 repo_name = match_dict.get('repo_name') 46 repo_name = match_dict.get('repo_name')
34 47
35 if match_dict.get('f_path'): 48 if match_dict.get('f_path'):
36 #fix for multiple initial slashes that causes errors 49 #fix for multiple initial slashes that causes errors
37 match_dict['f_path'] = match_dict['f_path'].lstrip('/') 50 match_dict['f_path'] = match_dict['f_path'].lstrip('/')
38 51
39 try: 52 by_id_match = get_repo_by_id(repo_name)
40 by_id = repo_name.split('_') 53 if by_id_match:
41 if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '': 54 repo_name = by_id_match
42 repo_name = Repository.get(by_id[1]).repo_name 55 match_dict['repo_name'] = repo_name
43 match_dict['repo_name'] = repo_name
44 except Exception:
45 pass
46 56
47 return is_valid_repo(repo_name, config['base_path']) 57 return is_valid_repo(repo_name, config['base_path'])
48 58
49 def check_group(environ, match_dict): 59 def check_group(environ, match_dict):
50 """ 60 """
51 check for valid repository group for proper 404 handling 61 check for valid repository group for proper 404 handling
52 62
53 :param environ: 63 :param environ:
54 :param match_dict: 64 :param match_dict:
55 """ 65 """
56 repos_group_name = match_dict.get('group_name') 66 repo_group_name = match_dict.get('group_name')
57 return is_valid_repos_group(repos_group_name, config['base_path']) 67 return is_valid_repo_group(repo_group_name, config['base_path'])
58 68
59 def check_group_skip_path(environ, match_dict): 69 def check_group_skip_path(environ, match_dict):
60 """ 70 """
61 check for valid repository group for proper 404 handling, but skips 71 check for valid repository group for proper 404 handling, but skips
62 verification of existing path 72 verification of existing path
63 73
64 :param environ: 74 :param environ:
65 :param match_dict: 75 :param match_dict:
66 """ 76 """
67 repos_group_name = match_dict.get('group_name') 77 repo_group_name = match_dict.get('group_name')
68 return is_valid_repos_group(repos_group_name, config['base_path'], 78 return is_valid_repo_group(repo_group_name, config['base_path'],
69 skip_path_check=True) 79 skip_path_check=True)
70 80
71 def check_user_group(environ, match_dict): 81 def check_user_group(environ, match_dict):
72 """ 82 """
73 check for valid user group for proper 404 handling 83 check for valid user group for proper 404 handling
74 84
89 # CUSTOM ROUTES HERE 99 # CUSTOM ROUTES HERE
90 #========================================================================== 100 #==========================================================================
91 101
92 #MAIN PAGE 102 #MAIN PAGE
93 rmap.connect('home', '/', controller='home', action='index') 103 rmap.connect('home', '/', controller='home', action='index')
94 rmap.connect('repo_switcher', '/repos', controller='home', 104 rmap.connect('repo_switcher_data', '/_repos', controller='home',
95 action='repo_switcher') 105 action='repo_switcher_data')
96 rmap.connect('branch_tag_switcher', '/branches-tags/{repo_name:.*?}', 106
97 controller='home', action='branch_tag_switcher')
98 rmap.connect('rst_help', 107 rmap.connect('rst_help',
99 "http://docutils.sourceforge.net/docs/user/rst/quickref.html", 108 "http://docutils.sourceforge.net/docs/user/rst/quickref.html",
100 _static=True) 109 _static=True)
101 rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True) 110 rmap.connect('rhodecode_official', "https://rhodecode.com", _static=True)
102 111 rmap.connect('rc_issue_tracker', 'https://rhodecode.com/help/', _static=True)
103 #ADMIN REPOSITORY REST ROUTES 112
113 #ADMIN REPOSITORY ROUTES
104 with rmap.submapper(path_prefix=ADMIN_PREFIX, 114 with rmap.submapper(path_prefix=ADMIN_PREFIX,
105 controller='admin/repos') as m: 115 controller='admin/repos') as m:
106 m.connect("repos", "/repos", 116 m.connect("repos", "/repos",
107 action="create", conditions=dict(method=["POST"])) 117 action="create", conditions=dict(method=["POST"]))
108 m.connect("repos", "/repos", 118 m.connect("repos", "/repos",
109 action="index", conditions=dict(method=["GET"])) 119 action="index", conditions=dict(method=["GET"]))
110 m.connect("formatted_repos", "/repos.{format}",
111 action="index",
112 conditions=dict(method=["GET"]))
113 m.connect("new_repo", "/create_repository", 120 m.connect("new_repo", "/create_repository",
114 action="create_repository", conditions=dict(method=["GET"])) 121 action="create_repository", conditions=dict(method=["GET"]))
115 m.connect("/repos/{repo_name:.*?}", 122 m.connect("/repos/{repo_name:.*?}",
116 action="update", conditions=dict(method=["PUT"], 123 action="update", conditions=dict(method=["PUT"],
117 function=check_repo)) 124 function=check_repo))
118 m.connect("/repos/{repo_name:.*?}", 125 m.connect("delete_repo", "/repos/{repo_name:.*?}",
119 action="delete", conditions=dict(method=["DELETE"], 126 action="delete", conditions=dict(method=["DELETE"],
120 function=check_repo)) 127 ))
121 m.connect("formatted_edit_repo", "/repos/{repo_name:.*?}.{format}/edit",
122 action="edit", conditions=dict(method=["GET"],
123 function=check_repo))
124 m.connect("repo", "/repos/{repo_name:.*?}", 128 m.connect("repo", "/repos/{repo_name:.*?}",
125 action="show", conditions=dict(method=["GET"], 129 action="show", conditions=dict(method=["GET"],
126 function=check_repo)) 130 function=check_repo))
127 m.connect("formatted_repo", "/repos/{repo_name:.*?}.{format}", 131
128 action="show", conditions=dict(method=["GET"], 132 #ADMIN REPOSITORY GROUPS ROUTES
129 function=check_repo)) 133 with rmap.submapper(path_prefix=ADMIN_PREFIX,
130 #add repo perm member 134 controller='admin/repo_groups') as m:
131 m.connect('set_repo_perm_member', 135 m.connect("repos_groups", "/repo_groups",
132 "/repos/{repo_name:.*?}/grant_perm",
133 action="set_repo_perm_member",
134 conditions=dict(method=["POST"], function=check_repo))
135
136 #ajax delete repo perm user
137 m.connect('delete_repo_perm_member',
138 "/repos/{repo_name:.*?}/revoke_perm",
139 action="delete_repo_perm_member",
140 conditions=dict(method=["DELETE"], function=check_repo))
141
142 #settings actions
143 m.connect('repo_stats', "/repos_stats/{repo_name:.*?}",
144 action="repo_stats", conditions=dict(method=["DELETE"],
145 function=check_repo))
146 m.connect('repo_cache', "/repos_cache/{repo_name:.*?}",
147 action="repo_cache", conditions=dict(method=["DELETE"],
148 function=check_repo))
149 m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*?}",
150 action="repo_public_journal", conditions=dict(method=["PUT"],
151 function=check_repo))
152 m.connect('repo_pull', "/repo_pull/{repo_name:.*?}",
153 action="repo_pull", conditions=dict(method=["PUT"],
154 function=check_repo))
155 m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*?}",
156 action="repo_as_fork", conditions=dict(method=["PUT"],
157 function=check_repo))
158 m.connect('repo_locking', "/repo_locking/{repo_name:.*?}",
159 action="repo_locking", conditions=dict(method=["PUT"],
160 function=check_repo))
161 m.connect('toggle_locking', "/locking_toggle/{repo_name:.*?}",
162 action="toggle_locking", conditions=dict(method=["GET"],
163 function=check_repo))
164
165 #repo fields
166 m.connect('create_repo_fields', "/repo_fields/{repo_name:.*?}/new",
167 action="create_repo_field", conditions=dict(method=["PUT"],
168 function=check_repo))
169
170 m.connect('delete_repo_fields', "/repo_fields/{repo_name:.*?}/{field_id}",
171 action="delete_repo_field", conditions=dict(method=["DELETE"],
172 function=check_repo))
173
174 with rmap.submapper(path_prefix=ADMIN_PREFIX,
175 controller='admin/repos_groups') as m:
176 m.connect("repos_groups", "/repos_groups",
177 action="create", conditions=dict(method=["POST"])) 136 action="create", conditions=dict(method=["POST"]))
178 m.connect("repos_groups", "/repos_groups", 137 m.connect("repos_groups", "/repo_groups",
179 action="index", conditions=dict(method=["GET"])) 138 action="index", conditions=dict(method=["GET"]))
180 m.connect("formatted_repos_groups", "/repos_groups.{format}", 139 m.connect("new_repos_group", "/repo_groups/new",
181 action="index", conditions=dict(method=["GET"]))
182 m.connect("new_repos_group", "/repos_groups/new",
183 action="new", conditions=dict(method=["GET"])) 140 action="new", conditions=dict(method=["GET"]))
184 m.connect("formatted_new_repos_group", "/repos_groups/new.{format}", 141 m.connect("update_repos_group", "/repo_groups/{group_name:.*?}",
185 action="new", conditions=dict(method=["GET"]))
186 m.connect("update_repos_group", "/repos_groups/{group_name:.*?}",
187 action="update", conditions=dict(method=["PUT"], 142 action="update", conditions=dict(method=["PUT"],
188 function=check_group)) 143 function=check_group))
189 #add repo group perm member 144
190 m.connect('set_repo_group_perm_member', 145 m.connect("repos_group", "/repo_groups/{group_name:.*?}",
191 "/repos_groups/{group_name:.*?}/grant_perm", 146 action="show", conditions=dict(method=["GET"],
192 action="set_repo_group_perm_member", 147 function=check_group))
193 conditions=dict(method=["POST"], function=check_group)) 148
194 149 #EXTRAS REPO GROUP ROUTES
195 #ajax delete repo group perm 150 m.connect("edit_repo_group", "/repo_groups/{group_name:.*?}/edit",
196 m.connect('delete_repo_group_perm_member', 151 action="edit",
197 "/repos_groups/{group_name:.*?}/revoke_perm", 152 conditions=dict(method=["GET"], function=check_group))
198 action="delete_repo_group_perm_member", 153 m.connect("edit_repo_group", "/repo_groups/{group_name:.*?}/edit",
154 action="edit",
155 conditions=dict(method=["PUT"], function=check_group))
156
157 m.connect("edit_repo_group_advanced", "/repo_groups/{group_name:.*?}/edit/advanced",
158 action="edit_repo_group_advanced",
159 conditions=dict(method=["GET"], function=check_group))
160 m.connect("edit_repo_group_advanced", "/repo_groups/{group_name:.*?}/edit/advanced",
161 action="edit_repo_group_advanced",
162 conditions=dict(method=["PUT"], function=check_group))
163
164 m.connect("edit_repo_group_perms", "/repo_groups/{group_name:.*?}/edit/permissions",
165 action="edit_repo_group_perms",
166 conditions=dict(method=["GET"], function=check_group))
167 m.connect("edit_repo_group_perms", "/repo_groups/{group_name:.*?}/edit/permissions",
168 action="update_perms",
169 conditions=dict(method=["PUT"], function=check_group))
170 m.connect("edit_repo_group_perms", "/repo_groups/{group_name:.*?}/edit/permissions",
171 action="delete_perms",
199 conditions=dict(method=["DELETE"], function=check_group)) 172 conditions=dict(method=["DELETE"], function=check_group))
200 173
201 m.connect("delete_repos_group", "/repos_groups/{group_name:.*?}", 174 m.connect("delete_repos_group", "/repo_groups/{group_name:.*?}",
202 action="delete", conditions=dict(method=["DELETE"], 175 action="delete", conditions=dict(method=["DELETE"],
203 function=check_group_skip_path)) 176 function=check_group_skip_path))
204 m.connect("edit_repos_group", "/repos_groups/{group_name:.*?}/edit", 177
205 action="edit", conditions=dict(method=["GET"], 178
206 function=check_group)) 179 #ADMIN USER ROUTES
207 m.connect("formatted_edit_repos_group",
208 "/repos_groups/{group_name:.*?}.{format}/edit",
209 action="edit", conditions=dict(method=["GET"],
210 function=check_group))
211 m.connect("repos_group", "/repos_groups/{group_name:.*?}",
212 action="show", conditions=dict(method=["GET"],
213 function=check_group))
214 m.connect("formatted_repos_group", "/repos_groups/{group_name:.*?}.{format}",
215 action="show", conditions=dict(method=["GET"],
216 function=check_group))
217
218 #ADMIN USER REST ROUTES
219 with rmap.submapper(path_prefix=ADMIN_PREFIX, 180 with rmap.submapper(path_prefix=ADMIN_PREFIX,
220 controller='admin/users') as m: 181 controller='admin/users') as m:
221 m.connect("users", "/users", 182 m.connect("users", "/users",
222 action="create", conditions=dict(method=["POST"])) 183 action="create", conditions=dict(method=["POST"]))
223 m.connect("users", "/users", 184 m.connect("users", "/users",
224 action="index", conditions=dict(method=["GET"])) 185 action="index", conditions=dict(method=["GET"]))
225 m.connect("formatted_users", "/users.{format}", 186 m.connect("formatted_users", "/users.{format}",
226 action="index", conditions=dict(method=["GET"])) 187 action="index", conditions=dict(method=["GET"]))
227 m.connect("new_user", "/users/new", 188 m.connect("new_user", "/users/new",
228 action="new", conditions=dict(method=["GET"])) 189 action="new", conditions=dict(method=["GET"]))
229 m.connect("formatted_new_user", "/users/new.{format}",
230 action="new", conditions=dict(method=["GET"]))
231 m.connect("update_user", "/users/{id}", 190 m.connect("update_user", "/users/{id}",
232 action="update", conditions=dict(method=["PUT"])) 191 action="update", conditions=dict(method=["PUT"]))
233 m.connect("delete_user", "/users/{id}", 192 m.connect("delete_user", "/users/{id}",
234 action="delete", conditions=dict(method=["DELETE"])) 193 action="delete", conditions=dict(method=["DELETE"]))
235 m.connect("edit_user", "/users/{id}/edit", 194 m.connect("edit_user", "/users/{id}/edit",
236 action="edit", conditions=dict(method=["GET"])) 195 action="edit", conditions=dict(method=["GET"]))
237 m.connect("formatted_edit_user",
238 "/users/{id}.{format}/edit",
239 action="edit", conditions=dict(method=["GET"]))
240 m.connect("user", "/users/{id}", 196 m.connect("user", "/users/{id}",
241 action="show", conditions=dict(method=["GET"])) 197 action="show", conditions=dict(method=["GET"]))
242 m.connect("formatted_user", "/users/{id}.{format}",
243 action="show", conditions=dict(method=["GET"]))
244 198
245 #EXTRAS USER ROUTES 199 #EXTRAS USER ROUTES
246 m.connect("user_perm", "/users_perm/{id}", 200 m.connect("edit_user_advanced", "/users/{id}/edit/advanced",
247 action="update_perm", conditions=dict(method=["PUT"])) 201 action="edit_advanced", conditions=dict(method=["GET"]))
248 m.connect("user_emails", "/users_emails/{id}", 202 m.connect("edit_user_advanced", "/users/{id}/edit/advanced",
203 action="update_advanced", conditions=dict(method=["PUT"]))
204
205 m.connect("edit_user_api_keys", "/users/{id}/edit/api_keys",
206 action="edit_api_keys", conditions=dict(method=["GET"]))
207 m.connect("edit_user_api_keys", "/users/{id}/edit/api_keys",
208 action="add_api_key", conditions=dict(method=["PUT"]))
209 m.connect("edit_user_api_keys", "/users/{id}/edit/api_keys",
210 action="delete_api_key", conditions=dict(method=["DELETE"]))
211
212 m.connect("edit_user_perms", "/users/{id}/edit/permissions",
213 action="edit_perms", conditions=dict(method=["GET"]))
214 m.connect("edit_user_perms", "/users/{id}/edit/permissions",
215 action="update_perms", conditions=dict(method=["PUT"]))
216
217 m.connect("edit_user_emails", "/users/{id}/edit/emails",
218 action="edit_emails", conditions=dict(method=["GET"]))
219 m.connect("edit_user_emails", "/users/{id}/edit/emails",
249 action="add_email", conditions=dict(method=["PUT"])) 220 action="add_email", conditions=dict(method=["PUT"]))
250 m.connect("user_emails_delete", "/users_emails/{id}", 221 m.connect("edit_user_emails", "/users/{id}/edit/emails",
251 action="delete_email", conditions=dict(method=["DELETE"])) 222 action="delete_email", conditions=dict(method=["DELETE"]))
252 m.connect("user_ips", "/users_ips/{id}", 223
224 m.connect("edit_user_ips", "/users/{id}/edit/ips",
225 action="edit_ips", conditions=dict(method=["GET"]))
226 m.connect("edit_user_ips", "/users/{id}/edit/ips",
253 action="add_ip", conditions=dict(method=["PUT"])) 227 action="add_ip", conditions=dict(method=["PUT"]))
254 m.connect("user_ips_delete", "/users_ips/{id}", 228 m.connect("edit_user_ips", "/users/{id}/edit/ips",
255 action="delete_ip", conditions=dict(method=["DELETE"])) 229 action="delete_ip", conditions=dict(method=["DELETE"]))
256 230
257 #ADMIN USER GROUPS REST ROUTES 231 #ADMIN USER GROUPS REST ROUTES
258 with rmap.submapper(path_prefix=ADMIN_PREFIX, 232 with rmap.submapper(path_prefix=ADMIN_PREFIX,
259 controller='admin/users_groups') as m: 233 controller='admin/user_groups') as m:
260 m.connect("users_groups", "/users_groups", 234 m.connect("users_groups", "/user_groups",
261 action="create", conditions=dict(method=["POST"])) 235 action="create", conditions=dict(method=["POST"]))
262 m.connect("users_groups", "/users_groups", 236 m.connect("users_groups", "/user_groups",
263 action="index", conditions=dict(method=["GET"])) 237 action="index", conditions=dict(method=["GET"]))
264 m.connect("formatted_users_groups", "/users_groups.{format}", 238 m.connect("new_users_group", "/user_groups/new",
265 action="index", conditions=dict(method=["GET"]))
266 m.connect("new_users_group", "/users_groups/new",
267 action="new", conditions=dict(method=["GET"])) 239 action="new", conditions=dict(method=["GET"]))
268 m.connect("formatted_new_users_group", "/users_groups/new.{format}", 240 m.connect("update_users_group", "/user_groups/{id}",
269 action="new", conditions=dict(method=["GET"]))
270 m.connect("update_users_group", "/users_groups/{id}",
271 action="update", conditions=dict(method=["PUT"])) 241 action="update", conditions=dict(method=["PUT"]))
272 m.connect("delete_users_group", "/users_groups/{id}", 242 m.connect("delete_users_group", "/user_groups/{id}",
273 action="delete", conditions=dict(method=["DELETE"])) 243 action="delete", conditions=dict(method=["DELETE"]))
274 m.connect("edit_users_group", "/users_groups/{id}/edit", 244 m.connect("edit_users_group", "/user_groups/{id}/edit",
275 action="edit", conditions=dict(method=["GET"]), 245 action="edit", conditions=dict(method=["GET"]),
276 function=check_user_group) 246 function=check_user_group)
277 m.connect("formatted_edit_users_group", 247 m.connect("users_group", "/user_groups/{id}",
278 "/users_groups/{id}.{format}/edit",
279 action="edit", conditions=dict(method=["GET"]))
280 m.connect("users_group", "/users_groups/{id}",
281 action="show", conditions=dict(method=["GET"])) 248 action="show", conditions=dict(method=["GET"]))
282 m.connect("formatted_users_group", "/users_groups/{id}.{format}", 249
283 action="show", conditions=dict(method=["GET"])) 250 #EXTRAS USER GROUP ROUTES
284 251 m.connect("edit_user_group_default_perms", "/user_groups/{id}/edit/default_perms",
285 #EXTRAS USER ROUTES 252 action="edit_default_perms", conditions=dict(method=["GET"]))
286 # update 253 m.connect("edit_user_group_default_perms", "/user_groups/{id}/edit/default_perms",
287 m.connect("users_group_perm", "/users_groups/{id}/update_global_perm", 254 action="update_default_perms", conditions=dict(method=["PUT"]))
288 action="update_perm", conditions=dict(method=["PUT"])) 255
289 256
290 #add user group perm member 257 m.connect("edit_user_group_perms", "/user_groups/{id}/edit/perms",
291 m.connect('set_user_group_perm_member', "/users_groups/{id}/grant_perm", 258 action="edit_perms", conditions=dict(method=["GET"]))
292 action="set_user_group_perm_member", 259 m.connect("edit_user_group_perms", "/user_groups/{id}/edit/perms",
293 conditions=dict(method=["POST"])) 260 action="update_perms", conditions=dict(method=["PUT"]))
294 261 m.connect("edit_user_group_perms", "/user_groups/{id}/edit/perms",
295 #ajax delete user group perm 262 action="delete_perms", conditions=dict(method=["DELETE"]))
296 m.connect('delete_user_group_perm_member', "/users_groups/{id}/revoke_perm", 263
297 action="delete_user_group_perm_member", 264 m.connect("edit_user_group_advanced", "/user_groups/{id}/edit/advanced",
298 conditions=dict(method=["DELETE"])) 265 action="edit_advanced", conditions=dict(method=["GET"]))
299 266
300 #ADMIN GROUP REST ROUTES 267 m.connect("edit_user_group_members", "/user_groups/{id}/edit/members",
301 rmap.resource('group', 'groups', 268 action="edit_members", conditions=dict(method=["GET"]))
302 controller='admin/groups', path_prefix=ADMIN_PREFIX) 269
303 270
304 #ADMIN PERMISSIONS REST ROUTES 271
305 rmap.resource('permission', 'permissions', 272 #ADMIN PERMISSIONS ROUTES
306 controller='admin/permissions', path_prefix=ADMIN_PREFIX) 273 with rmap.submapper(path_prefix=ADMIN_PREFIX,
274 controller='admin/permissions') as m:
275 m.connect("admin_permissions", "/permissions",
276 action="permission_globals", conditions=dict(method=["POST"]))
277 m.connect("admin_permissions", "/permissions",
278 action="permission_globals", conditions=dict(method=["GET"]))
279
280 m.connect("admin_permissions_ips", "/permissions/ips",
281 action="permission_ips", conditions=dict(method=["POST"]))
282 m.connect("admin_permissions_ips", "/permissions/ips",
283 action="permission_ips", conditions=dict(method=["GET"]))
284
285 m.connect("admin_permissions_perms", "/permissions/perms",
286 action="permission_perms", conditions=dict(method=["POST"]))
287 m.connect("admin_permissions_perms", "/permissions/perms",
288 action="permission_perms", conditions=dict(method=["GET"]))
289
307 290
308 #ADMIN DEFAULTS REST ROUTES 291 #ADMIN DEFAULTS REST ROUTES
309 rmap.resource('default', 'defaults', 292 rmap.resource('default', 'defaults',
310 controller='admin/defaults', path_prefix=ADMIN_PREFIX) 293 controller='admin/defaults', path_prefix=ADMIN_PREFIX)
311 294
312 ##ADMIN LDAP SETTINGS 295 #ADMIN AUTH SETTINGS
313 rmap.connect('ldap_settings', '%s/ldap' % ADMIN_PREFIX, 296 rmap.connect('auth_settings', '%s/auth' % ADMIN_PREFIX,
314 controller='admin/ldap_settings', action='ldap_settings', 297 controller='admin/auth_settings', action='auth_settings',
315 conditions=dict(method=["POST"])) 298 conditions=dict(method=["POST"]))
316 299 rmap.connect('auth_home', '%s/auth' % ADMIN_PREFIX,
317 rmap.connect('ldap_home', '%s/ldap' % ADMIN_PREFIX, 300 controller='admin/auth_settings')
318 controller='admin/ldap_settings') 301
319 302 #ADMIN SETTINGS ROUTES
320 #ADMIN SETTINGS REST ROUTES
321 with rmap.submapper(path_prefix=ADMIN_PREFIX, 303 with rmap.submapper(path_prefix=ADMIN_PREFIX,
322 controller='admin/settings') as m: 304 controller='admin/settings') as m:
323 m.connect("admin_settings", "/settings", 305 m.connect("admin_settings", "/settings",
324 action="create", conditions=dict(method=["POST"])) 306 action="settings_vcs", conditions=dict(method=["POST"]))
325 m.connect("admin_settings", "/settings", 307 m.connect("admin_settings", "/settings",
326 action="index", conditions=dict(method=["GET"])) 308 action="settings_vcs", conditions=dict(method=["GET"]))
327 m.connect("formatted_admin_settings", "/settings.{format}", 309
328 action="index", conditions=dict(method=["GET"])) 310 m.connect("admin_settings_mapping", "/settings/mapping",
329 m.connect("admin_new_setting", "/settings/new", 311 action="settings_mapping", conditions=dict(method=["POST"]))
330 action="new", conditions=dict(method=["GET"])) 312 m.connect("admin_settings_mapping", "/settings/mapping",
331 m.connect("formatted_admin_new_setting", "/settings/new.{format}", 313 action="settings_mapping", conditions=dict(method=["GET"]))
332 action="new", conditions=dict(method=["GET"])) 314
333 m.connect("/settings/{setting_id}", 315 m.connect("admin_settings_global", "/settings/global",
334 action="update", conditions=dict(method=["PUT"])) 316 action="settings_global", conditions=dict(method=["POST"]))
335 m.connect("/settings/{setting_id}", 317 m.connect("admin_settings_global", "/settings/global",
336 action="delete", conditions=dict(method=["DELETE"])) 318 action="settings_global", conditions=dict(method=["GET"]))
337 m.connect("admin_edit_setting", "/settings/{setting_id}/edit", 319
338 action="edit", conditions=dict(method=["GET"])) 320 m.connect("admin_settings_visual", "/settings/visual",
339 m.connect("formatted_admin_edit_setting", 321 action="settings_visual", conditions=dict(method=["POST"]))
340 "/settings/{setting_id}.{format}/edit", 322 m.connect("admin_settings_visual", "/settings/visual",
341 action="edit", conditions=dict(method=["GET"])) 323 action="settings_visual", conditions=dict(method=["GET"]))
342 m.connect("admin_setting", "/settings/{setting_id}", 324
343 action="show", conditions=dict(method=["GET"])) 325 m.connect("admin_settings_email", "/settings/email",
344 m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}", 326 action="settings_email", conditions=dict(method=["POST"]))
345 action="show", conditions=dict(method=["GET"])) 327 m.connect("admin_settings_email", "/settings/email",
346 m.connect("admin_settings_my_account", "/my_account", 328 action="settings_email", conditions=dict(method=["GET"]))
329
330 m.connect("admin_settings_hooks", "/settings/hooks",
331 action="settings_hooks", conditions=dict(method=["POST"]))
332 m.connect("admin_settings_hooks", "/settings/hooks",
333 action="settings_hooks", conditions=dict(method=["DELETE"]))
334 m.connect("admin_settings_hooks", "/settings/hooks",
335 action="settings_hooks", conditions=dict(method=["GET"]))
336
337 m.connect("admin_settings_search", "/settings/search",
338 action="settings_search", conditions=dict(method=["POST"]))
339 m.connect("admin_settings_search", "/settings/search",
340 action="settings_search", conditions=dict(method=["GET"]))
341
342 m.connect("admin_settings_system", "/settings/system",
343 action="settings_system", conditions=dict(method=["POST"]))
344 m.connect("admin_settings_system", "/settings/system",
345 action="settings_system", conditions=dict(method=["GET"]))
346 m.connect("admin_settings_system_update", "/settings/system/updates",
347 action="settings_system_update", conditions=dict(method=["GET"]))
348
349 m.connect("admin_settings_license", "/settings/license",
350 action="settings_license", conditions=dict(method=["POST"]))
351 m.connect("admin_settings_license", "/settings/license",
352 action="settings_license", conditions=dict(method=["GET"]))
353
354 #ADMIN MY ACCOUNT
355 with rmap.submapper(path_prefix=ADMIN_PREFIX,
356 controller='admin/my_account') as m:
357
358 m.connect("my_account", "/my_account",
347 action="my_account", conditions=dict(method=["GET"])) 359 action="my_account", conditions=dict(method=["GET"]))
348 m.connect("admin_settings_my_account_update", "/my_account_update", 360 m.connect("my_account", "/my_account",
349 action="my_account_update", conditions=dict(method=["PUT"])) 361 action="my_account", conditions=dict(method=["POST"]))
350 m.connect("admin_settings_my_repos", "/my_account/repos", 362
351 action="my_account_my_repos", conditions=dict(method=["GET"])) 363 m.connect("my_account_password", "/my_account/password",
352 m.connect("admin_settings_my_pullrequests", "/my_account/pull_requests", 364 action="my_account_password", conditions=dict(method=["GET"]))
353 action="my_account_my_pullrequests", conditions=dict(method=["GET"])) 365 m.connect("my_account_password", "/my_account/password",
366 action="my_account_password", conditions=dict(method=["POST"]))
367
368 m.connect("my_account_repos", "/my_account/repos",
369 action="my_account_repos", conditions=dict(method=["GET"]))
370
371 m.connect("my_account_watched", "/my_account/watched",
372 action="my_account_watched", conditions=dict(method=["GET"]))
373
374 m.connect("my_account_pullrequests", "/my_account/pull_requests",
375 action="my_account_pullrequests", conditions=dict(method=["GET"]))
376
377 m.connect("my_account_perms", "/my_account/perms",
378 action="my_account_perms", conditions=dict(method=["GET"]))
379
380 m.connect("my_account_emails", "/my_account/emails",
381 action="my_account_emails", conditions=dict(method=["GET"]))
382 m.connect("my_account_emails", "/my_account/emails",
383 action="my_account_emails_add", conditions=dict(method=["POST"]))
384 m.connect("my_account_emails", "/my_account/emails",
385 action="my_account_emails_delete", conditions=dict(method=["DELETE"]))
386
387 m.connect("my_account_api_keys", "/my_account/api_keys",
388 action="my_account_api_keys", conditions=dict(method=["GET"]))
389 m.connect("my_account_api_keys", "/my_account/api_keys",
390 action="my_account_api_keys_add", conditions=dict(method=["POST"]))
391 m.connect("my_account_api_keys", "/my_account/api_keys",
392 action="my_account_api_keys_delete", conditions=dict(method=["DELETE"]))
354 393
355 #NOTIFICATION REST ROUTES 394 #NOTIFICATION REST ROUTES
356 with rmap.submapper(path_prefix=ADMIN_PREFIX, 395 with rmap.submapper(path_prefix=ADMIN_PREFIX,
357 controller='admin/notifications') as m: 396 controller='admin/notifications') as m:
358 m.connect("notifications", "/notifications", 397 m.connect("notifications", "/notifications",
388 action="create", conditions=dict(method=["POST"])) 427 action="create", conditions=dict(method=["POST"]))
389 m.connect("gists", "/gists", 428 m.connect("gists", "/gists",
390 action="index", conditions=dict(method=["GET"])) 429 action="index", conditions=dict(method=["GET"]))
391 m.connect("new_gist", "/gists/new", 430 m.connect("new_gist", "/gists/new",
392 action="new", conditions=dict(method=["GET"])) 431 action="new", conditions=dict(method=["GET"]))
393 m.connect("formatted_new_gist", "/gists/new.{format}", 432
394 action="new", conditions=dict(method=["GET"])) 433
395 m.connect("formatted_gists", "/gists.{format}",
396 action="index", conditions=dict(method=["GET"]))
397 m.connect("/gists/{gist_id}", 434 m.connect("/gists/{gist_id}",
398 action="update", conditions=dict(method=["PUT"])) 435 action="update", conditions=dict(method=["PUT"]))
399 m.connect("/gists/{gist_id}", 436 m.connect("/gists/{gist_id}",
400 action="delete", conditions=dict(method=["DELETE"])) 437 action="delete", conditions=dict(method=["DELETE"]))
401 m.connect("edit_gist", "/gists/{gist_id}/edit", 438 m.connect("edit_gist", "/gists/{gist_id}/edit",
402 action="edit", conditions=dict(method=["GET"])) 439 action="edit", conditions=dict(method=["GET", "POST"]))
403 m.connect("formatted_edit_gist", 440 m.connect("edit_gist_check_revision", "/gists/{gist_id}/edit/check_revision",
404 "/gists/{gist_id}/{format}/edit", 441 action="check_revision", conditions=dict(method=["POST"]))
405 action="edit", conditions=dict(method=["GET"])) 442
443
406 m.connect("gist", "/gists/{gist_id}", 444 m.connect("gist", "/gists/{gist_id}",
407 action="show", conditions=dict(method=["GET"])) 445 action="show", conditions=dict(method=["GET"]))
408 m.connect("formatted_gist", "/gists/{gist_id}/{format}", 446 m.connect("gist_rev", "/gists/{gist_id}/{revision}",
447 revision="tip",
409 action="show", conditions=dict(method=["GET"])) 448 action="show", conditions=dict(method=["GET"]))
410 m.connect("formatted_gist_file", "/gists/{gist_id}/{format}/{revision}/{f_path:.*}", 449 m.connect("formatted_gist", "/gists/{gist_id}/{revision}/{format}",
450 revision="tip",
451 action="show", conditions=dict(method=["GET"]))
452 m.connect("formatted_gist_file", "/gists/{gist_id}/{revision}/{format}/{f_path:.*}",
453 revision='tip',
411 action="show", conditions=dict(method=["GET"])) 454 action="show", conditions=dict(method=["GET"]))
412 455
413 #ADMIN MAIN PAGES 456 #ADMIN MAIN PAGES
414 with rmap.submapper(path_prefix=ADMIN_PREFIX, 457 with rmap.submapper(path_prefix=ADMIN_PREFIX,
415 controller='admin/admin') as m: 458 controller='admin/admin') as m:
487 conditions=dict(function=check_repo)) 530 conditions=dict(function=check_repo))
488 531
489 #========================================================================== 532 #==========================================================================
490 # REPOSITORY ROUTES 533 # REPOSITORY ROUTES
491 #========================================================================== 534 #==========================================================================
535 rmap.connect('repo_creating_home', '/{repo_name:.*?}/repo_creating',
536 controller='admin/repos', action='repo_creating')
537 rmap.connect('repo_check_home', '/{repo_name:.*?}/crepo_check',
538 controller='admin/repos', action='repo_check')
539
492 rmap.connect('summary_home', '/{repo_name:.*?}', 540 rmap.connect('summary_home', '/{repo_name:.*?}',
493 controller='summary', 541 controller='summary',
494 conditions=dict(function=check_repo)) 542 conditions=dict(function=check_repo))
495 543
544 # must be here for proper group/repo catching
545 rmap.connect('repos_group_home', '/{group_name:.*}',
546 controller='admin/repo_groups', action="show_by_name",
547 conditions=dict(function=check_group))
548 rmap.connect('repo_stats_home', '/{repo_name:.*?}/statistics',
549 controller='summary', action='statistics',
550 conditions=dict(function=check_repo))
551
496 rmap.connect('repo_size', '/{repo_name:.*?}/repo_size', 552 rmap.connect('repo_size', '/{repo_name:.*?}/repo_size',
497 controller='summary', action='repo_size', 553 controller='summary', action='repo_size',
498 conditions=dict(function=check_repo)) 554 conditions=dict(function=check_repo))
499 555
500 rmap.connect('repos_group_home', '/{group_name:.*}', 556 rmap.connect('branch_tag_switcher', '/{repo_name:.*?}/branches-tags',
501 controller='admin/repos_groups', action="show_by_name", 557 controller='home', action='branch_tag_switcher')
502 conditions=dict(function=check_group)) 558 rmap.connect('repo_refs_data', '/{repo_name:.*?}/refs-data',
559 controller='home', action='repo_refs_data')
503 560
504 rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}', 561 rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}',
505 controller='changeset', revision='tip', 562 controller='changeset', revision='tip',
506 conditions=dict(function=check_repo)) 563 conditions=dict(function=check_repo))
507 564 rmap.connect('changeset_children', '/{repo_name:.*?}/changeset_children/{revision}',
508 # no longer user, but kept for routes to work 565 controller='changeset', revision='tip', action="changeset_children",
509 rmap.connect("_edit_repo", "/{repo_name:.*?}/edit", 566 conditions=dict(function=check_repo))
510 controller='admin/repos', action="edit", 567 rmap.connect('changeset_parents', '/{repo_name:.*?}/changeset_parents/{revision}',
511 conditions=dict(method=["GET"], function=check_repo) 568 controller='changeset', revision='tip', action="changeset_parents",
512 ) 569 conditions=dict(function=check_repo))
513 570
571 # repo edit options
514 rmap.connect("edit_repo", "/{repo_name:.*?}/settings", 572 rmap.connect("edit_repo", "/{repo_name:.*?}/settings",
515 controller='admin/repos', action="edit", 573 controller='admin/repos', action="edit",
516 conditions=dict(method=["GET"], function=check_repo) 574 conditions=dict(method=["GET"], function=check_repo))
517 ) 575
576 rmap.connect("edit_repo_perms", "/{repo_name:.*?}/settings/permissions",
577 controller='admin/repos', action="edit_permissions",
578 conditions=dict(method=["GET"], function=check_repo))
579 rmap.connect("edit_repo_perms_update", "/{repo_name:.*?}/settings/permissions",
580 controller='admin/repos', action="edit_permissions_update",
581 conditions=dict(method=["PUT"], function=check_repo))
582 rmap.connect("edit_repo_perms_revoke", "/{repo_name:.*?}/settings/permissions",
583 controller='admin/repos', action="edit_permissions_revoke",
584 conditions=dict(method=["DELETE"], function=check_repo))
585
586 rmap.connect("edit_repo_fields", "/{repo_name:.*?}/settings/fields",
587 controller='admin/repos', action="edit_fields",
588 conditions=dict(method=["GET"], function=check_repo))
589 rmap.connect('create_repo_fields', "/{repo_name:.*?}/settings/fields/new",
590 controller='admin/repos', action="create_repo_field",
591 conditions=dict(method=["PUT"], function=check_repo))
592 rmap.connect('delete_repo_fields', "/{repo_name:.*?}/settings/fields/{field_id}",
593 controller='admin/repos', action="delete_repo_field",
594 conditions=dict(method=["DELETE"], function=check_repo))
595
596
597 rmap.connect("edit_repo_advanced", "/{repo_name:.*?}/settings/advanced",
598 controller='admin/repos', action="edit_advanced",
599 conditions=dict(method=["GET"], function=check_repo))
600
601 rmap.connect("edit_repo_advanced_locking", "/{repo_name:.*?}/settings/advanced/locking",
602 controller='admin/repos', action="edit_advanced_locking",
603 conditions=dict(method=["PUT"], function=check_repo))
604 rmap.connect('toggle_locking', "/{repo_name:.*?}/settings/advanced/locking_toggle",
605 controller='admin/repos', action="toggle_locking",
606 conditions=dict(method=["GET"], function=check_repo))
607
608 rmap.connect("edit_repo_advanced_journal", "/{repo_name:.*?}/settings/advanced/journal",
609 controller='admin/repos', action="edit_advanced_journal",
610 conditions=dict(method=["PUT"], function=check_repo))
611
612 rmap.connect("edit_repo_advanced_fork", "/{repo_name:.*?}/settings/advanced/fork",
613 controller='admin/repos', action="edit_advanced_fork",
614 conditions=dict(method=["PUT"], function=check_repo))
615
616
617 rmap.connect("edit_repo_caches", "/{repo_name:.*?}/settings/caches",
618 controller='admin/repos', action="edit_caches",
619 conditions=dict(method=["GET"], function=check_repo))
620 rmap.connect("edit_repo_caches", "/{repo_name:.*?}/settings/caches",
621 controller='admin/repos', action="edit_caches",
622 conditions=dict(method=["PUT"], function=check_repo))
623
624
625 rmap.connect("edit_repo_remote", "/{repo_name:.*?}/settings/remote",
626 controller='admin/repos', action="edit_remote",
627 conditions=dict(method=["GET"], function=check_repo))
628 rmap.connect("edit_repo_remote", "/{repo_name:.*?}/settings/remote",
629 controller='admin/repos', action="edit_remote",
630 conditions=dict(method=["PUT"], function=check_repo))
631
632 rmap.connect("edit_repo_statistics", "/{repo_name:.*?}/settings/statistics",
633 controller='admin/repos', action="edit_statistics",
634 conditions=dict(method=["GET"], function=check_repo))
635 rmap.connect("edit_repo_statistics", "/{repo_name:.*?}/settings/statistics",
636 controller='admin/repos', action="edit_statistics",
637 conditions=dict(method=["PUT"], function=check_repo))
518 638
519 #still working url for backward compat. 639 #still working url for backward compat.
520 rmap.connect('raw_changeset_home_depraced', 640 rmap.connect('raw_changeset_home_depraced',
521 '/{repo_name:.*?}/raw-changeset/{revision}', 641 '/{repo_name:.*?}/raw-changeset/{revision}',
522 controller='changeset', action='changeset_raw', 642 controller='changeset', action='changeset_raw',
554 conditions=dict(function=check_repo, method=["DELETE"])) 674 conditions=dict(function=check_repo, method=["DELETE"]))
555 675
556 rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}', 676 rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}',
557 controller='changeset', action='changeset_info') 677 controller='changeset', action='changeset_info')
558 678
679 rmap.connect('compare_home',
680 '/{repo_name:.*?}/compare',
681 controller='compare', action='index',
682 conditions=dict(function=check_repo))
683
559 rmap.connect('compare_url', 684 rmap.connect('compare_url',
560 '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}', 685 '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}',
561 controller='compare', action='index', 686 controller='compare', action='compare',
562 conditions=dict(function=check_repo), 687 conditions=dict(function=check_repo),
563 requirements=dict( 688 requirements=dict(
564 org_ref_type='(branch|book|tag|rev|__other_ref_type__)', 689 org_ref_type='(branch|book|tag|rev|__other_ref_type__)',
565 other_ref_type='(branch|book|tag|rev|__org_ref_type__)') 690 other_ref_type='(branch|book|tag|rev|__org_ref_type__)')
566 ) 691 )
646 rmap.connect('files_history_home', 771 rmap.connect('files_history_home',
647 '/{repo_name:.*?}/history/{revision}/{f_path:.*}', 772 '/{repo_name:.*?}/history/{revision}/{f_path:.*}',
648 controller='files', action='history', revision='tip', f_path='', 773 controller='files', action='history', revision='tip', f_path='',
649 conditions=dict(function=check_repo)) 774 conditions=dict(function=check_repo))
650 775
776 rmap.connect('files_authors_home',
777 '/{repo_name:.*?}/authors/{revision}/{f_path:.*}',
778 controller='files', action='authors', revision='tip', f_path='',
779 conditions=dict(function=check_repo))
780
651 rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}', 781 rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}',
652 controller='files', action='diff', revision='tip', f_path='', 782 controller='files', action='diff', revision='tip', f_path='',
653 conditions=dict(function=check_repo)) 783 conditions=dict(function=check_repo))
654 784
655 rmap.connect('files_diff_2way_home', '/{repo_name:.*?}/diff-2way/{f_path:.*}', 785 rmap.connect('files_diff_2way_home', '/{repo_name:.*?}/diff-2way/{f_path:.*}',
679 rmap.connect('files_add_home', 809 rmap.connect('files_add_home',
680 '/{repo_name:.*?}/add/{revision}/{f_path:.*}', 810 '/{repo_name:.*?}/add/{revision}/{f_path:.*}',
681 controller='files', action='add', revision='tip', 811 controller='files', action='add', revision='tip',
682 f_path='', conditions=dict(function=check_repo)) 812 f_path='', conditions=dict(function=check_repo))
683 813
814 rmap.connect('files_delete_home',
815 '/{repo_name:.*?}/delete/{revision}/{f_path:.*}',
816 controller='files', action='delete', revision='tip',
817 f_path='', conditions=dict(function=check_repo))
818
684 rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}', 819 rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}',
685 controller='files', action='archivefile', 820 controller='files', action='archivefile',
686 conditions=dict(function=check_repo)) 821 conditions=dict(function=check_repo))
687 822
688 rmap.connect('files_nodelist_home', 823 rmap.connect('files_nodelist_home',