##// END OF EJS Templates
fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as...
marcink -
r2822:1670ee0a beta
parent child Browse files
Show More
@@ -1,580 +1,580 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 try:
35 try:
36 by_id = repo_name.split('_')
36 by_id = repo_name.split('_')
37 if len(by_id) == 2 and by_id[1].isdigit():
37 if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '':
38 repo_name = Repository.get(by_id[1]).repo_name
38 repo_name = Repository.get(by_id[1]).repo_name
39 match_dict['repo_name'] = repo_name
39 match_dict['repo_name'] = repo_name
40 except:
40 except:
41 pass
41 pass
42
42
43 return is_valid_repo(repo_name, config['base_path'])
43 return is_valid_repo(repo_name, config['base_path'])
44
44
45 def check_group(environ, match_dict):
45 def check_group(environ, match_dict):
46 """
46 """
47 check for valid repositories group for proper 404 handling
47 check for valid repositories group for proper 404 handling
48
48
49 :param environ:
49 :param environ:
50 :param match_dict:
50 :param match_dict:
51 """
51 """
52 repos_group_name = match_dict.get('group_name')
52 repos_group_name = match_dict.get('group_name')
53
53
54 return is_valid_repos_group(repos_group_name, config['base_path'])
54 return is_valid_repos_group(repos_group_name, config['base_path'])
55
55
56 def check_int(environ, match_dict):
56 def check_int(environ, match_dict):
57 return match_dict.get('id').isdigit()
57 return match_dict.get('id').isdigit()
58
58
59 # The ErrorController route (handles 404/500 error pages); it should
59 # The ErrorController route (handles 404/500 error pages); it should
60 # likely stay at the top, ensuring it can always be resolved
60 # likely stay at the top, ensuring it can always be resolved
61 rmap.connect('/error/{action}', controller='error')
61 rmap.connect('/error/{action}', controller='error')
62 rmap.connect('/error/{action}/{id}', controller='error')
62 rmap.connect('/error/{action}/{id}', controller='error')
63
63
64 #==========================================================================
64 #==========================================================================
65 # CUSTOM ROUTES HERE
65 # CUSTOM ROUTES HERE
66 #==========================================================================
66 #==========================================================================
67
67
68 #MAIN PAGE
68 #MAIN PAGE
69 rmap.connect('home', '/', controller='home', action='index')
69 rmap.connect('home', '/', controller='home', action='index')
70 rmap.connect('repo_switcher', '/repos', controller='home',
70 rmap.connect('repo_switcher', '/repos', controller='home',
71 action='repo_switcher')
71 action='repo_switcher')
72 rmap.connect('branch_tag_switcher', '/branches-tags/{repo_name:.*?}',
72 rmap.connect('branch_tag_switcher', '/branches-tags/{repo_name:.*?}',
73 controller='home', action='branch_tag_switcher')
73 controller='home', action='branch_tag_switcher')
74 rmap.connect('bugtracker',
74 rmap.connect('bugtracker',
75 "http://bitbucket.org/marcinkuzminski/rhodecode/issues",
75 "http://bitbucket.org/marcinkuzminski/rhodecode/issues",
76 _static=True)
76 _static=True)
77 rmap.connect('rst_help',
77 rmap.connect('rst_help',
78 "http://docutils.sourceforge.net/docs/user/rst/quickref.html",
78 "http://docutils.sourceforge.net/docs/user/rst/quickref.html",
79 _static=True)
79 _static=True)
80 rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True)
80 rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True)
81
81
82 #ADMIN REPOSITORY REST ROUTES
82 #ADMIN REPOSITORY REST ROUTES
83 with rmap.submapper(path_prefix=ADMIN_PREFIX,
83 with rmap.submapper(path_prefix=ADMIN_PREFIX,
84 controller='admin/repos') as m:
84 controller='admin/repos') as m:
85 m.connect("repos", "/repos",
85 m.connect("repos", "/repos",
86 action="create", conditions=dict(method=["POST"]))
86 action="create", conditions=dict(method=["POST"]))
87 m.connect("repos", "/repos",
87 m.connect("repos", "/repos",
88 action="index", conditions=dict(method=["GET"]))
88 action="index", conditions=dict(method=["GET"]))
89 m.connect("formatted_repos", "/repos.{format}",
89 m.connect("formatted_repos", "/repos.{format}",
90 action="index",
90 action="index",
91 conditions=dict(method=["GET"]))
91 conditions=dict(method=["GET"]))
92 m.connect("new_repo", "/repos/new",
92 m.connect("new_repo", "/repos/new",
93 action="new", conditions=dict(method=["GET"]))
93 action="new", conditions=dict(method=["GET"]))
94 m.connect("formatted_new_repo", "/repos/new.{format}",
94 m.connect("formatted_new_repo", "/repos/new.{format}",
95 action="new", conditions=dict(method=["GET"]))
95 action="new", conditions=dict(method=["GET"]))
96 m.connect("/repos/{repo_name:.*?}",
96 m.connect("/repos/{repo_name:.*?}",
97 action="update", conditions=dict(method=["PUT"],
97 action="update", conditions=dict(method=["PUT"],
98 function=check_repo))
98 function=check_repo))
99 m.connect("/repos/{repo_name:.*?}",
99 m.connect("/repos/{repo_name:.*?}",
100 action="delete", conditions=dict(method=["DELETE"],
100 action="delete", conditions=dict(method=["DELETE"],
101 function=check_repo))
101 function=check_repo))
102 m.connect("edit_repo", "/repos/{repo_name:.*?}/edit",
102 m.connect("edit_repo", "/repos/{repo_name:.*?}/edit",
103 action="edit", conditions=dict(method=["GET"],
103 action="edit", conditions=dict(method=["GET"],
104 function=check_repo))
104 function=check_repo))
105 m.connect("formatted_edit_repo", "/repos/{repo_name:.*?}.{format}/edit",
105 m.connect("formatted_edit_repo", "/repos/{repo_name:.*?}.{format}/edit",
106 action="edit", conditions=dict(method=["GET"],
106 action="edit", conditions=dict(method=["GET"],
107 function=check_repo))
107 function=check_repo))
108 m.connect("repo", "/repos/{repo_name:.*?}",
108 m.connect("repo", "/repos/{repo_name:.*?}",
109 action="show", conditions=dict(method=["GET"],
109 action="show", conditions=dict(method=["GET"],
110 function=check_repo))
110 function=check_repo))
111 m.connect("formatted_repo", "/repos/{repo_name:.*?}.{format}",
111 m.connect("formatted_repo", "/repos/{repo_name:.*?}.{format}",
112 action="show", conditions=dict(method=["GET"],
112 action="show", conditions=dict(method=["GET"],
113 function=check_repo))
113 function=check_repo))
114 #ajax delete repo perm user
114 #ajax delete repo perm user
115 m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*?}",
115 m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*?}",
116 action="delete_perm_user",
116 action="delete_perm_user",
117 conditions=dict(method=["DELETE"], function=check_repo))
117 conditions=dict(method=["DELETE"], function=check_repo))
118
118
119 #ajax delete repo perm users_group
119 #ajax delete repo perm users_group
120 m.connect('delete_repo_users_group',
120 m.connect('delete_repo_users_group',
121 "/repos_delete_users_group/{repo_name:.*?}",
121 "/repos_delete_users_group/{repo_name:.*?}",
122 action="delete_perm_users_group",
122 action="delete_perm_users_group",
123 conditions=dict(method=["DELETE"], function=check_repo))
123 conditions=dict(method=["DELETE"], function=check_repo))
124
124
125 #settings actions
125 #settings actions
126 m.connect('repo_stats', "/repos_stats/{repo_name:.*?}",
126 m.connect('repo_stats', "/repos_stats/{repo_name:.*?}",
127 action="repo_stats", conditions=dict(method=["DELETE"],
127 action="repo_stats", conditions=dict(method=["DELETE"],
128 function=check_repo))
128 function=check_repo))
129 m.connect('repo_cache', "/repos_cache/{repo_name:.*?}",
129 m.connect('repo_cache', "/repos_cache/{repo_name:.*?}",
130 action="repo_cache", conditions=dict(method=["DELETE"],
130 action="repo_cache", conditions=dict(method=["DELETE"],
131 function=check_repo))
131 function=check_repo))
132 m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*?}",
132 m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*?}",
133 action="repo_public_journal", conditions=dict(method=["PUT"],
133 action="repo_public_journal", conditions=dict(method=["PUT"],
134 function=check_repo))
134 function=check_repo))
135 m.connect('repo_pull', "/repo_pull/{repo_name:.*?}",
135 m.connect('repo_pull', "/repo_pull/{repo_name:.*?}",
136 action="repo_pull", conditions=dict(method=["PUT"],
136 action="repo_pull", conditions=dict(method=["PUT"],
137 function=check_repo))
137 function=check_repo))
138 m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*?}",
138 m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*?}",
139 action="repo_as_fork", conditions=dict(method=["PUT"],
139 action="repo_as_fork", conditions=dict(method=["PUT"],
140 function=check_repo))
140 function=check_repo))
141 m.connect('repo_locking', "/repo_locking/{repo_name:.*?}",
141 m.connect('repo_locking', "/repo_locking/{repo_name:.*?}",
142 action="repo_locking", conditions=dict(method=["PUT"],
142 action="repo_locking", conditions=dict(method=["PUT"],
143 function=check_repo))
143 function=check_repo))
144 with rmap.submapper(path_prefix=ADMIN_PREFIX,
144 with rmap.submapper(path_prefix=ADMIN_PREFIX,
145 controller='admin/repos_groups') as m:
145 controller='admin/repos_groups') as m:
146 m.connect("repos_groups", "/repos_groups",
146 m.connect("repos_groups", "/repos_groups",
147 action="create", conditions=dict(method=["POST"]))
147 action="create", conditions=dict(method=["POST"]))
148 m.connect("repos_groups", "/repos_groups",
148 m.connect("repos_groups", "/repos_groups",
149 action="index", conditions=dict(method=["GET"]))
149 action="index", conditions=dict(method=["GET"]))
150 m.connect("formatted_repos_groups", "/repos_groups.{format}",
150 m.connect("formatted_repos_groups", "/repos_groups.{format}",
151 action="index", conditions=dict(method=["GET"]))
151 action="index", conditions=dict(method=["GET"]))
152 m.connect("new_repos_group", "/repos_groups/new",
152 m.connect("new_repos_group", "/repos_groups/new",
153 action="new", conditions=dict(method=["GET"]))
153 action="new", conditions=dict(method=["GET"]))
154 m.connect("formatted_new_repos_group", "/repos_groups/new.{format}",
154 m.connect("formatted_new_repos_group", "/repos_groups/new.{format}",
155 action="new", conditions=dict(method=["GET"]))
155 action="new", conditions=dict(method=["GET"]))
156 m.connect("update_repos_group", "/repos_groups/{id}",
156 m.connect("update_repos_group", "/repos_groups/{id}",
157 action="update", conditions=dict(method=["PUT"],
157 action="update", conditions=dict(method=["PUT"],
158 function=check_int))
158 function=check_int))
159 m.connect("delete_repos_group", "/repos_groups/{id}",
159 m.connect("delete_repos_group", "/repos_groups/{id}",
160 action="delete", conditions=dict(method=["DELETE"],
160 action="delete", conditions=dict(method=["DELETE"],
161 function=check_int))
161 function=check_int))
162 m.connect("edit_repos_group", "/repos_groups/{id:.*?}/edit",
162 m.connect("edit_repos_group", "/repos_groups/{id:.*?}/edit",
163 action="edit", conditions=dict(method=["GET"],))
163 action="edit", conditions=dict(method=["GET"],))
164 m.connect("formatted_edit_repos_group",
164 m.connect("formatted_edit_repos_group",
165 "/repos_groups/{id}.{format}/edit",
165 "/repos_groups/{id}.{format}/edit",
166 action="edit", conditions=dict(method=["GET"],
166 action="edit", conditions=dict(method=["GET"],
167 function=check_int))
167 function=check_int))
168 m.connect("repos_group", "/repos_groups/{id}",
168 m.connect("repos_group", "/repos_groups/{id}",
169 action="show", conditions=dict(method=["GET"],
169 action="show", conditions=dict(method=["GET"],
170 function=check_int))
170 function=check_int))
171 m.connect("formatted_repos_group", "/repos_groups/{id}.{format}",
171 m.connect("formatted_repos_group", "/repos_groups/{id}.{format}",
172 action="show", conditions=dict(method=["GET"],
172 action="show", conditions=dict(method=["GET"],
173 function=check_int))
173 function=check_int))
174 # ajax delete repos group perm user
174 # ajax delete repos group perm user
175 m.connect('delete_repos_group_user_perm',
175 m.connect('delete_repos_group_user_perm',
176 "/delete_repos_group_user_perm/{group_name:.*}",
176 "/delete_repos_group_user_perm/{group_name:.*}",
177 action="delete_repos_group_user_perm",
177 action="delete_repos_group_user_perm",
178 conditions=dict(method=["DELETE"], function=check_group))
178 conditions=dict(method=["DELETE"], function=check_group))
179
179
180 # ajax delete repos group perm users_group
180 # ajax delete repos group perm users_group
181 m.connect('delete_repos_group_users_group_perm',
181 m.connect('delete_repos_group_users_group_perm',
182 "/delete_repos_group_users_group_perm/{group_name:.*}",
182 "/delete_repos_group_users_group_perm/{group_name:.*}",
183 action="delete_repos_group_users_group_perm",
183 action="delete_repos_group_users_group_perm",
184 conditions=dict(method=["DELETE"], function=check_group))
184 conditions=dict(method=["DELETE"], function=check_group))
185
185
186 #ADMIN USER REST ROUTES
186 #ADMIN USER REST ROUTES
187 with rmap.submapper(path_prefix=ADMIN_PREFIX,
187 with rmap.submapper(path_prefix=ADMIN_PREFIX,
188 controller='admin/users') as m:
188 controller='admin/users') as m:
189 m.connect("users", "/users",
189 m.connect("users", "/users",
190 action="create", conditions=dict(method=["POST"]))
190 action="create", conditions=dict(method=["POST"]))
191 m.connect("users", "/users",
191 m.connect("users", "/users",
192 action="index", conditions=dict(method=["GET"]))
192 action="index", conditions=dict(method=["GET"]))
193 m.connect("formatted_users", "/users.{format}",
193 m.connect("formatted_users", "/users.{format}",
194 action="index", conditions=dict(method=["GET"]))
194 action="index", conditions=dict(method=["GET"]))
195 m.connect("new_user", "/users/new",
195 m.connect("new_user", "/users/new",
196 action="new", conditions=dict(method=["GET"]))
196 action="new", conditions=dict(method=["GET"]))
197 m.connect("formatted_new_user", "/users/new.{format}",
197 m.connect("formatted_new_user", "/users/new.{format}",
198 action="new", conditions=dict(method=["GET"]))
198 action="new", conditions=dict(method=["GET"]))
199 m.connect("update_user", "/users/{id}",
199 m.connect("update_user", "/users/{id}",
200 action="update", conditions=dict(method=["PUT"]))
200 action="update", conditions=dict(method=["PUT"]))
201 m.connect("delete_user", "/users/{id}",
201 m.connect("delete_user", "/users/{id}",
202 action="delete", conditions=dict(method=["DELETE"]))
202 action="delete", conditions=dict(method=["DELETE"]))
203 m.connect("edit_user", "/users/{id}/edit",
203 m.connect("edit_user", "/users/{id}/edit",
204 action="edit", conditions=dict(method=["GET"]))
204 action="edit", conditions=dict(method=["GET"]))
205 m.connect("formatted_edit_user",
205 m.connect("formatted_edit_user",
206 "/users/{id}.{format}/edit",
206 "/users/{id}.{format}/edit",
207 action="edit", conditions=dict(method=["GET"]))
207 action="edit", conditions=dict(method=["GET"]))
208 m.connect("user", "/users/{id}",
208 m.connect("user", "/users/{id}",
209 action="show", conditions=dict(method=["GET"]))
209 action="show", conditions=dict(method=["GET"]))
210 m.connect("formatted_user", "/users/{id}.{format}",
210 m.connect("formatted_user", "/users/{id}.{format}",
211 action="show", conditions=dict(method=["GET"]))
211 action="show", conditions=dict(method=["GET"]))
212
212
213 #EXTRAS USER ROUTES
213 #EXTRAS USER ROUTES
214 m.connect("user_perm", "/users_perm/{id}",
214 m.connect("user_perm", "/users_perm/{id}",
215 action="update_perm", conditions=dict(method=["PUT"]))
215 action="update_perm", conditions=dict(method=["PUT"]))
216 m.connect("user_emails", "/users_emails/{id}",
216 m.connect("user_emails", "/users_emails/{id}",
217 action="add_email", conditions=dict(method=["PUT"]))
217 action="add_email", conditions=dict(method=["PUT"]))
218 m.connect("user_emails_delete", "/users_emails/{id}",
218 m.connect("user_emails_delete", "/users_emails/{id}",
219 action="delete_email", conditions=dict(method=["DELETE"]))
219 action="delete_email", conditions=dict(method=["DELETE"]))
220
220
221 #ADMIN USERS GROUPS REST ROUTES
221 #ADMIN USERS GROUPS REST ROUTES
222 with rmap.submapper(path_prefix=ADMIN_PREFIX,
222 with rmap.submapper(path_prefix=ADMIN_PREFIX,
223 controller='admin/users_groups') as m:
223 controller='admin/users_groups') as m:
224 m.connect("users_groups", "/users_groups",
224 m.connect("users_groups", "/users_groups",
225 action="create", conditions=dict(method=["POST"]))
225 action="create", conditions=dict(method=["POST"]))
226 m.connect("users_groups", "/users_groups",
226 m.connect("users_groups", "/users_groups",
227 action="index", conditions=dict(method=["GET"]))
227 action="index", conditions=dict(method=["GET"]))
228 m.connect("formatted_users_groups", "/users_groups.{format}",
228 m.connect("formatted_users_groups", "/users_groups.{format}",
229 action="index", conditions=dict(method=["GET"]))
229 action="index", conditions=dict(method=["GET"]))
230 m.connect("new_users_group", "/users_groups/new",
230 m.connect("new_users_group", "/users_groups/new",
231 action="new", conditions=dict(method=["GET"]))
231 action="new", conditions=dict(method=["GET"]))
232 m.connect("formatted_new_users_group", "/users_groups/new.{format}",
232 m.connect("formatted_new_users_group", "/users_groups/new.{format}",
233 action="new", conditions=dict(method=["GET"]))
233 action="new", conditions=dict(method=["GET"]))
234 m.connect("update_users_group", "/users_groups/{id}",
234 m.connect("update_users_group", "/users_groups/{id}",
235 action="update", conditions=dict(method=["PUT"]))
235 action="update", conditions=dict(method=["PUT"]))
236 m.connect("delete_users_group", "/users_groups/{id}",
236 m.connect("delete_users_group", "/users_groups/{id}",
237 action="delete", conditions=dict(method=["DELETE"]))
237 action="delete", conditions=dict(method=["DELETE"]))
238 m.connect("edit_users_group", "/users_groups/{id}/edit",
238 m.connect("edit_users_group", "/users_groups/{id}/edit",
239 action="edit", conditions=dict(method=["GET"]))
239 action="edit", conditions=dict(method=["GET"]))
240 m.connect("formatted_edit_users_group",
240 m.connect("formatted_edit_users_group",
241 "/users_groups/{id}.{format}/edit",
241 "/users_groups/{id}.{format}/edit",
242 action="edit", conditions=dict(method=["GET"]))
242 action="edit", conditions=dict(method=["GET"]))
243 m.connect("users_group", "/users_groups/{id}",
243 m.connect("users_group", "/users_groups/{id}",
244 action="show", conditions=dict(method=["GET"]))
244 action="show", conditions=dict(method=["GET"]))
245 m.connect("formatted_users_group", "/users_groups/{id}.{format}",
245 m.connect("formatted_users_group", "/users_groups/{id}.{format}",
246 action="show", conditions=dict(method=["GET"]))
246 action="show", conditions=dict(method=["GET"]))
247
247
248 #EXTRAS USER ROUTES
248 #EXTRAS USER ROUTES
249 m.connect("users_group_perm", "/users_groups_perm/{id}",
249 m.connect("users_group_perm", "/users_groups_perm/{id}",
250 action="update_perm", conditions=dict(method=["PUT"]))
250 action="update_perm", conditions=dict(method=["PUT"]))
251
251
252 #ADMIN GROUP REST ROUTES
252 #ADMIN GROUP REST ROUTES
253 rmap.resource('group', 'groups',
253 rmap.resource('group', 'groups',
254 controller='admin/groups', path_prefix=ADMIN_PREFIX)
254 controller='admin/groups', path_prefix=ADMIN_PREFIX)
255
255
256 #ADMIN PERMISSIONS REST ROUTES
256 #ADMIN PERMISSIONS REST ROUTES
257 rmap.resource('permission', 'permissions',
257 rmap.resource('permission', 'permissions',
258 controller='admin/permissions', path_prefix=ADMIN_PREFIX)
258 controller='admin/permissions', path_prefix=ADMIN_PREFIX)
259
259
260 ##ADMIN LDAP SETTINGS
260 ##ADMIN LDAP SETTINGS
261 rmap.connect('ldap_settings', '%s/ldap' % ADMIN_PREFIX,
261 rmap.connect('ldap_settings', '%s/ldap' % ADMIN_PREFIX,
262 controller='admin/ldap_settings', action='ldap_settings',
262 controller='admin/ldap_settings', action='ldap_settings',
263 conditions=dict(method=["POST"]))
263 conditions=dict(method=["POST"]))
264
264
265 rmap.connect('ldap_home', '%s/ldap' % ADMIN_PREFIX,
265 rmap.connect('ldap_home', '%s/ldap' % ADMIN_PREFIX,
266 controller='admin/ldap_settings')
266 controller='admin/ldap_settings')
267
267
268 #ADMIN SETTINGS REST ROUTES
268 #ADMIN SETTINGS REST ROUTES
269 with rmap.submapper(path_prefix=ADMIN_PREFIX,
269 with rmap.submapper(path_prefix=ADMIN_PREFIX,
270 controller='admin/settings') as m:
270 controller='admin/settings') as m:
271 m.connect("admin_settings", "/settings",
271 m.connect("admin_settings", "/settings",
272 action="create", conditions=dict(method=["POST"]))
272 action="create", conditions=dict(method=["POST"]))
273 m.connect("admin_settings", "/settings",
273 m.connect("admin_settings", "/settings",
274 action="index", conditions=dict(method=["GET"]))
274 action="index", conditions=dict(method=["GET"]))
275 m.connect("formatted_admin_settings", "/settings.{format}",
275 m.connect("formatted_admin_settings", "/settings.{format}",
276 action="index", conditions=dict(method=["GET"]))
276 action="index", conditions=dict(method=["GET"]))
277 m.connect("admin_new_setting", "/settings/new",
277 m.connect("admin_new_setting", "/settings/new",
278 action="new", conditions=dict(method=["GET"]))
278 action="new", conditions=dict(method=["GET"]))
279 m.connect("formatted_admin_new_setting", "/settings/new.{format}",
279 m.connect("formatted_admin_new_setting", "/settings/new.{format}",
280 action="new", conditions=dict(method=["GET"]))
280 action="new", conditions=dict(method=["GET"]))
281 m.connect("/settings/{setting_id}",
281 m.connect("/settings/{setting_id}",
282 action="update", conditions=dict(method=["PUT"]))
282 action="update", conditions=dict(method=["PUT"]))
283 m.connect("/settings/{setting_id}",
283 m.connect("/settings/{setting_id}",
284 action="delete", conditions=dict(method=["DELETE"]))
284 action="delete", conditions=dict(method=["DELETE"]))
285 m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
285 m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
286 action="edit", conditions=dict(method=["GET"]))
286 action="edit", conditions=dict(method=["GET"]))
287 m.connect("formatted_admin_edit_setting",
287 m.connect("formatted_admin_edit_setting",
288 "/settings/{setting_id}.{format}/edit",
288 "/settings/{setting_id}.{format}/edit",
289 action="edit", conditions=dict(method=["GET"]))
289 action="edit", conditions=dict(method=["GET"]))
290 m.connect("admin_setting", "/settings/{setting_id}",
290 m.connect("admin_setting", "/settings/{setting_id}",
291 action="show", conditions=dict(method=["GET"]))
291 action="show", conditions=dict(method=["GET"]))
292 m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}",
292 m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}",
293 action="show", conditions=dict(method=["GET"]))
293 action="show", conditions=dict(method=["GET"]))
294 m.connect("admin_settings_my_account", "/my_account",
294 m.connect("admin_settings_my_account", "/my_account",
295 action="my_account", conditions=dict(method=["GET"]))
295 action="my_account", conditions=dict(method=["GET"]))
296 m.connect("admin_settings_my_account_update", "/my_account_update",
296 m.connect("admin_settings_my_account_update", "/my_account_update",
297 action="my_account_update", conditions=dict(method=["PUT"]))
297 action="my_account_update", conditions=dict(method=["PUT"]))
298 m.connect("admin_settings_create_repository", "/create_repository",
298 m.connect("admin_settings_create_repository", "/create_repository",
299 action="create_repository", conditions=dict(method=["GET"]))
299 action="create_repository", conditions=dict(method=["GET"]))
300 m.connect("admin_settings_my_repos", "/my_account/repos",
300 m.connect("admin_settings_my_repos", "/my_account/repos",
301 action="my_account_my_repos", conditions=dict(method=["GET"]))
301 action="my_account_my_repos", conditions=dict(method=["GET"]))
302 m.connect("admin_settings_my_pullrequests", "/my_account/pull_requests",
302 m.connect("admin_settings_my_pullrequests", "/my_account/pull_requests",
303 action="my_account_my_pullrequests", conditions=dict(method=["GET"]))
303 action="my_account_my_pullrequests", conditions=dict(method=["GET"]))
304
304
305 #NOTIFICATION REST ROUTES
305 #NOTIFICATION REST ROUTES
306 with rmap.submapper(path_prefix=ADMIN_PREFIX,
306 with rmap.submapper(path_prefix=ADMIN_PREFIX,
307 controller='admin/notifications') as m:
307 controller='admin/notifications') as m:
308 m.connect("notifications", "/notifications",
308 m.connect("notifications", "/notifications",
309 action="create", conditions=dict(method=["POST"]))
309 action="create", conditions=dict(method=["POST"]))
310 m.connect("notifications", "/notifications",
310 m.connect("notifications", "/notifications",
311 action="index", conditions=dict(method=["GET"]))
311 action="index", conditions=dict(method=["GET"]))
312 m.connect("notifications_mark_all_read", "/notifications/mark_all_read",
312 m.connect("notifications_mark_all_read", "/notifications/mark_all_read",
313 action="mark_all_read", conditions=dict(method=["GET"]))
313 action="mark_all_read", conditions=dict(method=["GET"]))
314 m.connect("formatted_notifications", "/notifications.{format}",
314 m.connect("formatted_notifications", "/notifications.{format}",
315 action="index", conditions=dict(method=["GET"]))
315 action="index", conditions=dict(method=["GET"]))
316 m.connect("new_notification", "/notifications/new",
316 m.connect("new_notification", "/notifications/new",
317 action="new", conditions=dict(method=["GET"]))
317 action="new", conditions=dict(method=["GET"]))
318 m.connect("formatted_new_notification", "/notifications/new.{format}",
318 m.connect("formatted_new_notification", "/notifications/new.{format}",
319 action="new", conditions=dict(method=["GET"]))
319 action="new", conditions=dict(method=["GET"]))
320 m.connect("/notification/{notification_id}",
320 m.connect("/notification/{notification_id}",
321 action="update", conditions=dict(method=["PUT"]))
321 action="update", conditions=dict(method=["PUT"]))
322 m.connect("/notification/{notification_id}",
322 m.connect("/notification/{notification_id}",
323 action="delete", conditions=dict(method=["DELETE"]))
323 action="delete", conditions=dict(method=["DELETE"]))
324 m.connect("edit_notification", "/notification/{notification_id}/edit",
324 m.connect("edit_notification", "/notification/{notification_id}/edit",
325 action="edit", conditions=dict(method=["GET"]))
325 action="edit", conditions=dict(method=["GET"]))
326 m.connect("formatted_edit_notification",
326 m.connect("formatted_edit_notification",
327 "/notification/{notification_id}.{format}/edit",
327 "/notification/{notification_id}.{format}/edit",
328 action="edit", conditions=dict(method=["GET"]))
328 action="edit", conditions=dict(method=["GET"]))
329 m.connect("notification", "/notification/{notification_id}",
329 m.connect("notification", "/notification/{notification_id}",
330 action="show", conditions=dict(method=["GET"]))
330 action="show", conditions=dict(method=["GET"]))
331 m.connect("formatted_notification", "/notifications/{notification_id}.{format}",
331 m.connect("formatted_notification", "/notifications/{notification_id}.{format}",
332 action="show", conditions=dict(method=["GET"]))
332 action="show", conditions=dict(method=["GET"]))
333
333
334 #ADMIN MAIN PAGES
334 #ADMIN MAIN PAGES
335 with rmap.submapper(path_prefix=ADMIN_PREFIX,
335 with rmap.submapper(path_prefix=ADMIN_PREFIX,
336 controller='admin/admin') as m:
336 controller='admin/admin') as m:
337 m.connect('admin_home', '', action='index')
337 m.connect('admin_home', '', action='index')
338 m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
338 m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
339 action='add_repo')
339 action='add_repo')
340
340
341 #==========================================================================
341 #==========================================================================
342 # API V2
342 # API V2
343 #==========================================================================
343 #==========================================================================
344 with rmap.submapper(path_prefix=ADMIN_PREFIX,
344 with rmap.submapper(path_prefix=ADMIN_PREFIX,
345 controller='api/api') as m:
345 controller='api/api') as m:
346 m.connect('api', '/api')
346 m.connect('api', '/api')
347
347
348 #USER JOURNAL
348 #USER JOURNAL
349 rmap.connect('journal', '%s/journal' % ADMIN_PREFIX,
349 rmap.connect('journal', '%s/journal' % ADMIN_PREFIX,
350 controller='journal', action='index')
350 controller='journal', action='index')
351 rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX,
351 rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX,
352 controller='journal', action='journal_rss')
352 controller='journal', action='journal_rss')
353 rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX,
353 rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX,
354 controller='journal', action='journal_atom')
354 controller='journal', action='journal_atom')
355
355
356 rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX,
356 rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX,
357 controller='journal', action="public_journal")
357 controller='journal', action="public_journal")
358
358
359 rmap.connect('public_journal_rss', '%s/public_journal/rss' % ADMIN_PREFIX,
359 rmap.connect('public_journal_rss', '%s/public_journal/rss' % ADMIN_PREFIX,
360 controller='journal', action="public_journal_rss")
360 controller='journal', action="public_journal_rss")
361
361
362 rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % ADMIN_PREFIX,
362 rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % ADMIN_PREFIX,
363 controller='journal', action="public_journal_rss")
363 controller='journal', action="public_journal_rss")
364
364
365 rmap.connect('public_journal_atom',
365 rmap.connect('public_journal_atom',
366 '%s/public_journal/atom' % ADMIN_PREFIX, controller='journal',
366 '%s/public_journal/atom' % ADMIN_PREFIX, controller='journal',
367 action="public_journal_atom")
367 action="public_journal_atom")
368
368
369 rmap.connect('public_journal_atom_old',
369 rmap.connect('public_journal_atom_old',
370 '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal',
370 '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal',
371 action="public_journal_atom")
371 action="public_journal_atom")
372
372
373 rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX,
373 rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX,
374 controller='journal', action='toggle_following',
374 controller='journal', action='toggle_following',
375 conditions=dict(method=["POST"]))
375 conditions=dict(method=["POST"]))
376
376
377 #SEARCH
377 #SEARCH
378 rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',)
378 rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',)
379 rmap.connect('search_repo', '%s/search/{search_repo:.*}' % ADMIN_PREFIX,
379 rmap.connect('search_repo', '%s/search/{search_repo:.*}' % ADMIN_PREFIX,
380 controller='search')
380 controller='search')
381
381
382 #LOGIN/LOGOUT/REGISTER/SIGN IN
382 #LOGIN/LOGOUT/REGISTER/SIGN IN
383 rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login')
383 rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login')
384 rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login',
384 rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login',
385 action='logout')
385 action='logout')
386
386
387 rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login',
387 rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login',
388 action='register')
388 action='register')
389
389
390 rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX,
390 rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX,
391 controller='login', action='password_reset')
391 controller='login', action='password_reset')
392
392
393 rmap.connect('reset_password_confirmation',
393 rmap.connect('reset_password_confirmation',
394 '%s/password_reset_confirmation' % ADMIN_PREFIX,
394 '%s/password_reset_confirmation' % ADMIN_PREFIX,
395 controller='login', action='password_reset_confirmation')
395 controller='login', action='password_reset_confirmation')
396
396
397 #FEEDS
397 #FEEDS
398 rmap.connect('rss_feed_home', '/{repo_name:.*?}/feed/rss',
398 rmap.connect('rss_feed_home', '/{repo_name:.*?}/feed/rss',
399 controller='feed', action='rss',
399 controller='feed', action='rss',
400 conditions=dict(function=check_repo))
400 conditions=dict(function=check_repo))
401
401
402 rmap.connect('atom_feed_home', '/{repo_name:.*?}/feed/atom',
402 rmap.connect('atom_feed_home', '/{repo_name:.*?}/feed/atom',
403 controller='feed', action='atom',
403 controller='feed', action='atom',
404 conditions=dict(function=check_repo))
404 conditions=dict(function=check_repo))
405
405
406 #==========================================================================
406 #==========================================================================
407 # REPOSITORY ROUTES
407 # REPOSITORY ROUTES
408 #==========================================================================
408 #==========================================================================
409 rmap.connect('summary_home', '/{repo_name:.*?}',
409 rmap.connect('summary_home', '/{repo_name:.*?}',
410 controller='summary',
410 controller='summary',
411 conditions=dict(function=check_repo))
411 conditions=dict(function=check_repo))
412
412
413 rmap.connect('repos_group_home', '/{group_name:.*}',
413 rmap.connect('repos_group_home', '/{group_name:.*}',
414 controller='admin/repos_groups', action="show_by_name",
414 controller='admin/repos_groups', action="show_by_name",
415 conditions=dict(function=check_group))
415 conditions=dict(function=check_group))
416
416
417 rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}',
417 rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}',
418 controller='changeset', revision='tip',
418 controller='changeset', revision='tip',
419 conditions=dict(function=check_repo))
419 conditions=dict(function=check_repo))
420
420
421 rmap.connect('changeset_comment',
421 rmap.connect('changeset_comment',
422 '/{repo_name:.*?}/changeset/{revision}/comment',
422 '/{repo_name:.*?}/changeset/{revision}/comment',
423 controller='changeset', revision='tip', action='comment',
423 controller='changeset', revision='tip', action='comment',
424 conditions=dict(function=check_repo))
424 conditions=dict(function=check_repo))
425
425
426 rmap.connect('changeset_comment_delete',
426 rmap.connect('changeset_comment_delete',
427 '/{repo_name:.*?}/changeset/comment/{comment_id}/delete',
427 '/{repo_name:.*?}/changeset/comment/{comment_id}/delete',
428 controller='changeset', action='delete_comment',
428 controller='changeset', action='delete_comment',
429 conditions=dict(function=check_repo, method=["DELETE"]))
429 conditions=dict(function=check_repo, method=["DELETE"]))
430
430
431 rmap.connect('raw_changeset_home',
431 rmap.connect('raw_changeset_home',
432 '/{repo_name:.*?}/raw-changeset/{revision}',
432 '/{repo_name:.*?}/raw-changeset/{revision}',
433 controller='changeset', action='raw_changeset',
433 controller='changeset', action='raw_changeset',
434 revision='tip', conditions=dict(function=check_repo))
434 revision='tip', conditions=dict(function=check_repo))
435
435
436 rmap.connect('compare_url',
436 rmap.connect('compare_url',
437 '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref}...{other_ref_type}@{other_ref}',
437 '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref}...{other_ref_type}@{other_ref}',
438 controller='compare', action='index',
438 controller='compare', action='index',
439 conditions=dict(function=check_repo),
439 conditions=dict(function=check_repo),
440 requirements=dict(
440 requirements=dict(
441 org_ref_type='(branch|book|tag|rev|org_ref_type)',
441 org_ref_type='(branch|book|tag|rev|org_ref_type)',
442 other_ref_type='(branch|book|tag|rev|other_ref_type)')
442 other_ref_type='(branch|book|tag|rev|other_ref_type)')
443 )
443 )
444
444
445 rmap.connect('pullrequest_home',
445 rmap.connect('pullrequest_home',
446 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
446 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
447 action='index', conditions=dict(function=check_repo,
447 action='index', conditions=dict(function=check_repo,
448 method=["GET"]))
448 method=["GET"]))
449
449
450 rmap.connect('pullrequest',
450 rmap.connect('pullrequest',
451 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
451 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
452 action='create', conditions=dict(function=check_repo,
452 action='create', conditions=dict(function=check_repo,
453 method=["POST"]))
453 method=["POST"]))
454
454
455 rmap.connect('pullrequest_show',
455 rmap.connect('pullrequest_show',
456 '/{repo_name:.*?}/pull-request/{pull_request_id}',
456 '/{repo_name:.*?}/pull-request/{pull_request_id}',
457 controller='pullrequests',
457 controller='pullrequests',
458 action='show', conditions=dict(function=check_repo,
458 action='show', conditions=dict(function=check_repo,
459 method=["GET"]))
459 method=["GET"]))
460 rmap.connect('pullrequest_update',
460 rmap.connect('pullrequest_update',
461 '/{repo_name:.*?}/pull-request/{pull_request_id}',
461 '/{repo_name:.*?}/pull-request/{pull_request_id}',
462 controller='pullrequests',
462 controller='pullrequests',
463 action='update', conditions=dict(function=check_repo,
463 action='update', conditions=dict(function=check_repo,
464 method=["PUT"]))
464 method=["PUT"]))
465 rmap.connect('pullrequest_delete',
465 rmap.connect('pullrequest_delete',
466 '/{repo_name:.*?}/pull-request/{pull_request_id}',
466 '/{repo_name:.*?}/pull-request/{pull_request_id}',
467 controller='pullrequests',
467 controller='pullrequests',
468 action='delete', conditions=dict(function=check_repo,
468 action='delete', conditions=dict(function=check_repo,
469 method=["DELETE"]))
469 method=["DELETE"]))
470
470
471 rmap.connect('pullrequest_show_all',
471 rmap.connect('pullrequest_show_all',
472 '/{repo_name:.*?}/pull-request',
472 '/{repo_name:.*?}/pull-request',
473 controller='pullrequests',
473 controller='pullrequests',
474 action='show_all', conditions=dict(function=check_repo,
474 action='show_all', conditions=dict(function=check_repo,
475 method=["GET"]))
475 method=["GET"]))
476
476
477 rmap.connect('pullrequest_comment',
477 rmap.connect('pullrequest_comment',
478 '/{repo_name:.*?}/pull-request-comment/{pull_request_id}',
478 '/{repo_name:.*?}/pull-request-comment/{pull_request_id}',
479 controller='pullrequests',
479 controller='pullrequests',
480 action='comment', conditions=dict(function=check_repo,
480 action='comment', conditions=dict(function=check_repo,
481 method=["POST"]))
481 method=["POST"]))
482
482
483 rmap.connect('pullrequest_comment_delete',
483 rmap.connect('pullrequest_comment_delete',
484 '/{repo_name:.*?}/pull-request-comment/{comment_id}/delete',
484 '/{repo_name:.*?}/pull-request-comment/{comment_id}/delete',
485 controller='pullrequests', action='delete_comment',
485 controller='pullrequests', action='delete_comment',
486 conditions=dict(function=check_repo, method=["DELETE"]))
486 conditions=dict(function=check_repo, method=["DELETE"]))
487
487
488 rmap.connect('summary_home', '/{repo_name:.*?}/summary',
488 rmap.connect('summary_home', '/{repo_name:.*?}/summary',
489 controller='summary', conditions=dict(function=check_repo))
489 controller='summary', conditions=dict(function=check_repo))
490
490
491 rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog',
491 rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog',
492 controller='shortlog', conditions=dict(function=check_repo))
492 controller='shortlog', conditions=dict(function=check_repo))
493
493
494 rmap.connect('branches_home', '/{repo_name:.*?}/branches',
494 rmap.connect('branches_home', '/{repo_name:.*?}/branches',
495 controller='branches', conditions=dict(function=check_repo))
495 controller='branches', conditions=dict(function=check_repo))
496
496
497 rmap.connect('tags_home', '/{repo_name:.*?}/tags',
497 rmap.connect('tags_home', '/{repo_name:.*?}/tags',
498 controller='tags', conditions=dict(function=check_repo))
498 controller='tags', conditions=dict(function=check_repo))
499
499
500 rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks',
500 rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks',
501 controller='bookmarks', conditions=dict(function=check_repo))
501 controller='bookmarks', conditions=dict(function=check_repo))
502
502
503 rmap.connect('changelog_home', '/{repo_name:.*?}/changelog',
503 rmap.connect('changelog_home', '/{repo_name:.*?}/changelog',
504 controller='changelog', conditions=dict(function=check_repo))
504 controller='changelog', conditions=dict(function=check_repo))
505
505
506 rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}',
506 rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}',
507 controller='changelog', action='changelog_details',
507 controller='changelog', action='changelog_details',
508 conditions=dict(function=check_repo))
508 conditions=dict(function=check_repo))
509
509
510 rmap.connect('files_home', '/{repo_name:.*?}/files/{revision}/{f_path:.*}',
510 rmap.connect('files_home', '/{repo_name:.*?}/files/{revision}/{f_path:.*}',
511 controller='files', revision='tip', f_path='',
511 controller='files', revision='tip', f_path='',
512 conditions=dict(function=check_repo))
512 conditions=dict(function=check_repo))
513
513
514 rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}',
514 rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}',
515 controller='files', action='diff', revision='tip', f_path='',
515 controller='files', action='diff', revision='tip', f_path='',
516 conditions=dict(function=check_repo))
516 conditions=dict(function=check_repo))
517
517
518 rmap.connect('files_rawfile_home',
518 rmap.connect('files_rawfile_home',
519 '/{repo_name:.*?}/rawfile/{revision}/{f_path:.*}',
519 '/{repo_name:.*?}/rawfile/{revision}/{f_path:.*}',
520 controller='files', action='rawfile', revision='tip',
520 controller='files', action='rawfile', revision='tip',
521 f_path='', conditions=dict(function=check_repo))
521 f_path='', conditions=dict(function=check_repo))
522
522
523 rmap.connect('files_raw_home',
523 rmap.connect('files_raw_home',
524 '/{repo_name:.*?}/raw/{revision}/{f_path:.*}',
524 '/{repo_name:.*?}/raw/{revision}/{f_path:.*}',
525 controller='files', action='raw', revision='tip', f_path='',
525 controller='files', action='raw', revision='tip', f_path='',
526 conditions=dict(function=check_repo))
526 conditions=dict(function=check_repo))
527
527
528 rmap.connect('files_annotate_home',
528 rmap.connect('files_annotate_home',
529 '/{repo_name:.*?}/annotate/{revision}/{f_path:.*}',
529 '/{repo_name:.*?}/annotate/{revision}/{f_path:.*}',
530 controller='files', action='index', revision='tip',
530 controller='files', action='index', revision='tip',
531 f_path='', annotate=True, conditions=dict(function=check_repo))
531 f_path='', annotate=True, conditions=dict(function=check_repo))
532
532
533 rmap.connect('files_edit_home',
533 rmap.connect('files_edit_home',
534 '/{repo_name:.*?}/edit/{revision}/{f_path:.*}',
534 '/{repo_name:.*?}/edit/{revision}/{f_path:.*}',
535 controller='files', action='edit', revision='tip',
535 controller='files', action='edit', revision='tip',
536 f_path='', conditions=dict(function=check_repo))
536 f_path='', conditions=dict(function=check_repo))
537
537
538 rmap.connect('files_add_home',
538 rmap.connect('files_add_home',
539 '/{repo_name:.*?}/add/{revision}/{f_path:.*}',
539 '/{repo_name:.*?}/add/{revision}/{f_path:.*}',
540 controller='files', action='add', revision='tip',
540 controller='files', action='add', revision='tip',
541 f_path='', conditions=dict(function=check_repo))
541 f_path='', conditions=dict(function=check_repo))
542
542
543 rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}',
543 rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}',
544 controller='files', action='archivefile',
544 controller='files', action='archivefile',
545 conditions=dict(function=check_repo))
545 conditions=dict(function=check_repo))
546
546
547 rmap.connect('files_nodelist_home',
547 rmap.connect('files_nodelist_home',
548 '/{repo_name:.*?}/nodelist/{revision}/{f_path:.*}',
548 '/{repo_name:.*?}/nodelist/{revision}/{f_path:.*}',
549 controller='files', action='nodelist',
549 controller='files', action='nodelist',
550 conditions=dict(function=check_repo))
550 conditions=dict(function=check_repo))
551
551
552 rmap.connect('repo_settings_delete', '/{repo_name:.*?}/settings',
552 rmap.connect('repo_settings_delete', '/{repo_name:.*?}/settings',
553 controller='settings', action="delete",
553 controller='settings', action="delete",
554 conditions=dict(method=["DELETE"], function=check_repo))
554 conditions=dict(method=["DELETE"], function=check_repo))
555
555
556 rmap.connect('repo_settings_update', '/{repo_name:.*?}/settings',
556 rmap.connect('repo_settings_update', '/{repo_name:.*?}/settings',
557 controller='settings', action="update",
557 controller='settings', action="update",
558 conditions=dict(method=["PUT"], function=check_repo))
558 conditions=dict(method=["PUT"], function=check_repo))
559
559
560 rmap.connect('repo_settings_home', '/{repo_name:.*?}/settings',
560 rmap.connect('repo_settings_home', '/{repo_name:.*?}/settings',
561 controller='settings', action='index',
561 controller='settings', action='index',
562 conditions=dict(function=check_repo))
562 conditions=dict(function=check_repo))
563
563
564 rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork',
564 rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork',
565 controller='forks', action='fork_create',
565 controller='forks', action='fork_create',
566 conditions=dict(function=check_repo, method=["POST"]))
566 conditions=dict(function=check_repo, method=["POST"]))
567
567
568 rmap.connect('repo_fork_home', '/{repo_name:.*?}/fork',
568 rmap.connect('repo_fork_home', '/{repo_name:.*?}/fork',
569 controller='forks', action='fork',
569 controller='forks', action='fork',
570 conditions=dict(function=check_repo))
570 conditions=dict(function=check_repo))
571
571
572 rmap.connect('repo_forks_home', '/{repo_name:.*?}/forks',
572 rmap.connect('repo_forks_home', '/{repo_name:.*?}/forks',
573 controller='forks', action='forks',
573 controller='forks', action='forks',
574 conditions=dict(function=check_repo))
574 conditions=dict(function=check_repo))
575
575
576 rmap.connect('repo_followers_home', '/{repo_name:.*?}/followers',
576 rmap.connect('repo_followers_home', '/{repo_name:.*?}/followers',
577 controller='followers', action='followers',
577 controller='followers', action='followers',
578 conditions=dict(function=check_repo))
578 conditions=dict(function=check_repo))
579
579
580 return rmap
580 return rmap
@@ -1,104 +1,121 b''
1 from rhodecode.tests import *
1 from rhodecode.tests import *
2 from rhodecode.model.db import Repository
2 from rhodecode.model.db import Repository
3 from rhodecode.lib.utils import invalidate_cache
3 from rhodecode.lib.utils import invalidate_cache
4 from rhodecode.model.repo import RepoModel
5 from rhodecode.tests.models.common import _make_repo
6 from rhodecode.model.meta import Session
4
7
5
8
6 class TestSummaryController(TestController):
9 class TestSummaryController(TestController):
7
10
8 def test_index(self):
11 def test_index(self):
9 self.log_user()
12 self.log_user()
10 ID = Repository.get_by_repo_name(HG_REPO).repo_id
13 ID = Repository.get_by_repo_name(HG_REPO).repo_id
11 response = self.app.get(url(controller='summary',
14 response = self.app.get(url(controller='summary',
12 action='index',
15 action='index',
13 repo_name=HG_REPO))
16 repo_name=HG_REPO))
14
17
15 #repo type
18 #repo type
16 response.mustcontain(
19 response.mustcontain(
17 """<img style="margin-bottom:2px" class="icon" """
20 """<img style="margin-bottom:2px" class="icon" """
18 """title="Mercurial repository" alt="Mercurial repository" """
21 """title="Mercurial repository" alt="Mercurial repository" """
19 """src="/images/icons/hgicon.png"/>"""
22 """src="/images/icons/hgicon.png"/>"""
20 )
23 )
21 response.mustcontain(
24 response.mustcontain(
22 """<img style="margin-bottom:2px" class="icon" """
25 """<img style="margin-bottom:2px" class="icon" """
23 """title="public repository" alt="public """
26 """title="public repository" alt="public """
24 """repository" src="/images/icons/lock_open.png"/>"""
27 """repository" src="/images/icons/lock_open.png"/>"""
25 )
28 )
26
29
27 #codes stats
30 #codes stats
28 self._enable_stats()
31 self._enable_stats()
29
32
30 invalidate_cache('get_repo_cached_%s' % HG_REPO)
33 invalidate_cache('get_repo_cached_%s' % HG_REPO)
31 response = self.app.get(url(controller='summary', action='index',
34 response = self.app.get(url(controller='summary', action='index',
32 repo_name=HG_REPO))
35 repo_name=HG_REPO))
33 response.mustcontain(
36 response.mustcontain(
34 """var data = [["py", {"count": 42, "desc": ["Python"]}], """
37 """var data = [["py", {"count": 42, "desc": ["Python"]}], """
35 """["rst", {"count": 11, "desc": ["Rst"]}], """
38 """["rst", {"count": 11, "desc": ["Rst"]}], """
36 """["sh", {"count": 2, "desc": ["Bash"]}], """
39 """["sh", {"count": 2, "desc": ["Bash"]}], """
37 """["makefile", {"count": 1, "desc": ["Makefile", "Makefile"]}],"""
40 """["makefile", {"count": 1, "desc": ["Makefile", "Makefile"]}],"""
38 """ ["cfg", {"count": 1, "desc": ["Ini"]}], """
41 """ ["cfg", {"count": 1, "desc": ["Ini"]}], """
39 """["css", {"count": 1, "desc": ["Css"]}], """
42 """["css", {"count": 1, "desc": ["Css"]}], """
40 """["bat", {"count": 1, "desc": ["Batch"]}]];"""
43 """["bat", {"count": 1, "desc": ["Batch"]}]];"""
41 )
44 )
42
45
43 # clone url...
46 # clone url...
44 response.mustcontain("""<input style="width:80%%;margin-left:105px" type="text" id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"/>""" % HG_REPO)
47 response.mustcontain("""<input style="width:80%%;margin-left:105px" type="text" id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"/>""" % HG_REPO)
45 response.mustcontain("""<input style="display:none;width:80%%;margin-left:105px" type="text" id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"/>""" % ID)
48 response.mustcontain("""<input style="display:none;width:80%%;margin-left:105px" type="text" id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"/>""" % ID)
46
49
47 def test_index_git(self):
50 def test_index_git(self):
48 self.log_user()
51 self.log_user()
49 ID = Repository.get_by_repo_name(GIT_REPO).repo_id
52 ID = Repository.get_by_repo_name(GIT_REPO).repo_id
50 response = self.app.get(url(controller='summary',
53 response = self.app.get(url(controller='summary',
51 action='index',
54 action='index',
52 repo_name=GIT_REPO))
55 repo_name=GIT_REPO))
53
56
54 #repo type
57 #repo type
55 response.mustcontain(
58 response.mustcontain(
56 """<img style="margin-bottom:2px" class="icon" """
59 """<img style="margin-bottom:2px" class="icon" """
57 """title="Git repository" alt="Git repository" """
60 """title="Git repository" alt="Git repository" """
58 """src="/images/icons/giticon.png"/>"""
61 """src="/images/icons/giticon.png"/>"""
59 )
62 )
60 response.mustcontain(
63 response.mustcontain(
61 """<img style="margin-bottom:2px" class="icon" """
64 """<img style="margin-bottom:2px" class="icon" """
62 """title="public repository" alt="public """
65 """title="public repository" alt="public """
63 """repository" src="/images/icons/lock_open.png"/>"""
66 """repository" src="/images/icons/lock_open.png"/>"""
64 )
67 )
65
68
66 # clone url...
69 # clone url...
67 response.mustcontain("""<input style="width:80%%;margin-left:105px" type="text" id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"/>""" % GIT_REPO)
70 response.mustcontain("""<input style="width:80%%;margin-left:105px" type="text" id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"/>""" % GIT_REPO)
68 response.mustcontain("""<input style="display:none;width:80%%;margin-left:105px" type="text" id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"/>""" % ID)
71 response.mustcontain("""<input style="display:none;width:80%%;margin-left:105px" type="text" id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"/>""" % ID)
69
72
70 def test_index_by_id_hg(self):
73 def test_index_by_id_hg(self):
71 self.log_user()
74 self.log_user()
72 ID = Repository.get_by_repo_name(HG_REPO).repo_id
75 ID = Repository.get_by_repo_name(HG_REPO).repo_id
73 response = self.app.get(url(controller='summary',
76 response = self.app.get(url(controller='summary',
74 action='index',
77 action='index',
75 repo_name='_%s' % ID))
78 repo_name='_%s' % ID))
76
79
77 #repo type
80 #repo type
78 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
81 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
79 """title="Mercurial repository" alt="Mercurial """
82 """title="Mercurial repository" alt="Mercurial """
80 """repository" src="/images/icons/hgicon.png"/>""")
83 """repository" src="/images/icons/hgicon.png"/>""")
81 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
84 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
82 """title="public repository" alt="public """
85 """title="public repository" alt="public """
83 """repository" src="/images/icons/lock_open.png"/>""")
86 """repository" src="/images/icons/lock_open.png"/>""")
84
87
88 def test_index_by_repo_having_id_path_in_name_hg(self):
89 self.log_user()
90 _make_repo(name='repo_1')
91 Session().commit()
92 response = self.app.get(url(controller='summary',
93 action='index',
94 repo_name='repo_1'))
95
96 try:
97 response.mustcontain("""repo_1""")
98 finally:
99 RepoModel().delete(Repository.get_by_repo_name('repo_1'))
100 Session().commit()
101
85 def test_index_by_id_git(self):
102 def test_index_by_id_git(self):
86 self.log_user()
103 self.log_user()
87 ID = Repository.get_by_repo_name(GIT_REPO).repo_id
104 ID = Repository.get_by_repo_name(GIT_REPO).repo_id
88 response = self.app.get(url(controller='summary',
105 response = self.app.get(url(controller='summary',
89 action='index',
106 action='index',
90 repo_name='_%s' % ID))
107 repo_name='_%s' % ID))
91
108
92 #repo type
109 #repo type
93 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
110 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
94 """title="Git repository" alt="Git """
111 """title="Git repository" alt="Git """
95 """repository" src="/images/icons/giticon.png"/>""")
112 """repository" src="/images/icons/giticon.png"/>""")
96 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
113 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
97 """title="public repository" alt="public """
114 """title="public repository" alt="public """
98 """repository" src="/images/icons/lock_open.png"/>""")
115 """repository" src="/images/icons/lock_open.png"/>""")
99
116
100 def _enable_stats(self):
117 def _enable_stats(self):
101 r = Repository.get_by_repo_name(HG_REPO)
118 r = Repository.get_by_repo_name(HG_REPO)
102 r.enable_statistics = True
119 r.enable_statistics = True
103 self.Session.add(r)
120 self.Session.add(r)
104 self.Session.commit()
121 self.Session.commit()
General Comments 0
You need to be logged in to leave comments. Login now