##// END OF EJS Templates
added global fix for stripping multiple slashes from f_path variable
marcink -
r3040:ec483ce6 beta
parent child Browse files
Show More
@@ -1,616 +1,620 b''
1 """
1 """
2 Routes configuration
2 Routes configuration
3
3
4 The more specific and detailed routes should be defined first so they
4 The more specific and detailed routes should be defined first so they
5 may take precedent over the more generic routes. For more information
5 may take precedent over the more generic routes. For more information
6 refer to the routes manual at http://routes.groovie.org/docs/
6 refer to the routes manual at http://routes.groovie.org/docs/
7 """
7 """
8 from __future__ import with_statement
8 from __future__ import with_statement
9 from routes import Mapper
9 from routes import Mapper
10
10
11 # prefix for non repository related links needs to be prefixed with `/`
11 # prefix for non repository related links needs to be prefixed with `/`
12 ADMIN_PREFIX = '/_admin'
12 ADMIN_PREFIX = '/_admin'
13
13
14
14
15 def make_map(config):
15 def make_map(config):
16 """Create, configure and return the routes Mapper"""
16 """Create, configure and return the routes Mapper"""
17 rmap = Mapper(directory=config['pylons.paths']['controllers'],
17 rmap = Mapper(directory=config['pylons.paths']['controllers'],
18 always_scan=config['debug'])
18 always_scan=config['debug'])
19 rmap.minimization = False
19 rmap.minimization = False
20 rmap.explicit = False
20 rmap.explicit = False
21
21
22 from rhodecode.lib.utils import is_valid_repo
22 from rhodecode.lib.utils import is_valid_repo
23 from rhodecode.lib.utils import is_valid_repos_group
23 from rhodecode.lib.utils import is_valid_repos_group
24
24
25 def check_repo(environ, match_dict):
25 def check_repo(environ, match_dict):
26 """
26 """
27 check for valid repository for proper 404 handling
27 check for valid repository for proper 404 handling
28
28
29 :param environ:
29 :param environ:
30 :param match_dict:
30 :param match_dict:
31 """
31 """
32 from rhodecode.model.db import Repository
32 from rhodecode.model.db import Repository
33 repo_name = match_dict.get('repo_name')
33 repo_name = match_dict.get('repo_name')
34
34
35 if match_dict.get('f_path'):
36 #fix for multiple initial slashes that causes errors
37 match_dict['f_path'] = match_dict['f_path'].lstrip('/')
38
35 try:
39 try:
36 by_id = repo_name.split('_')
40 by_id = repo_name.split('_')
37 if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '':
41 if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '':
38 repo_name = Repository.get(by_id[1]).repo_name
42 repo_name = Repository.get(by_id[1]).repo_name
39 match_dict['repo_name'] = repo_name
43 match_dict['repo_name'] = repo_name
40 except:
44 except:
41 pass
45 pass
42
46
43 return is_valid_repo(repo_name, config['base_path'])
47 return is_valid_repo(repo_name, config['base_path'])
44
48
45 def check_group(environ, match_dict):
49 def check_group(environ, match_dict):
46 """
50 """
47 check for valid repositories group for proper 404 handling
51 check for valid repositories group for proper 404 handling
48
52
49 :param environ:
53 :param environ:
50 :param match_dict:
54 :param match_dict:
51 """
55 """
52 repos_group_name = match_dict.get('group_name')
56 repos_group_name = match_dict.get('group_name')
53
57
54 return is_valid_repos_group(repos_group_name, config['base_path'])
58 return is_valid_repos_group(repos_group_name, config['base_path'])
55
59
56 def check_int(environ, match_dict):
60 def check_int(environ, match_dict):
57 return match_dict.get('id').isdigit()
61 return match_dict.get('id').isdigit()
58
62
59 # The ErrorController route (handles 404/500 error pages); it should
63 # The ErrorController route (handles 404/500 error pages); it should
60 # likely stay at the top, ensuring it can always be resolved
64 # likely stay at the top, ensuring it can always be resolved
61 rmap.connect('/error/{action}', controller='error')
65 rmap.connect('/error/{action}', controller='error')
62 rmap.connect('/error/{action}/{id}', controller='error')
66 rmap.connect('/error/{action}/{id}', controller='error')
63
67
64 #==========================================================================
68 #==========================================================================
65 # CUSTOM ROUTES HERE
69 # CUSTOM ROUTES HERE
66 #==========================================================================
70 #==========================================================================
67
71
68 #MAIN PAGE
72 #MAIN PAGE
69 rmap.connect('home', '/', controller='home', action='index')
73 rmap.connect('home', '/', controller='home', action='index')
70 rmap.connect('repo_switcher', '/repos', controller='home',
74 rmap.connect('repo_switcher', '/repos', controller='home',
71 action='repo_switcher')
75 action='repo_switcher')
72 rmap.connect('branch_tag_switcher', '/branches-tags/{repo_name:.*?}',
76 rmap.connect('branch_tag_switcher', '/branches-tags/{repo_name:.*?}',
73 controller='home', action='branch_tag_switcher')
77 controller='home', action='branch_tag_switcher')
74 rmap.connect('bugtracker',
78 rmap.connect('bugtracker',
75 "http://bitbucket.org/marcinkuzminski/rhodecode/issues",
79 "http://bitbucket.org/marcinkuzminski/rhodecode/issues",
76 _static=True)
80 _static=True)
77 rmap.connect('rst_help',
81 rmap.connect('rst_help',
78 "http://docutils.sourceforge.net/docs/user/rst/quickref.html",
82 "http://docutils.sourceforge.net/docs/user/rst/quickref.html",
79 _static=True)
83 _static=True)
80 rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True)
84 rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True)
81
85
82 #ADMIN REPOSITORY REST ROUTES
86 #ADMIN REPOSITORY REST ROUTES
83 with rmap.submapper(path_prefix=ADMIN_PREFIX,
87 with rmap.submapper(path_prefix=ADMIN_PREFIX,
84 controller='admin/repos') as m:
88 controller='admin/repos') as m:
85 m.connect("repos", "/repos",
89 m.connect("repos", "/repos",
86 action="create", conditions=dict(method=["POST"]))
90 action="create", conditions=dict(method=["POST"]))
87 m.connect("repos", "/repos",
91 m.connect("repos", "/repos",
88 action="index", conditions=dict(method=["GET"]))
92 action="index", conditions=dict(method=["GET"]))
89 m.connect("formatted_repos", "/repos.{format}",
93 m.connect("formatted_repos", "/repos.{format}",
90 action="index",
94 action="index",
91 conditions=dict(method=["GET"]))
95 conditions=dict(method=["GET"]))
92 m.connect("new_repo", "/repos/new",
96 m.connect("new_repo", "/repos/new",
93 action="new", conditions=dict(method=["GET"]))
97 action="new", conditions=dict(method=["GET"]))
94 m.connect("formatted_new_repo", "/repos/new.{format}",
98 m.connect("formatted_new_repo", "/repos/new.{format}",
95 action="new", conditions=dict(method=["GET"]))
99 action="new", conditions=dict(method=["GET"]))
96 m.connect("/repos/{repo_name:.*?}",
100 m.connect("/repos/{repo_name:.*?}",
97 action="update", conditions=dict(method=["PUT"],
101 action="update", conditions=dict(method=["PUT"],
98 function=check_repo))
102 function=check_repo))
99 m.connect("/repos/{repo_name:.*?}",
103 m.connect("/repos/{repo_name:.*?}",
100 action="delete", conditions=dict(method=["DELETE"],
104 action="delete", conditions=dict(method=["DELETE"],
101 function=check_repo))
105 function=check_repo))
102 m.connect("edit_repo", "/repos/{repo_name:.*?}/edit",
106 m.connect("edit_repo", "/repos/{repo_name:.*?}/edit",
103 action="edit", conditions=dict(method=["GET"],
107 action="edit", conditions=dict(method=["GET"],
104 function=check_repo))
108 function=check_repo))
105 m.connect("formatted_edit_repo", "/repos/{repo_name:.*?}.{format}/edit",
109 m.connect("formatted_edit_repo", "/repos/{repo_name:.*?}.{format}/edit",
106 action="edit", conditions=dict(method=["GET"],
110 action="edit", conditions=dict(method=["GET"],
107 function=check_repo))
111 function=check_repo))
108 m.connect("repo", "/repos/{repo_name:.*?}",
112 m.connect("repo", "/repos/{repo_name:.*?}",
109 action="show", conditions=dict(method=["GET"],
113 action="show", conditions=dict(method=["GET"],
110 function=check_repo))
114 function=check_repo))
111 m.connect("formatted_repo", "/repos/{repo_name:.*?}.{format}",
115 m.connect("formatted_repo", "/repos/{repo_name:.*?}.{format}",
112 action="show", conditions=dict(method=["GET"],
116 action="show", conditions=dict(method=["GET"],
113 function=check_repo))
117 function=check_repo))
114 #ajax delete repo perm user
118 #ajax delete repo perm user
115 m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*?}",
119 m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*?}",
116 action="delete_perm_user",
120 action="delete_perm_user",
117 conditions=dict(method=["DELETE"], function=check_repo))
121 conditions=dict(method=["DELETE"], function=check_repo))
118
122
119 #ajax delete repo perm users_group
123 #ajax delete repo perm users_group
120 m.connect('delete_repo_users_group',
124 m.connect('delete_repo_users_group',
121 "/repos_delete_users_group/{repo_name:.*?}",
125 "/repos_delete_users_group/{repo_name:.*?}",
122 action="delete_perm_users_group",
126 action="delete_perm_users_group",
123 conditions=dict(method=["DELETE"], function=check_repo))
127 conditions=dict(method=["DELETE"], function=check_repo))
124
128
125 #settings actions
129 #settings actions
126 m.connect('repo_stats', "/repos_stats/{repo_name:.*?}",
130 m.connect('repo_stats', "/repos_stats/{repo_name:.*?}",
127 action="repo_stats", conditions=dict(method=["DELETE"],
131 action="repo_stats", conditions=dict(method=["DELETE"],
128 function=check_repo))
132 function=check_repo))
129 m.connect('repo_cache', "/repos_cache/{repo_name:.*?}",
133 m.connect('repo_cache', "/repos_cache/{repo_name:.*?}",
130 action="repo_cache", conditions=dict(method=["DELETE"],
134 action="repo_cache", conditions=dict(method=["DELETE"],
131 function=check_repo))
135 function=check_repo))
132 m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*?}",
136 m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*?}",
133 action="repo_public_journal", conditions=dict(method=["PUT"],
137 action="repo_public_journal", conditions=dict(method=["PUT"],
134 function=check_repo))
138 function=check_repo))
135 m.connect('repo_pull', "/repo_pull/{repo_name:.*?}",
139 m.connect('repo_pull', "/repo_pull/{repo_name:.*?}",
136 action="repo_pull", conditions=dict(method=["PUT"],
140 action="repo_pull", conditions=dict(method=["PUT"],
137 function=check_repo))
141 function=check_repo))
138 m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*?}",
142 m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*?}",
139 action="repo_as_fork", conditions=dict(method=["PUT"],
143 action="repo_as_fork", conditions=dict(method=["PUT"],
140 function=check_repo))
144 function=check_repo))
141 m.connect('repo_locking', "/repo_locking/{repo_name:.*?}",
145 m.connect('repo_locking', "/repo_locking/{repo_name:.*?}",
142 action="repo_locking", conditions=dict(method=["PUT"],
146 action="repo_locking", conditions=dict(method=["PUT"],
143 function=check_repo))
147 function=check_repo))
144
148
145 with rmap.submapper(path_prefix=ADMIN_PREFIX,
149 with rmap.submapper(path_prefix=ADMIN_PREFIX,
146 controller='admin/repos_groups') as m:
150 controller='admin/repos_groups') as m:
147 m.connect("repos_groups", "/repos_groups",
151 m.connect("repos_groups", "/repos_groups",
148 action="create", conditions=dict(method=["POST"]))
152 action="create", conditions=dict(method=["POST"]))
149 m.connect("repos_groups", "/repos_groups",
153 m.connect("repos_groups", "/repos_groups",
150 action="index", conditions=dict(method=["GET"]))
154 action="index", conditions=dict(method=["GET"]))
151 m.connect("formatted_repos_groups", "/repos_groups.{format}",
155 m.connect("formatted_repos_groups", "/repos_groups.{format}",
152 action="index", conditions=dict(method=["GET"]))
156 action="index", conditions=dict(method=["GET"]))
153 m.connect("new_repos_group", "/repos_groups/new",
157 m.connect("new_repos_group", "/repos_groups/new",
154 action="new", conditions=dict(method=["GET"]))
158 action="new", conditions=dict(method=["GET"]))
155 m.connect("formatted_new_repos_group", "/repos_groups/new.{format}",
159 m.connect("formatted_new_repos_group", "/repos_groups/new.{format}",
156 action="new", conditions=dict(method=["GET"]))
160 action="new", conditions=dict(method=["GET"]))
157 m.connect("update_repos_group", "/repos_groups/{id}",
161 m.connect("update_repos_group", "/repos_groups/{id}",
158 action="update", conditions=dict(method=["PUT"],
162 action="update", conditions=dict(method=["PUT"],
159 function=check_int))
163 function=check_int))
160 m.connect("delete_repos_group", "/repos_groups/{id}",
164 m.connect("delete_repos_group", "/repos_groups/{id}",
161 action="delete", conditions=dict(method=["DELETE"],
165 action="delete", conditions=dict(method=["DELETE"],
162 function=check_int))
166 function=check_int))
163 m.connect("edit_repos_group", "/repos_groups/{id:.*?}/edit",
167 m.connect("edit_repos_group", "/repos_groups/{id:.*?}/edit",
164 action="edit", conditions=dict(method=["GET"],))
168 action="edit", conditions=dict(method=["GET"],))
165 m.connect("formatted_edit_repos_group",
169 m.connect("formatted_edit_repos_group",
166 "/repos_groups/{id}.{format}/edit",
170 "/repos_groups/{id}.{format}/edit",
167 action="edit", conditions=dict(method=["GET"],
171 action="edit", conditions=dict(method=["GET"],
168 function=check_int))
172 function=check_int))
169 m.connect("repos_group", "/repos_groups/{id}",
173 m.connect("repos_group", "/repos_groups/{id}",
170 action="show", conditions=dict(method=["GET"],
174 action="show", conditions=dict(method=["GET"],
171 function=check_int))
175 function=check_int))
172 m.connect("formatted_repos_group", "/repos_groups/{id}.{format}",
176 m.connect("formatted_repos_group", "/repos_groups/{id}.{format}",
173 action="show", conditions=dict(method=["GET"],
177 action="show", conditions=dict(method=["GET"],
174 function=check_int))
178 function=check_int))
175 # ajax delete repos group perm user
179 # ajax delete repos group perm user
176 m.connect('delete_repos_group_user_perm',
180 m.connect('delete_repos_group_user_perm',
177 "/delete_repos_group_user_perm/{group_name:.*}",
181 "/delete_repos_group_user_perm/{group_name:.*}",
178 action="delete_repos_group_user_perm",
182 action="delete_repos_group_user_perm",
179 conditions=dict(method=["DELETE"], function=check_group))
183 conditions=dict(method=["DELETE"], function=check_group))
180
184
181 # ajax delete repos group perm users_group
185 # ajax delete repos group perm users_group
182 m.connect('delete_repos_group_users_group_perm',
186 m.connect('delete_repos_group_users_group_perm',
183 "/delete_repos_group_users_group_perm/{group_name:.*}",
187 "/delete_repos_group_users_group_perm/{group_name:.*}",
184 action="delete_repos_group_users_group_perm",
188 action="delete_repos_group_users_group_perm",
185 conditions=dict(method=["DELETE"], function=check_group))
189 conditions=dict(method=["DELETE"], function=check_group))
186
190
187 #ADMIN USER REST ROUTES
191 #ADMIN USER REST ROUTES
188 with rmap.submapper(path_prefix=ADMIN_PREFIX,
192 with rmap.submapper(path_prefix=ADMIN_PREFIX,
189 controller='admin/users') as m:
193 controller='admin/users') as m:
190 m.connect("users", "/users",
194 m.connect("users", "/users",
191 action="create", conditions=dict(method=["POST"]))
195 action="create", conditions=dict(method=["POST"]))
192 m.connect("users", "/users",
196 m.connect("users", "/users",
193 action="index", conditions=dict(method=["GET"]))
197 action="index", conditions=dict(method=["GET"]))
194 m.connect("formatted_users", "/users.{format}",
198 m.connect("formatted_users", "/users.{format}",
195 action="index", conditions=dict(method=["GET"]))
199 action="index", conditions=dict(method=["GET"]))
196 m.connect("new_user", "/users/new",
200 m.connect("new_user", "/users/new",
197 action="new", conditions=dict(method=["GET"]))
201 action="new", conditions=dict(method=["GET"]))
198 m.connect("formatted_new_user", "/users/new.{format}",
202 m.connect("formatted_new_user", "/users/new.{format}",
199 action="new", conditions=dict(method=["GET"]))
203 action="new", conditions=dict(method=["GET"]))
200 m.connect("update_user", "/users/{id}",
204 m.connect("update_user", "/users/{id}",
201 action="update", conditions=dict(method=["PUT"]))
205 action="update", conditions=dict(method=["PUT"]))
202 m.connect("delete_user", "/users/{id}",
206 m.connect("delete_user", "/users/{id}",
203 action="delete", conditions=dict(method=["DELETE"]))
207 action="delete", conditions=dict(method=["DELETE"]))
204 m.connect("edit_user", "/users/{id}/edit",
208 m.connect("edit_user", "/users/{id}/edit",
205 action="edit", conditions=dict(method=["GET"]))
209 action="edit", conditions=dict(method=["GET"]))
206 m.connect("formatted_edit_user",
210 m.connect("formatted_edit_user",
207 "/users/{id}.{format}/edit",
211 "/users/{id}.{format}/edit",
208 action="edit", conditions=dict(method=["GET"]))
212 action="edit", conditions=dict(method=["GET"]))
209 m.connect("user", "/users/{id}",
213 m.connect("user", "/users/{id}",
210 action="show", conditions=dict(method=["GET"]))
214 action="show", conditions=dict(method=["GET"]))
211 m.connect("formatted_user", "/users/{id}.{format}",
215 m.connect("formatted_user", "/users/{id}.{format}",
212 action="show", conditions=dict(method=["GET"]))
216 action="show", conditions=dict(method=["GET"]))
213
217
214 #EXTRAS USER ROUTES
218 #EXTRAS USER ROUTES
215 m.connect("user_perm", "/users_perm/{id}",
219 m.connect("user_perm", "/users_perm/{id}",
216 action="update_perm", conditions=dict(method=["PUT"]))
220 action="update_perm", conditions=dict(method=["PUT"]))
217 m.connect("user_emails", "/users_emails/{id}",
221 m.connect("user_emails", "/users_emails/{id}",
218 action="add_email", conditions=dict(method=["PUT"]))
222 action="add_email", conditions=dict(method=["PUT"]))
219 m.connect("user_emails_delete", "/users_emails/{id}",
223 m.connect("user_emails_delete", "/users_emails/{id}",
220 action="delete_email", conditions=dict(method=["DELETE"]))
224 action="delete_email", conditions=dict(method=["DELETE"]))
221
225
222 #ADMIN USERS GROUPS REST ROUTES
226 #ADMIN USERS GROUPS REST ROUTES
223 with rmap.submapper(path_prefix=ADMIN_PREFIX,
227 with rmap.submapper(path_prefix=ADMIN_PREFIX,
224 controller='admin/users_groups') as m:
228 controller='admin/users_groups') as m:
225 m.connect("users_groups", "/users_groups",
229 m.connect("users_groups", "/users_groups",
226 action="create", conditions=dict(method=["POST"]))
230 action="create", conditions=dict(method=["POST"]))
227 m.connect("users_groups", "/users_groups",
231 m.connect("users_groups", "/users_groups",
228 action="index", conditions=dict(method=["GET"]))
232 action="index", conditions=dict(method=["GET"]))
229 m.connect("formatted_users_groups", "/users_groups.{format}",
233 m.connect("formatted_users_groups", "/users_groups.{format}",
230 action="index", conditions=dict(method=["GET"]))
234 action="index", conditions=dict(method=["GET"]))
231 m.connect("new_users_group", "/users_groups/new",
235 m.connect("new_users_group", "/users_groups/new",
232 action="new", conditions=dict(method=["GET"]))
236 action="new", conditions=dict(method=["GET"]))
233 m.connect("formatted_new_users_group", "/users_groups/new.{format}",
237 m.connect("formatted_new_users_group", "/users_groups/new.{format}",
234 action="new", conditions=dict(method=["GET"]))
238 action="new", conditions=dict(method=["GET"]))
235 m.connect("update_users_group", "/users_groups/{id}",
239 m.connect("update_users_group", "/users_groups/{id}",
236 action="update", conditions=dict(method=["PUT"]))
240 action="update", conditions=dict(method=["PUT"]))
237 m.connect("delete_users_group", "/users_groups/{id}",
241 m.connect("delete_users_group", "/users_groups/{id}",
238 action="delete", conditions=dict(method=["DELETE"]))
242 action="delete", conditions=dict(method=["DELETE"]))
239 m.connect("edit_users_group", "/users_groups/{id}/edit",
243 m.connect("edit_users_group", "/users_groups/{id}/edit",
240 action="edit", conditions=dict(method=["GET"]))
244 action="edit", conditions=dict(method=["GET"]))
241 m.connect("formatted_edit_users_group",
245 m.connect("formatted_edit_users_group",
242 "/users_groups/{id}.{format}/edit",
246 "/users_groups/{id}.{format}/edit",
243 action="edit", conditions=dict(method=["GET"]))
247 action="edit", conditions=dict(method=["GET"]))
244 m.connect("users_group", "/users_groups/{id}",
248 m.connect("users_group", "/users_groups/{id}",
245 action="show", conditions=dict(method=["GET"]))
249 action="show", conditions=dict(method=["GET"]))
246 m.connect("formatted_users_group", "/users_groups/{id}.{format}",
250 m.connect("formatted_users_group", "/users_groups/{id}.{format}",
247 action="show", conditions=dict(method=["GET"]))
251 action="show", conditions=dict(method=["GET"]))
248
252
249 #EXTRAS USER ROUTES
253 #EXTRAS USER ROUTES
250 m.connect("users_group_perm", "/users_groups_perm/{id}",
254 m.connect("users_group_perm", "/users_groups_perm/{id}",
251 action="update_perm", conditions=dict(method=["PUT"]))
255 action="update_perm", conditions=dict(method=["PUT"]))
252
256
253 #ADMIN GROUP REST ROUTES
257 #ADMIN GROUP REST ROUTES
254 rmap.resource('group', 'groups',
258 rmap.resource('group', 'groups',
255 controller='admin/groups', path_prefix=ADMIN_PREFIX)
259 controller='admin/groups', path_prefix=ADMIN_PREFIX)
256
260
257 #ADMIN PERMISSIONS REST ROUTES
261 #ADMIN PERMISSIONS REST ROUTES
258 rmap.resource('permission', 'permissions',
262 rmap.resource('permission', 'permissions',
259 controller='admin/permissions', path_prefix=ADMIN_PREFIX)
263 controller='admin/permissions', path_prefix=ADMIN_PREFIX)
260
264
261 ##ADMIN LDAP SETTINGS
265 ##ADMIN LDAP SETTINGS
262 rmap.connect('ldap_settings', '%s/ldap' % ADMIN_PREFIX,
266 rmap.connect('ldap_settings', '%s/ldap' % ADMIN_PREFIX,
263 controller='admin/ldap_settings', action='ldap_settings',
267 controller='admin/ldap_settings', action='ldap_settings',
264 conditions=dict(method=["POST"]))
268 conditions=dict(method=["POST"]))
265
269
266 rmap.connect('ldap_home', '%s/ldap' % ADMIN_PREFIX,
270 rmap.connect('ldap_home', '%s/ldap' % ADMIN_PREFIX,
267 controller='admin/ldap_settings')
271 controller='admin/ldap_settings')
268
272
269 #ADMIN SETTINGS REST ROUTES
273 #ADMIN SETTINGS REST ROUTES
270 with rmap.submapper(path_prefix=ADMIN_PREFIX,
274 with rmap.submapper(path_prefix=ADMIN_PREFIX,
271 controller='admin/settings') as m:
275 controller='admin/settings') as m:
272 m.connect("admin_settings", "/settings",
276 m.connect("admin_settings", "/settings",
273 action="create", conditions=dict(method=["POST"]))
277 action="create", conditions=dict(method=["POST"]))
274 m.connect("admin_settings", "/settings",
278 m.connect("admin_settings", "/settings",
275 action="index", conditions=dict(method=["GET"]))
279 action="index", conditions=dict(method=["GET"]))
276 m.connect("formatted_admin_settings", "/settings.{format}",
280 m.connect("formatted_admin_settings", "/settings.{format}",
277 action="index", conditions=dict(method=["GET"]))
281 action="index", conditions=dict(method=["GET"]))
278 m.connect("admin_new_setting", "/settings/new",
282 m.connect("admin_new_setting", "/settings/new",
279 action="new", conditions=dict(method=["GET"]))
283 action="new", conditions=dict(method=["GET"]))
280 m.connect("formatted_admin_new_setting", "/settings/new.{format}",
284 m.connect("formatted_admin_new_setting", "/settings/new.{format}",
281 action="new", conditions=dict(method=["GET"]))
285 action="new", conditions=dict(method=["GET"]))
282 m.connect("/settings/{setting_id}",
286 m.connect("/settings/{setting_id}",
283 action="update", conditions=dict(method=["PUT"]))
287 action="update", conditions=dict(method=["PUT"]))
284 m.connect("/settings/{setting_id}",
288 m.connect("/settings/{setting_id}",
285 action="delete", conditions=dict(method=["DELETE"]))
289 action="delete", conditions=dict(method=["DELETE"]))
286 m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
290 m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
287 action="edit", conditions=dict(method=["GET"]))
291 action="edit", conditions=dict(method=["GET"]))
288 m.connect("formatted_admin_edit_setting",
292 m.connect("formatted_admin_edit_setting",
289 "/settings/{setting_id}.{format}/edit",
293 "/settings/{setting_id}.{format}/edit",
290 action="edit", conditions=dict(method=["GET"]))
294 action="edit", conditions=dict(method=["GET"]))
291 m.connect("admin_setting", "/settings/{setting_id}",
295 m.connect("admin_setting", "/settings/{setting_id}",
292 action="show", conditions=dict(method=["GET"]))
296 action="show", conditions=dict(method=["GET"]))
293 m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}",
297 m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}",
294 action="show", conditions=dict(method=["GET"]))
298 action="show", conditions=dict(method=["GET"]))
295 m.connect("admin_settings_my_account", "/my_account",
299 m.connect("admin_settings_my_account", "/my_account",
296 action="my_account", conditions=dict(method=["GET"]))
300 action="my_account", conditions=dict(method=["GET"]))
297 m.connect("admin_settings_my_account_update", "/my_account_update",
301 m.connect("admin_settings_my_account_update", "/my_account_update",
298 action="my_account_update", conditions=dict(method=["PUT"]))
302 action="my_account_update", conditions=dict(method=["PUT"]))
299 m.connect("admin_settings_create_repository", "/create_repository",
303 m.connect("admin_settings_create_repository", "/create_repository",
300 action="create_repository", conditions=dict(method=["GET"]))
304 action="create_repository", conditions=dict(method=["GET"]))
301 m.connect("admin_settings_my_repos", "/my_account/repos",
305 m.connect("admin_settings_my_repos", "/my_account/repos",
302 action="my_account_my_repos", conditions=dict(method=["GET"]))
306 action="my_account_my_repos", conditions=dict(method=["GET"]))
303 m.connect("admin_settings_my_pullrequests", "/my_account/pull_requests",
307 m.connect("admin_settings_my_pullrequests", "/my_account/pull_requests",
304 action="my_account_my_pullrequests", conditions=dict(method=["GET"]))
308 action="my_account_my_pullrequests", conditions=dict(method=["GET"]))
305
309
306 #NOTIFICATION REST ROUTES
310 #NOTIFICATION REST ROUTES
307 with rmap.submapper(path_prefix=ADMIN_PREFIX,
311 with rmap.submapper(path_prefix=ADMIN_PREFIX,
308 controller='admin/notifications') as m:
312 controller='admin/notifications') as m:
309 m.connect("notifications", "/notifications",
313 m.connect("notifications", "/notifications",
310 action="create", conditions=dict(method=["POST"]))
314 action="create", conditions=dict(method=["POST"]))
311 m.connect("notifications", "/notifications",
315 m.connect("notifications", "/notifications",
312 action="index", conditions=dict(method=["GET"]))
316 action="index", conditions=dict(method=["GET"]))
313 m.connect("notifications_mark_all_read", "/notifications/mark_all_read",
317 m.connect("notifications_mark_all_read", "/notifications/mark_all_read",
314 action="mark_all_read", conditions=dict(method=["GET"]))
318 action="mark_all_read", conditions=dict(method=["GET"]))
315 m.connect("formatted_notifications", "/notifications.{format}",
319 m.connect("formatted_notifications", "/notifications.{format}",
316 action="index", conditions=dict(method=["GET"]))
320 action="index", conditions=dict(method=["GET"]))
317 m.connect("new_notification", "/notifications/new",
321 m.connect("new_notification", "/notifications/new",
318 action="new", conditions=dict(method=["GET"]))
322 action="new", conditions=dict(method=["GET"]))
319 m.connect("formatted_new_notification", "/notifications/new.{format}",
323 m.connect("formatted_new_notification", "/notifications/new.{format}",
320 action="new", conditions=dict(method=["GET"]))
324 action="new", conditions=dict(method=["GET"]))
321 m.connect("/notification/{notification_id}",
325 m.connect("/notification/{notification_id}",
322 action="update", conditions=dict(method=["PUT"]))
326 action="update", conditions=dict(method=["PUT"]))
323 m.connect("/notification/{notification_id}",
327 m.connect("/notification/{notification_id}",
324 action="delete", conditions=dict(method=["DELETE"]))
328 action="delete", conditions=dict(method=["DELETE"]))
325 m.connect("edit_notification", "/notification/{notification_id}/edit",
329 m.connect("edit_notification", "/notification/{notification_id}/edit",
326 action="edit", conditions=dict(method=["GET"]))
330 action="edit", conditions=dict(method=["GET"]))
327 m.connect("formatted_edit_notification",
331 m.connect("formatted_edit_notification",
328 "/notification/{notification_id}.{format}/edit",
332 "/notification/{notification_id}.{format}/edit",
329 action="edit", conditions=dict(method=["GET"]))
333 action="edit", conditions=dict(method=["GET"]))
330 m.connect("notification", "/notification/{notification_id}",
334 m.connect("notification", "/notification/{notification_id}",
331 action="show", conditions=dict(method=["GET"]))
335 action="show", conditions=dict(method=["GET"]))
332 m.connect("formatted_notification", "/notifications/{notification_id}.{format}",
336 m.connect("formatted_notification", "/notifications/{notification_id}.{format}",
333 action="show", conditions=dict(method=["GET"]))
337 action="show", conditions=dict(method=["GET"]))
334
338
335 #ADMIN MAIN PAGES
339 #ADMIN MAIN PAGES
336 with rmap.submapper(path_prefix=ADMIN_PREFIX,
340 with rmap.submapper(path_prefix=ADMIN_PREFIX,
337 controller='admin/admin') as m:
341 controller='admin/admin') as m:
338 m.connect('admin_home', '', action='index')
342 m.connect('admin_home', '', action='index')
339 m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
343 m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
340 action='add_repo')
344 action='add_repo')
341
345
342 #==========================================================================
346 #==========================================================================
343 # API V2
347 # API V2
344 #==========================================================================
348 #==========================================================================
345 with rmap.submapper(path_prefix=ADMIN_PREFIX,
349 with rmap.submapper(path_prefix=ADMIN_PREFIX,
346 controller='api/api') as m:
350 controller='api/api') as m:
347 m.connect('api', '/api')
351 m.connect('api', '/api')
348
352
349 #USER JOURNAL
353 #USER JOURNAL
350 rmap.connect('journal_my_repos', '%s/journal_my_repos' % ADMIN_PREFIX,
354 rmap.connect('journal_my_repos', '%s/journal_my_repos' % ADMIN_PREFIX,
351 controller='journal', action='index_my_repos')
355 controller='journal', action='index_my_repos')
352 rmap.connect('journal', '%s/journal' % ADMIN_PREFIX,
356 rmap.connect('journal', '%s/journal' % ADMIN_PREFIX,
353 controller='journal', action='index')
357 controller='journal', action='index')
354 rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX,
358 rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX,
355 controller='journal', action='journal_rss')
359 controller='journal', action='journal_rss')
356 rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX,
360 rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX,
357 controller='journal', action='journal_atom')
361 controller='journal', action='journal_atom')
358
362
359 rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX,
363 rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX,
360 controller='journal', action="public_journal")
364 controller='journal', action="public_journal")
361
365
362 rmap.connect('public_journal_rss', '%s/public_journal/rss' % ADMIN_PREFIX,
366 rmap.connect('public_journal_rss', '%s/public_journal/rss' % ADMIN_PREFIX,
363 controller='journal', action="public_journal_rss")
367 controller='journal', action="public_journal_rss")
364
368
365 rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % ADMIN_PREFIX,
369 rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % ADMIN_PREFIX,
366 controller='journal', action="public_journal_rss")
370 controller='journal', action="public_journal_rss")
367
371
368 rmap.connect('public_journal_atom',
372 rmap.connect('public_journal_atom',
369 '%s/public_journal/atom' % ADMIN_PREFIX, controller='journal',
373 '%s/public_journal/atom' % ADMIN_PREFIX, controller='journal',
370 action="public_journal_atom")
374 action="public_journal_atom")
371
375
372 rmap.connect('public_journal_atom_old',
376 rmap.connect('public_journal_atom_old',
373 '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal',
377 '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal',
374 action="public_journal_atom")
378 action="public_journal_atom")
375
379
376 rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX,
380 rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX,
377 controller='journal', action='toggle_following',
381 controller='journal', action='toggle_following',
378 conditions=dict(method=["POST"]))
382 conditions=dict(method=["POST"]))
379
383
380 #SEARCH
384 #SEARCH
381 rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',)
385 rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',)
382 rmap.connect('search_repo', '%s/search/{search_repo:.*}' % ADMIN_PREFIX,
386 rmap.connect('search_repo', '%s/search/{search_repo:.*}' % ADMIN_PREFIX,
383 controller='search')
387 controller='search')
384
388
385 #LOGIN/LOGOUT/REGISTER/SIGN IN
389 #LOGIN/LOGOUT/REGISTER/SIGN IN
386 rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login')
390 rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login')
387 rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login',
391 rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login',
388 action='logout')
392 action='logout')
389
393
390 rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login',
394 rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login',
391 action='register')
395 action='register')
392
396
393 rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX,
397 rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX,
394 controller='login', action='password_reset')
398 controller='login', action='password_reset')
395
399
396 rmap.connect('reset_password_confirmation',
400 rmap.connect('reset_password_confirmation',
397 '%s/password_reset_confirmation' % ADMIN_PREFIX,
401 '%s/password_reset_confirmation' % ADMIN_PREFIX,
398 controller='login', action='password_reset_confirmation')
402 controller='login', action='password_reset_confirmation')
399
403
400 #FEEDS
404 #FEEDS
401 rmap.connect('rss_feed_home', '/{repo_name:.*?}/feed/rss',
405 rmap.connect('rss_feed_home', '/{repo_name:.*?}/feed/rss',
402 controller='feed', action='rss',
406 controller='feed', action='rss',
403 conditions=dict(function=check_repo))
407 conditions=dict(function=check_repo))
404
408
405 rmap.connect('atom_feed_home', '/{repo_name:.*?}/feed/atom',
409 rmap.connect('atom_feed_home', '/{repo_name:.*?}/feed/atom',
406 controller='feed', action='atom',
410 controller='feed', action='atom',
407 conditions=dict(function=check_repo))
411 conditions=dict(function=check_repo))
408
412
409 #==========================================================================
413 #==========================================================================
410 # REPOSITORY ROUTES
414 # REPOSITORY ROUTES
411 #==========================================================================
415 #==========================================================================
412 rmap.connect('summary_home', '/{repo_name:.*?}',
416 rmap.connect('summary_home', '/{repo_name:.*?}',
413 controller='summary',
417 controller='summary',
414 conditions=dict(function=check_repo))
418 conditions=dict(function=check_repo))
415
419
416 rmap.connect('repos_group_home', '/{group_name:.*}',
420 rmap.connect('repos_group_home', '/{group_name:.*}',
417 controller='admin/repos_groups', action="show_by_name",
421 controller='admin/repos_groups', action="show_by_name",
418 conditions=dict(function=check_group))
422 conditions=dict(function=check_group))
419
423
420 rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}',
424 rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}',
421 controller='changeset', revision='tip',
425 controller='changeset', revision='tip',
422 conditions=dict(function=check_repo))
426 conditions=dict(function=check_repo))
423
427
424 #still working url for backward compat.
428 #still working url for backward compat.
425 rmap.connect('raw_changeset_home_depraced',
429 rmap.connect('raw_changeset_home_depraced',
426 '/{repo_name:.*?}/raw-changeset/{revision}',
430 '/{repo_name:.*?}/raw-changeset/{revision}',
427 controller='changeset', action='changeset_raw',
431 controller='changeset', action='changeset_raw',
428 revision='tip', conditions=dict(function=check_repo))
432 revision='tip', conditions=dict(function=check_repo))
429
433
430 ## new URLs
434 ## new URLs
431 rmap.connect('changeset_raw_home',
435 rmap.connect('changeset_raw_home',
432 '/{repo_name:.*?}/changeset-diff/{revision}',
436 '/{repo_name:.*?}/changeset-diff/{revision}',
433 controller='changeset', action='changeset_raw',
437 controller='changeset', action='changeset_raw',
434 revision='tip', conditions=dict(function=check_repo))
438 revision='tip', conditions=dict(function=check_repo))
435
439
436 rmap.connect('changeset_patch_home',
440 rmap.connect('changeset_patch_home',
437 '/{repo_name:.*?}/changeset-patch/{revision}',
441 '/{repo_name:.*?}/changeset-patch/{revision}',
438 controller='changeset', action='changeset_patch',
442 controller='changeset', action='changeset_patch',
439 revision='tip', conditions=dict(function=check_repo))
443 revision='tip', conditions=dict(function=check_repo))
440
444
441 rmap.connect('changeset_download_home',
445 rmap.connect('changeset_download_home',
442 '/{repo_name:.*?}/changeset-download/{revision}',
446 '/{repo_name:.*?}/changeset-download/{revision}',
443 controller='changeset', action='changeset_download',
447 controller='changeset', action='changeset_download',
444 revision='tip', conditions=dict(function=check_repo))
448 revision='tip', conditions=dict(function=check_repo))
445
449
446 rmap.connect('changeset_comment',
450 rmap.connect('changeset_comment',
447 '/{repo_name:.*?}/changeset/{revision}/comment',
451 '/{repo_name:.*?}/changeset/{revision}/comment',
448 controller='changeset', revision='tip', action='comment',
452 controller='changeset', revision='tip', action='comment',
449 conditions=dict(function=check_repo))
453 conditions=dict(function=check_repo))
450
454
451 rmap.connect('changeset_comment_delete',
455 rmap.connect('changeset_comment_delete',
452 '/{repo_name:.*?}/changeset/comment/{comment_id}/delete',
456 '/{repo_name:.*?}/changeset/comment/{comment_id}/delete',
453 controller='changeset', action='delete_comment',
457 controller='changeset', action='delete_comment',
454 conditions=dict(function=check_repo, method=["DELETE"]))
458 conditions=dict(function=check_repo, method=["DELETE"]))
455
459
456 rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}',
460 rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}',
457 controller='changeset', action='changeset_info')
461 controller='changeset', action='changeset_info')
458
462
459 rmap.connect('compare_url',
463 rmap.connect('compare_url',
460 '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}',
464 '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}',
461 controller='compare', action='index',
465 controller='compare', action='index',
462 conditions=dict(function=check_repo),
466 conditions=dict(function=check_repo),
463 requirements=dict(
467 requirements=dict(
464 org_ref_type='(branch|book|tag|rev|org_ref_type)',
468 org_ref_type='(branch|book|tag|rev|org_ref_type)',
465 other_ref_type='(branch|book|tag|rev|other_ref_type)')
469 other_ref_type='(branch|book|tag|rev|other_ref_type)')
466 )
470 )
467
471
468 rmap.connect('pullrequest_home',
472 rmap.connect('pullrequest_home',
469 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
473 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
470 action='index', conditions=dict(function=check_repo,
474 action='index', conditions=dict(function=check_repo,
471 method=["GET"]))
475 method=["GET"]))
472
476
473 rmap.connect('pullrequest',
477 rmap.connect('pullrequest',
474 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
478 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
475 action='create', conditions=dict(function=check_repo,
479 action='create', conditions=dict(function=check_repo,
476 method=["POST"]))
480 method=["POST"]))
477
481
478 rmap.connect('pullrequest_show',
482 rmap.connect('pullrequest_show',
479 '/{repo_name:.*?}/pull-request/{pull_request_id}',
483 '/{repo_name:.*?}/pull-request/{pull_request_id}',
480 controller='pullrequests',
484 controller='pullrequests',
481 action='show', conditions=dict(function=check_repo,
485 action='show', conditions=dict(function=check_repo,
482 method=["GET"]))
486 method=["GET"]))
483 rmap.connect('pullrequest_update',
487 rmap.connect('pullrequest_update',
484 '/{repo_name:.*?}/pull-request/{pull_request_id}',
488 '/{repo_name:.*?}/pull-request/{pull_request_id}',
485 controller='pullrequests',
489 controller='pullrequests',
486 action='update', conditions=dict(function=check_repo,
490 action='update', conditions=dict(function=check_repo,
487 method=["PUT"]))
491 method=["PUT"]))
488 rmap.connect('pullrequest_delete',
492 rmap.connect('pullrequest_delete',
489 '/{repo_name:.*?}/pull-request/{pull_request_id}',
493 '/{repo_name:.*?}/pull-request/{pull_request_id}',
490 controller='pullrequests',
494 controller='pullrequests',
491 action='delete', conditions=dict(function=check_repo,
495 action='delete', conditions=dict(function=check_repo,
492 method=["DELETE"]))
496 method=["DELETE"]))
493
497
494 rmap.connect('pullrequest_show_all',
498 rmap.connect('pullrequest_show_all',
495 '/{repo_name:.*?}/pull-request',
499 '/{repo_name:.*?}/pull-request',
496 controller='pullrequests',
500 controller='pullrequests',
497 action='show_all', conditions=dict(function=check_repo,
501 action='show_all', conditions=dict(function=check_repo,
498 method=["GET"]))
502 method=["GET"]))
499
503
500 rmap.connect('pullrequest_comment',
504 rmap.connect('pullrequest_comment',
501 '/{repo_name:.*?}/pull-request-comment/{pull_request_id}',
505 '/{repo_name:.*?}/pull-request-comment/{pull_request_id}',
502 controller='pullrequests',
506 controller='pullrequests',
503 action='comment', conditions=dict(function=check_repo,
507 action='comment', conditions=dict(function=check_repo,
504 method=["POST"]))
508 method=["POST"]))
505
509
506 rmap.connect('pullrequest_comment_delete',
510 rmap.connect('pullrequest_comment_delete',
507 '/{repo_name:.*?}/pull-request-comment/{comment_id}/delete',
511 '/{repo_name:.*?}/pull-request-comment/{comment_id}/delete',
508 controller='pullrequests', action='delete_comment',
512 controller='pullrequests', action='delete_comment',
509 conditions=dict(function=check_repo, method=["DELETE"]))
513 conditions=dict(function=check_repo, method=["DELETE"]))
510
514
511 rmap.connect('summary_home', '/{repo_name:.*?}/summary',
515 rmap.connect('summary_home', '/{repo_name:.*?}/summary',
512 controller='summary', conditions=dict(function=check_repo))
516 controller='summary', conditions=dict(function=check_repo))
513
517
514 rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog',
518 rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog',
515 controller='shortlog', conditions=dict(function=check_repo))
519 controller='shortlog', conditions=dict(function=check_repo))
516
520
517 rmap.connect('shortlog_file_home', '/{repo_name:.*?}/shortlog/{revision}/{f_path:.*}',
521 rmap.connect('shortlog_file_home', '/{repo_name:.*?}/shortlog/{revision}/{f_path:.*}',
518 controller='shortlog', f_path=None,
522 controller='shortlog', f_path=None,
519 conditions=dict(function=check_repo))
523 conditions=dict(function=check_repo))
520
524
521 rmap.connect('branches_home', '/{repo_name:.*?}/branches',
525 rmap.connect('branches_home', '/{repo_name:.*?}/branches',
522 controller='branches', conditions=dict(function=check_repo))
526 controller='branches', conditions=dict(function=check_repo))
523
527
524 rmap.connect('tags_home', '/{repo_name:.*?}/tags',
528 rmap.connect('tags_home', '/{repo_name:.*?}/tags',
525 controller='tags', conditions=dict(function=check_repo))
529 controller='tags', conditions=dict(function=check_repo))
526
530
527 rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks',
531 rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks',
528 controller='bookmarks', conditions=dict(function=check_repo))
532 controller='bookmarks', conditions=dict(function=check_repo))
529
533
530 rmap.connect('changelog_home', '/{repo_name:.*?}/changelog',
534 rmap.connect('changelog_home', '/{repo_name:.*?}/changelog',
531 controller='changelog', conditions=dict(function=check_repo))
535 controller='changelog', conditions=dict(function=check_repo))
532
536
533 rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}',
537 rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}',
534 controller='changelog', action='changelog_details',
538 controller='changelog', action='changelog_details',
535 conditions=dict(function=check_repo))
539 conditions=dict(function=check_repo))
536
540
537 rmap.connect('files_home', '/{repo_name:.*?}/files/{revision}/{f_path:.*}',
541 rmap.connect('files_home', '/{repo_name:.*?}/files/{revision}/{f_path:.*}',
538 controller='files', revision='tip', f_path='',
542 controller='files', revision='tip', f_path='',
539 conditions=dict(function=check_repo))
543 conditions=dict(function=check_repo))
540
544
541 rmap.connect('files_history_home',
545 rmap.connect('files_history_home',
542 '/{repo_name:.*?}/history/{revision}/{f_path:.*}',
546 '/{repo_name:.*?}/history/{revision}/{f_path:.*}',
543 controller='files', action='history', revision='tip', f_path='',
547 controller='files', action='history', revision='tip', f_path='',
544 conditions=dict(function=check_repo))
548 conditions=dict(function=check_repo))
545
549
546 rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}',
550 rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}',
547 controller='files', action='diff', revision='tip', f_path='',
551 controller='files', action='diff', revision='tip', f_path='',
548 conditions=dict(function=check_repo))
552 conditions=dict(function=check_repo))
549
553
550 rmap.connect('files_rawfile_home',
554 rmap.connect('files_rawfile_home',
551 '/{repo_name:.*?}/rawfile/{revision}/{f_path:.*}',
555 '/{repo_name:.*?}/rawfile/{revision}/{f_path:.*}',
552 controller='files', action='rawfile', revision='tip',
556 controller='files', action='rawfile', revision='tip',
553 f_path='', conditions=dict(function=check_repo))
557 f_path='', conditions=dict(function=check_repo))
554
558
555 rmap.connect('files_raw_home',
559 rmap.connect('files_raw_home',
556 '/{repo_name:.*?}/raw/{revision}/{f_path:.*}',
560 '/{repo_name:.*?}/raw/{revision}/{f_path:.*}',
557 controller='files', action='raw', revision='tip', f_path='',
561 controller='files', action='raw', revision='tip', f_path='',
558 conditions=dict(function=check_repo))
562 conditions=dict(function=check_repo))
559
563
560 rmap.connect('files_annotate_home',
564 rmap.connect('files_annotate_home',
561 '/{repo_name:.*?}/annotate/{revision}/{f_path:.*}',
565 '/{repo_name:.*?}/annotate/{revision}/{f_path:.*}',
562 controller='files', action='index', revision='tip',
566 controller='files', action='index', revision='tip',
563 f_path='', annotate=True, conditions=dict(function=check_repo))
567 f_path='', annotate=True, conditions=dict(function=check_repo))
564
568
565 rmap.connect('files_edit_home',
569 rmap.connect('files_edit_home',
566 '/{repo_name:.*?}/edit/{revision}/{f_path:.*}',
570 '/{repo_name:.*?}/edit/{revision}/{f_path:.*}',
567 controller='files', action='edit', revision='tip',
571 controller='files', action='edit', revision='tip',
568 f_path='', conditions=dict(function=check_repo))
572 f_path='', conditions=dict(function=check_repo))
569
573
570 rmap.connect('files_add_home',
574 rmap.connect('files_add_home',
571 '/{repo_name:.*?}/add/{revision}/{f_path:.*}',
575 '/{repo_name:.*?}/add/{revision}/{f_path:.*}',
572 controller='files', action='add', revision='tip',
576 controller='files', action='add', revision='tip',
573 f_path='', conditions=dict(function=check_repo))
577 f_path='', conditions=dict(function=check_repo))
574
578
575 rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}',
579 rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}',
576 controller='files', action='archivefile',
580 controller='files', action='archivefile',
577 conditions=dict(function=check_repo))
581 conditions=dict(function=check_repo))
578
582
579 rmap.connect('files_nodelist_home',
583 rmap.connect('files_nodelist_home',
580 '/{repo_name:.*?}/nodelist/{revision}/{f_path:.*}',
584 '/{repo_name:.*?}/nodelist/{revision}/{f_path:.*}',
581 controller='files', action='nodelist',
585 controller='files', action='nodelist',
582 conditions=dict(function=check_repo))
586 conditions=dict(function=check_repo))
583
587
584 rmap.connect('repo_settings_delete', '/{repo_name:.*?}/settings',
588 rmap.connect('repo_settings_delete', '/{repo_name:.*?}/settings',
585 controller='settings', action="delete",
589 controller='settings', action="delete",
586 conditions=dict(method=["DELETE"], function=check_repo))
590 conditions=dict(method=["DELETE"], function=check_repo))
587
591
588 rmap.connect('repo_settings_update', '/{repo_name:.*?}/settings',
592 rmap.connect('repo_settings_update', '/{repo_name:.*?}/settings',
589 controller='settings', action="update",
593 controller='settings', action="update",
590 conditions=dict(method=["PUT"], function=check_repo))
594 conditions=dict(method=["PUT"], function=check_repo))
591
595
592 rmap.connect('repo_settings_home', '/{repo_name:.*?}/settings',
596 rmap.connect('repo_settings_home', '/{repo_name:.*?}/settings',
593 controller='settings', action='index',
597 controller='settings', action='index',
594 conditions=dict(function=check_repo))
598 conditions=dict(function=check_repo))
595
599
596 rmap.connect('toggle_locking', "/{repo_name:.*?}/locking_toggle",
600 rmap.connect('toggle_locking', "/{repo_name:.*?}/locking_toggle",
597 controller='settings', action="toggle_locking",
601 controller='settings', action="toggle_locking",
598 conditions=dict(method=["GET"], function=check_repo))
602 conditions=dict(method=["GET"], function=check_repo))
599
603
600 rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork',
604 rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork',
601 controller='forks', action='fork_create',
605 controller='forks', action='fork_create',
602 conditions=dict(function=check_repo, method=["POST"]))
606 conditions=dict(function=check_repo, method=["POST"]))
603
607
604 rmap.connect('repo_fork_home', '/{repo_name:.*?}/fork',
608 rmap.connect('repo_fork_home', '/{repo_name:.*?}/fork',
605 controller='forks', action='fork',
609 controller='forks', action='fork',
606 conditions=dict(function=check_repo))
610 conditions=dict(function=check_repo))
607
611
608 rmap.connect('repo_forks_home', '/{repo_name:.*?}/forks',
612 rmap.connect('repo_forks_home', '/{repo_name:.*?}/forks',
609 controller='forks', action='forks',
613 controller='forks', action='forks',
610 conditions=dict(function=check_repo))
614 conditions=dict(function=check_repo))
611
615
612 rmap.connect('repo_followers_home', '/{repo_name:.*?}/followers',
616 rmap.connect('repo_followers_home', '/{repo_name:.*?}/followers',
613 controller='followers', action='followers',
617 controller='followers', action='followers',
614 conditions=dict(function=check_repo))
618 conditions=dict(function=check_repo))
615
619
616 return rmap
620 return rmap
@@ -1,104 +1,103 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 rhodecode.controllers.shortlog
3 rhodecode.controllers.shortlog
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 Shortlog controller for rhodecode
6 Shortlog controller for rhodecode
7
7
8 :created_on: Apr 18, 2010
8 :created_on: Apr 18, 2010
9 :author: marcink
9 :author: marcink
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
11 :license: GPLv3, see COPYING for more details.
12 """
12 """
13 # This program is free software: you can redistribute it and/or modify
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
16 # (at your option) any later version.
17 #
17 #
18 # This program is distributed in the hope that it will be useful,
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
21 # GNU General Public License for more details.
22 #
22 #
23 # You should have received a copy of the GNU General Public License
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25
26 import logging
26 import logging
27
27
28 from pylons import tmpl_context as c, request, url
28 from pylons import tmpl_context as c, request, url
29 from pylons.i18n.translation import _
29 from pylons.i18n.translation import _
30
30
31 from rhodecode.lib import helpers as h
31 from rhodecode.lib import helpers as h
32 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
32 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
33 from rhodecode.lib.base import BaseRepoController, render
33 from rhodecode.lib.base import BaseRepoController, render
34 from rhodecode.lib.helpers import RepoPage
34 from rhodecode.lib.helpers import RepoPage
35 from pylons.controllers.util import redirect
35 from pylons.controllers.util import redirect
36 from rhodecode.lib.utils2 import safe_int
36 from rhodecode.lib.utils2 import safe_int
37 from rhodecode.lib.vcs.exceptions import NodeDoesNotExistError, ChangesetError,\
37 from rhodecode.lib.vcs.exceptions import NodeDoesNotExistError, ChangesetError,\
38 RepositoryError
38 RepositoryError
39
39
40 log = logging.getLogger(__name__)
40 log = logging.getLogger(__name__)
41
41
42
42
43 class ShortlogController(BaseRepoController):
43 class ShortlogController(BaseRepoController):
44
44
45 @LoginRequired()
45 @LoginRequired()
46 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
46 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
47 'repository.admin')
47 'repository.admin')
48 def __before__(self):
48 def __before__(self):
49 super(ShortlogController, self).__before__()
49 super(ShortlogController, self).__before__()
50
50
51 def __get_cs_or_redirect(self, rev, repo_name, redirect_after=True):
51 def __get_cs_or_redirect(self, rev, repo_name, redirect_after=True):
52 """
52 """
53 Safe way to get changeset if error occur it redirects to tip with
53 Safe way to get changeset if error occur it redirects to tip with
54 proper message
54 proper message
55
55
56 :param rev: revision to fetch
56 :param rev: revision to fetch
57 :param repo_name: repo name to redirect after
57 :param repo_name: repo name to redirect after
58 """
58 """
59
59
60 try:
60 try:
61 return c.rhodecode_repo.get_changeset(rev)
61 return c.rhodecode_repo.get_changeset(rev)
62 except RepositoryError, e:
62 except RepositoryError, e:
63 h.flash(str(e), category='warning')
63 h.flash(str(e), category='warning')
64 redirect(h.url('shortlog_home', repo_name=repo_name))
64 redirect(h.url('shortlog_home', repo_name=repo_name))
65
65
66 def index(self, repo_name, revision=None, f_path=None):
66 def index(self, repo_name, revision=None, f_path=None):
67 p = safe_int(request.params.get('page', 1), 1)
67 p = safe_int(request.params.get('page', 1), 1)
68 size = safe_int(request.params.get('size', 20), 20)
68 size = safe_int(request.params.get('size', 20), 20)
69
69
70 def url_generator(**kw):
70 def url_generator(**kw):
71 return url('shortlog_home', repo_name=repo_name, size=size, **kw)
71 return url('shortlog_home', repo_name=repo_name, size=size, **kw)
72
72
73 collection = c.rhodecode_repo
73 collection = c.rhodecode_repo
74 c.file_history = f_path
74 c.file_history = f_path
75 if f_path:
75 if f_path:
76 f_path = f_path.lstrip('/')
77 # get the history for the file !
76 # get the history for the file !
78 tip_cs = c.rhodecode_repo.get_changeset()
77 tip_cs = c.rhodecode_repo.get_changeset()
79 try:
78 try:
80 collection = tip_cs.get_file_history(f_path)
79 collection = tip_cs.get_file_history(f_path)
81 except (NodeDoesNotExistError, ChangesetError):
80 except (NodeDoesNotExistError, ChangesetError):
82 #this node is not present at tip !
81 #this node is not present at tip !
83 try:
82 try:
84 cs = self.__get_cs_or_redirect(revision, repo_name)
83 cs = self.__get_cs_or_redirect(revision, repo_name)
85 collection = cs.get_file_history(f_path)
84 collection = cs.get_file_history(f_path)
86 except RepositoryError, e:
85 except RepositoryError, e:
87 h.flash(str(e), category='warning')
86 h.flash(str(e), category='warning')
88 redirect(h.url('shortlog_home', repo_name=repo_name))
87 redirect(h.url('shortlog_home', repo_name=repo_name))
89 collection = list(reversed(collection))
88 collection = list(reversed(collection))
90
89
91 c.repo_changesets = RepoPage(collection, page=p,
90 c.repo_changesets = RepoPage(collection, page=p,
92 items_per_page=size, url=url_generator)
91 items_per_page=size, url=url_generator)
93 page_revisions = [x.raw_id for x in list(collection)]
92 page_revisions = [x.raw_id for x in list(collection)]
94 c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
93 c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
95
94
96 if not c.repo_changesets:
95 if not c.repo_changesets:
97 h.flash(_('There are no changesets yet'), category='warning')
96 h.flash(_('There are no changesets yet'), category='warning')
98 return redirect(url('summary_home', repo_name=repo_name))
97 return redirect(url('summary_home', repo_name=repo_name))
99
98
100 c.shortlog_data = render('shortlog/shortlog_data.html')
99 c.shortlog_data = render('shortlog/shortlog_data.html')
101 if request.environ.get('HTTP_X_PARTIAL_XHR'):
100 if request.environ.get('HTTP_X_PARTIAL_XHR'):
102 return c.shortlog_data
101 return c.shortlog_data
103 r = render('shortlog/shortlog.html')
102 r = render('shortlog/shortlog.html')
104 return r
103 return r
General Comments 0
You need to be logged in to leave comments. Login now