##// END OF EJS Templates
be more explicit about constructing compare url
marcink -
r3321:a91fa221 beta
parent child Browse files
Show More
@@ -1,648 +1,648 b''
1 1 """
2 2 Routes configuration
3 3
4 4 The more specific and detailed routes should be defined first so they
5 5 may take precedent over the more generic routes. For more information
6 6 refer to the routes manual at http://routes.groovie.org/docs/
7 7 """
8 8 from __future__ import with_statement
9 9 from routes import Mapper
10 10
11 11 # prefix for non repository related links needs to be prefixed with `/`
12 12 ADMIN_PREFIX = '/_admin'
13 13
14 14
15 15 def make_map(config):
16 16 """Create, configure and return the routes Mapper"""
17 17 rmap = Mapper(directory=config['pylons.paths']['controllers'],
18 18 always_scan=config['debug'])
19 19 rmap.minimization = False
20 20 rmap.explicit = False
21 21
22 22 from rhodecode.lib.utils import is_valid_repo
23 23 from rhodecode.lib.utils import is_valid_repos_group
24 24
25 25 def check_repo(environ, match_dict):
26 26 """
27 27 check for valid repository for proper 404 handling
28 28
29 29 :param environ:
30 30 :param match_dict:
31 31 """
32 32 from rhodecode.model.db import Repository
33 33 repo_name = match_dict.get('repo_name')
34 34
35 35 if match_dict.get('f_path'):
36 36 #fix for multiple initial slashes that causes errors
37 37 match_dict['f_path'] = match_dict['f_path'].lstrip('/')
38 38
39 39 try:
40 40 by_id = repo_name.split('_')
41 41 if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '':
42 42 repo_name = Repository.get(by_id[1]).repo_name
43 43 match_dict['repo_name'] = repo_name
44 44 except:
45 45 pass
46 46
47 47 return is_valid_repo(repo_name, config['base_path'])
48 48
49 49 def check_group(environ, match_dict):
50 50 """
51 51 check for valid repositories group for proper 404 handling
52 52
53 53 :param environ:
54 54 :param match_dict:
55 55 """
56 56 repos_group_name = match_dict.get('group_name')
57 57 return is_valid_repos_group(repos_group_name, config['base_path'])
58 58
59 59 def check_int(environ, match_dict):
60 60 return match_dict.get('id').isdigit()
61 61
62 62 # The ErrorController route (handles 404/500 error pages); it should
63 63 # likely stay at the top, ensuring it can always be resolved
64 64 rmap.connect('/error/{action}', controller='error')
65 65 rmap.connect('/error/{action}/{id}', controller='error')
66 66
67 67 #==========================================================================
68 68 # CUSTOM ROUTES HERE
69 69 #==========================================================================
70 70
71 71 #MAIN PAGE
72 72 rmap.connect('home', '/', controller='home', action='index')
73 73 rmap.connect('repo_switcher', '/repos', controller='home',
74 74 action='repo_switcher')
75 75 rmap.connect('branch_tag_switcher', '/branches-tags/{repo_name:.*?}',
76 76 controller='home', action='branch_tag_switcher')
77 77 rmap.connect('bugtracker',
78 78 "http://bitbucket.org/marcinkuzminski/rhodecode/issues",
79 79 _static=True)
80 80 rmap.connect('rst_help',
81 81 "http://docutils.sourceforge.net/docs/user/rst/quickref.html",
82 82 _static=True)
83 83 rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True)
84 84
85 85 #ADMIN REPOSITORY REST ROUTES
86 86 with rmap.submapper(path_prefix=ADMIN_PREFIX,
87 87 controller='admin/repos') as m:
88 88 m.connect("repos", "/repos",
89 89 action="create", conditions=dict(method=["POST"]))
90 90 m.connect("repos", "/repos",
91 91 action="index", conditions=dict(method=["GET"]))
92 92 m.connect("formatted_repos", "/repos.{format}",
93 93 action="index",
94 94 conditions=dict(method=["GET"]))
95 95 m.connect("new_repo", "/repos/new",
96 96 action="new", conditions=dict(method=["GET"]))
97 97 m.connect("formatted_new_repo", "/repos/new.{format}",
98 98 action="new", conditions=dict(method=["GET"]))
99 99 m.connect("/repos/{repo_name:.*?}",
100 100 action="update", conditions=dict(method=["PUT"],
101 101 function=check_repo))
102 102 m.connect("/repos/{repo_name:.*?}",
103 103 action="delete", conditions=dict(method=["DELETE"],
104 104 function=check_repo))
105 105 # no longer used:
106 106 m.connect("edit_repo_admin", "/repos/{repo_name:.*?}/edit",
107 107 action="edit", conditions=dict(method=["GET"],
108 108 function=check_repo))
109 109 m.connect("formatted_edit_repo", "/repos/{repo_name:.*?}.{format}/edit",
110 110 action="edit", conditions=dict(method=["GET"],
111 111 function=check_repo))
112 112 m.connect("repo", "/repos/{repo_name:.*?}",
113 113 action="show", conditions=dict(method=["GET"],
114 114 function=check_repo))
115 115 m.connect("formatted_repo", "/repos/{repo_name:.*?}.{format}",
116 116 action="show", conditions=dict(method=["GET"],
117 117 function=check_repo))
118 118 #ajax delete repo perm user
119 119 m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*?}",
120 120 action="delete_perm_user",
121 121 conditions=dict(method=["DELETE"], function=check_repo))
122 122
123 123 #ajax delete repo perm users_group
124 124 m.connect('delete_repo_users_group',
125 125 "/repos_delete_users_group/{repo_name:.*?}",
126 126 action="delete_perm_users_group",
127 127 conditions=dict(method=["DELETE"], function=check_repo))
128 128
129 129 #settings actions
130 130 m.connect('repo_stats', "/repos_stats/{repo_name:.*?}",
131 131 action="repo_stats", conditions=dict(method=["DELETE"],
132 132 function=check_repo))
133 133 m.connect('repo_cache', "/repos_cache/{repo_name:.*?}",
134 134 action="repo_cache", conditions=dict(method=["DELETE"],
135 135 function=check_repo))
136 136 m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*?}",
137 137 action="repo_public_journal", conditions=dict(method=["PUT"],
138 138 function=check_repo))
139 139 m.connect('repo_pull', "/repo_pull/{repo_name:.*?}",
140 140 action="repo_pull", conditions=dict(method=["PUT"],
141 141 function=check_repo))
142 142 m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*?}",
143 143 action="repo_as_fork", conditions=dict(method=["PUT"],
144 144 function=check_repo))
145 145 m.connect('repo_locking', "/repo_locking/{repo_name:.*?}",
146 146 action="repo_locking", conditions=dict(method=["PUT"],
147 147 function=check_repo))
148 148 #repo fields
149 149 m.connect('create_repo_fields', "/repo_fields/{repo_name:.*?}/new",
150 150 action="create_repo_field", conditions=dict(method=["PUT"],
151 151 function=check_repo))
152 152
153 153 m.connect('delete_repo_fields', "/repo_fields/{repo_name:.*?}/{field_id}",
154 154 action="delete_repo_field", conditions=dict(method=["DELETE"],
155 155 function=check_repo))
156 156
157 157 with rmap.submapper(path_prefix=ADMIN_PREFIX,
158 158 controller='admin/repos_groups') as m:
159 159 m.connect("repos_groups", "/repos_groups",
160 160 action="create", conditions=dict(method=["POST"]))
161 161 m.connect("repos_groups", "/repos_groups",
162 162 action="index", conditions=dict(method=["GET"]))
163 163 m.connect("formatted_repos_groups", "/repos_groups.{format}",
164 164 action="index", conditions=dict(method=["GET"]))
165 165 m.connect("new_repos_group", "/repos_groups/new",
166 166 action="new", conditions=dict(method=["GET"]))
167 167 m.connect("formatted_new_repos_group", "/repos_groups/new.{format}",
168 168 action="new", conditions=dict(method=["GET"]))
169 169 m.connect("update_repos_group", "/repos_groups/{group_name:.*?}",
170 170 action="update", conditions=dict(method=["PUT"],
171 171 function=check_group))
172 172 m.connect("delete_repos_group", "/repos_groups/{group_name:.*?}",
173 173 action="delete", conditions=dict(method=["DELETE"],
174 174 function=check_group))
175 175 m.connect("edit_repos_group", "/repos_groups/{group_name:.*?}/edit",
176 176 action="edit", conditions=dict(method=["GET"],))
177 177 m.connect("formatted_edit_repos_group",
178 178 "/repos_groups/{group_name:.*?}.{format}/edit",
179 179 action="edit", conditions=dict(method=["GET"],
180 180 function=check_group))
181 181 m.connect("repos_group", "/repos_groups/{group_name:.*?}",
182 182 action="show", conditions=dict(method=["GET"],
183 183 function=check_group))
184 184 m.connect("formatted_repos_group", "/repos_groups/{group_name:.*?}.{format}",
185 185 action="show", conditions=dict(method=["GET"],
186 186 function=check_group))
187 187 # ajax delete repos group perm user
188 188 m.connect('delete_repos_group_user_perm',
189 189 "/delete_repos_group_user_perm/{group_name:.*?}",
190 190 action="delete_repos_group_user_perm",
191 191 conditions=dict(method=["DELETE"], function=check_group))
192 192
193 193 # ajax delete repos group perm users_group
194 194 m.connect('delete_repos_group_users_group_perm',
195 195 "/delete_repos_group_users_group_perm/{group_name:.*?}",
196 196 action="delete_repos_group_users_group_perm",
197 197 conditions=dict(method=["DELETE"], function=check_group))
198 198
199 199 #ADMIN USER REST ROUTES
200 200 with rmap.submapper(path_prefix=ADMIN_PREFIX,
201 201 controller='admin/users') as m:
202 202 m.connect("users", "/users",
203 203 action="create", conditions=dict(method=["POST"]))
204 204 m.connect("users", "/users",
205 205 action="index", conditions=dict(method=["GET"]))
206 206 m.connect("formatted_users", "/users.{format}",
207 207 action="index", conditions=dict(method=["GET"]))
208 208 m.connect("new_user", "/users/new",
209 209 action="new", conditions=dict(method=["GET"]))
210 210 m.connect("formatted_new_user", "/users/new.{format}",
211 211 action="new", conditions=dict(method=["GET"]))
212 212 m.connect("update_user", "/users/{id}",
213 213 action="update", conditions=dict(method=["PUT"]))
214 214 m.connect("delete_user", "/users/{id}",
215 215 action="delete", conditions=dict(method=["DELETE"]))
216 216 m.connect("edit_user", "/users/{id}/edit",
217 217 action="edit", conditions=dict(method=["GET"]))
218 218 m.connect("formatted_edit_user",
219 219 "/users/{id}.{format}/edit",
220 220 action="edit", conditions=dict(method=["GET"]))
221 221 m.connect("user", "/users/{id}",
222 222 action="show", conditions=dict(method=["GET"]))
223 223 m.connect("formatted_user", "/users/{id}.{format}",
224 224 action="show", conditions=dict(method=["GET"]))
225 225
226 226 #EXTRAS USER ROUTES
227 227 m.connect("user_perm", "/users_perm/{id}",
228 228 action="update_perm", conditions=dict(method=["PUT"]))
229 229 m.connect("user_emails", "/users_emails/{id}",
230 230 action="add_email", conditions=dict(method=["PUT"]))
231 231 m.connect("user_emails_delete", "/users_emails/{id}",
232 232 action="delete_email", conditions=dict(method=["DELETE"]))
233 233 m.connect("user_ips", "/users_ips/{id}",
234 234 action="add_ip", conditions=dict(method=["PUT"]))
235 235 m.connect("user_ips_delete", "/users_ips/{id}",
236 236 action="delete_ip", conditions=dict(method=["DELETE"]))
237 237
238 238 #ADMIN USERS GROUPS REST ROUTES
239 239 with rmap.submapper(path_prefix=ADMIN_PREFIX,
240 240 controller='admin/users_groups') as m:
241 241 m.connect("users_groups", "/users_groups",
242 242 action="create", conditions=dict(method=["POST"]))
243 243 m.connect("users_groups", "/users_groups",
244 244 action="index", conditions=dict(method=["GET"]))
245 245 m.connect("formatted_users_groups", "/users_groups.{format}",
246 246 action="index", conditions=dict(method=["GET"]))
247 247 m.connect("new_users_group", "/users_groups/new",
248 248 action="new", conditions=dict(method=["GET"]))
249 249 m.connect("formatted_new_users_group", "/users_groups/new.{format}",
250 250 action="new", conditions=dict(method=["GET"]))
251 251 m.connect("update_users_group", "/users_groups/{id}",
252 252 action="update", conditions=dict(method=["PUT"]))
253 253 m.connect("delete_users_group", "/users_groups/{id}",
254 254 action="delete", conditions=dict(method=["DELETE"]))
255 255 m.connect("edit_users_group", "/users_groups/{id}/edit",
256 256 action="edit", conditions=dict(method=["GET"]))
257 257 m.connect("formatted_edit_users_group",
258 258 "/users_groups/{id}.{format}/edit",
259 259 action="edit", conditions=dict(method=["GET"]))
260 260 m.connect("users_group", "/users_groups/{id}",
261 261 action="show", conditions=dict(method=["GET"]))
262 262 m.connect("formatted_users_group", "/users_groups/{id}.{format}",
263 263 action="show", conditions=dict(method=["GET"]))
264 264
265 265 #EXTRAS USER ROUTES
266 266 m.connect("users_group_perm", "/users_groups_perm/{id}",
267 267 action="update_perm", conditions=dict(method=["PUT"]))
268 268
269 269 #ADMIN GROUP REST ROUTES
270 270 rmap.resource('group', 'groups',
271 271 controller='admin/groups', path_prefix=ADMIN_PREFIX)
272 272
273 273 #ADMIN PERMISSIONS REST ROUTES
274 274 rmap.resource('permission', 'permissions',
275 275 controller='admin/permissions', path_prefix=ADMIN_PREFIX)
276 276
277 277 #ADMIN DEFAULTS REST ROUTES
278 278 rmap.resource('default', 'defaults',
279 279 controller='admin/defaults', path_prefix=ADMIN_PREFIX)
280 280
281 281 ##ADMIN LDAP SETTINGS
282 282 rmap.connect('ldap_settings', '%s/ldap' % ADMIN_PREFIX,
283 283 controller='admin/ldap_settings', action='ldap_settings',
284 284 conditions=dict(method=["POST"]))
285 285
286 286 rmap.connect('ldap_home', '%s/ldap' % ADMIN_PREFIX,
287 287 controller='admin/ldap_settings')
288 288
289 289 #ADMIN SETTINGS REST ROUTES
290 290 with rmap.submapper(path_prefix=ADMIN_PREFIX,
291 291 controller='admin/settings') as m:
292 292 m.connect("admin_settings", "/settings",
293 293 action="create", conditions=dict(method=["POST"]))
294 294 m.connect("admin_settings", "/settings",
295 295 action="index", conditions=dict(method=["GET"]))
296 296 m.connect("formatted_admin_settings", "/settings.{format}",
297 297 action="index", conditions=dict(method=["GET"]))
298 298 m.connect("admin_new_setting", "/settings/new",
299 299 action="new", conditions=dict(method=["GET"]))
300 300 m.connect("formatted_admin_new_setting", "/settings/new.{format}",
301 301 action="new", conditions=dict(method=["GET"]))
302 302 m.connect("/settings/{setting_id}",
303 303 action="update", conditions=dict(method=["PUT"]))
304 304 m.connect("/settings/{setting_id}",
305 305 action="delete", conditions=dict(method=["DELETE"]))
306 306 m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
307 307 action="edit", conditions=dict(method=["GET"]))
308 308 m.connect("formatted_admin_edit_setting",
309 309 "/settings/{setting_id}.{format}/edit",
310 310 action="edit", conditions=dict(method=["GET"]))
311 311 m.connect("admin_setting", "/settings/{setting_id}",
312 312 action="show", conditions=dict(method=["GET"]))
313 313 m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}",
314 314 action="show", conditions=dict(method=["GET"]))
315 315 m.connect("admin_settings_my_account", "/my_account",
316 316 action="my_account", conditions=dict(method=["GET"]))
317 317 m.connect("admin_settings_my_account_update", "/my_account_update",
318 318 action="my_account_update", conditions=dict(method=["PUT"]))
319 319 m.connect("admin_settings_create_repository", "/create_repository",
320 320 action="create_repository", conditions=dict(method=["GET"]))
321 321 m.connect("admin_settings_my_repos", "/my_account/repos",
322 322 action="my_account_my_repos", conditions=dict(method=["GET"]))
323 323 m.connect("admin_settings_my_pullrequests", "/my_account/pull_requests",
324 324 action="my_account_my_pullrequests", conditions=dict(method=["GET"]))
325 325
326 326 #NOTIFICATION REST ROUTES
327 327 with rmap.submapper(path_prefix=ADMIN_PREFIX,
328 328 controller='admin/notifications') as m:
329 329 m.connect("notifications", "/notifications",
330 330 action="create", conditions=dict(method=["POST"]))
331 331 m.connect("notifications", "/notifications",
332 332 action="index", conditions=dict(method=["GET"]))
333 333 m.connect("notifications_mark_all_read", "/notifications/mark_all_read",
334 334 action="mark_all_read", conditions=dict(method=["GET"]))
335 335 m.connect("formatted_notifications", "/notifications.{format}",
336 336 action="index", conditions=dict(method=["GET"]))
337 337 m.connect("new_notification", "/notifications/new",
338 338 action="new", conditions=dict(method=["GET"]))
339 339 m.connect("formatted_new_notification", "/notifications/new.{format}",
340 340 action="new", conditions=dict(method=["GET"]))
341 341 m.connect("/notification/{notification_id}",
342 342 action="update", conditions=dict(method=["PUT"]))
343 343 m.connect("/notification/{notification_id}",
344 344 action="delete", conditions=dict(method=["DELETE"]))
345 345 m.connect("edit_notification", "/notification/{notification_id}/edit",
346 346 action="edit", conditions=dict(method=["GET"]))
347 347 m.connect("formatted_edit_notification",
348 348 "/notification/{notification_id}.{format}/edit",
349 349 action="edit", conditions=dict(method=["GET"]))
350 350 m.connect("notification", "/notification/{notification_id}",
351 351 action="show", conditions=dict(method=["GET"]))
352 352 m.connect("formatted_notification", "/notifications/{notification_id}.{format}",
353 353 action="show", conditions=dict(method=["GET"]))
354 354
355 355 #ADMIN MAIN PAGES
356 356 with rmap.submapper(path_prefix=ADMIN_PREFIX,
357 357 controller='admin/admin') as m:
358 358 m.connect('admin_home', '', action='index')
359 359 m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
360 360 action='add_repo')
361 361
362 362 #==========================================================================
363 363 # API V2
364 364 #==========================================================================
365 365 with rmap.submapper(path_prefix=ADMIN_PREFIX,
366 366 controller='api/api') as m:
367 367 m.connect('api', '/api')
368 368
369 369 #USER JOURNAL
370 370 rmap.connect('journal', '%s/journal' % ADMIN_PREFIX,
371 371 controller='journal', action='index')
372 372 rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX,
373 373 controller='journal', action='journal_rss')
374 374 rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX,
375 375 controller='journal', action='journal_atom')
376 376
377 377 rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX,
378 378 controller='journal', action="public_journal")
379 379
380 380 rmap.connect('public_journal_rss', '%s/public_journal/rss' % ADMIN_PREFIX,
381 381 controller='journal', action="public_journal_rss")
382 382
383 383 rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % ADMIN_PREFIX,
384 384 controller='journal', action="public_journal_rss")
385 385
386 386 rmap.connect('public_journal_atom',
387 387 '%s/public_journal/atom' % ADMIN_PREFIX, controller='journal',
388 388 action="public_journal_atom")
389 389
390 390 rmap.connect('public_journal_atom_old',
391 391 '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal',
392 392 action="public_journal_atom")
393 393
394 394 rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX,
395 395 controller='journal', action='toggle_following',
396 396 conditions=dict(method=["POST"]))
397 397
398 398 #SEARCH
399 399 rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',)
400 400 rmap.connect('search_repo_admin', '%s/search/{repo_name:.*}' % ADMIN_PREFIX,
401 401 controller='search',
402 402 conditions=dict(function=check_repo))
403 403 rmap.connect('search_repo', '/{repo_name:.*?}/search',
404 404 controller='search',
405 405 conditions=dict(function=check_repo),
406 406 )
407 407
408 408 #LOGIN/LOGOUT/REGISTER/SIGN IN
409 409 rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login')
410 410 rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login',
411 411 action='logout')
412 412
413 413 rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login',
414 414 action='register')
415 415
416 416 rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX,
417 417 controller='login', action='password_reset')
418 418
419 419 rmap.connect('reset_password_confirmation',
420 420 '%s/password_reset_confirmation' % ADMIN_PREFIX,
421 421 controller='login', action='password_reset_confirmation')
422 422
423 423 #FEEDS
424 424 rmap.connect('rss_feed_home', '/{repo_name:.*?}/feed/rss',
425 425 controller='feed', action='rss',
426 426 conditions=dict(function=check_repo))
427 427
428 428 rmap.connect('atom_feed_home', '/{repo_name:.*?}/feed/atom',
429 429 controller='feed', action='atom',
430 430 conditions=dict(function=check_repo))
431 431
432 432 #==========================================================================
433 433 # REPOSITORY ROUTES
434 434 #==========================================================================
435 435 rmap.connect('summary_home', '/{repo_name:.*?}',
436 436 controller='summary',
437 437 conditions=dict(function=check_repo))
438 438
439 439 rmap.connect('repo_size', '/{repo_name:.*?}/repo_size',
440 440 controller='summary', action='repo_size',
441 441 conditions=dict(function=check_repo))
442 442
443 443 rmap.connect('repos_group_home', '/{group_name:.*}',
444 444 controller='admin/repos_groups', action="show_by_name",
445 445 conditions=dict(function=check_group))
446 446
447 447 rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}',
448 448 controller='changeset', revision='tip',
449 449 conditions=dict(function=check_repo))
450 450
451 451 rmap.connect("edit_repo", "/{repo_name:.*?}/edit",
452 452 controller='admin/repos', action="edit",
453 453 conditions=dict(method=["GET"], function=check_repo)
454 454 )
455 455
456 456 #still working url for backward compat.
457 457 rmap.connect('raw_changeset_home_depraced',
458 458 '/{repo_name:.*?}/raw-changeset/{revision}',
459 459 controller='changeset', action='changeset_raw',
460 460 revision='tip', conditions=dict(function=check_repo))
461 461
462 462 ## new URLs
463 463 rmap.connect('changeset_raw_home',
464 464 '/{repo_name:.*?}/changeset-diff/{revision}',
465 465 controller='changeset', action='changeset_raw',
466 466 revision='tip', conditions=dict(function=check_repo))
467 467
468 468 rmap.connect('changeset_patch_home',
469 469 '/{repo_name:.*?}/changeset-patch/{revision}',
470 470 controller='changeset', action='changeset_patch',
471 471 revision='tip', conditions=dict(function=check_repo))
472 472
473 473 rmap.connect('changeset_download_home',
474 474 '/{repo_name:.*?}/changeset-download/{revision}',
475 475 controller='changeset', action='changeset_download',
476 476 revision='tip', conditions=dict(function=check_repo))
477 477
478 478 rmap.connect('changeset_comment',
479 479 '/{repo_name:.*?}/changeset/{revision}/comment',
480 480 controller='changeset', revision='tip', action='comment',
481 481 conditions=dict(function=check_repo))
482 482
483 483 rmap.connect('changeset_comment_delete',
484 484 '/{repo_name:.*?}/changeset/comment/{comment_id}/delete',
485 485 controller='changeset', action='delete_comment',
486 486 conditions=dict(function=check_repo, method=["DELETE"]))
487 487
488 488 rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}',
489 489 controller='changeset', action='changeset_info')
490 490
491 491 rmap.connect('compare_url',
492 492 '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}',
493 493 controller='compare', action='index',
494 494 conditions=dict(function=check_repo),
495 495 requirements=dict(
496 org_ref_type='(branch|book|tag|rev|org_ref_type)',
497 other_ref_type='(branch|book|tag|rev|other_ref_type)')
496 org_ref_type='(branch|book|tag|rev|__org_ref_type__)',
497 other_ref_type='(branch|book|tag|rev|__other_ref_type__)')
498 498 )
499 499
500 500 rmap.connect('pullrequest_home',
501 501 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
502 502 action='index', conditions=dict(function=check_repo,
503 503 method=["GET"]))
504 504
505 505 rmap.connect('pullrequest',
506 506 '/{repo_name:.*?}/pull-request/new', controller='pullrequests',
507 507 action='create', conditions=dict(function=check_repo,
508 508 method=["POST"]))
509 509
510 510 rmap.connect('pullrequest_show',
511 511 '/{repo_name:.*?}/pull-request/{pull_request_id}',
512 512 controller='pullrequests',
513 513 action='show', conditions=dict(function=check_repo,
514 514 method=["GET"]))
515 515 rmap.connect('pullrequest_update',
516 516 '/{repo_name:.*?}/pull-request/{pull_request_id}',
517 517 controller='pullrequests',
518 518 action='update', conditions=dict(function=check_repo,
519 519 method=["PUT"]))
520 520 rmap.connect('pullrequest_delete',
521 521 '/{repo_name:.*?}/pull-request/{pull_request_id}',
522 522 controller='pullrequests',
523 523 action='delete', conditions=dict(function=check_repo,
524 524 method=["DELETE"]))
525 525
526 526 rmap.connect('pullrequest_show_all',
527 527 '/{repo_name:.*?}/pull-request',
528 528 controller='pullrequests',
529 529 action='show_all', conditions=dict(function=check_repo,
530 530 method=["GET"]))
531 531
532 532 rmap.connect('pullrequest_comment',
533 533 '/{repo_name:.*?}/pull-request-comment/{pull_request_id}',
534 534 controller='pullrequests',
535 535 action='comment', conditions=dict(function=check_repo,
536 536 method=["POST"]))
537 537
538 538 rmap.connect('pullrequest_comment_delete',
539 539 '/{repo_name:.*?}/pull-request-comment/{comment_id}/delete',
540 540 controller='pullrequests', action='delete_comment',
541 541 conditions=dict(function=check_repo, method=["DELETE"]))
542 542
543 543 rmap.connect('summary_home_summary', '/{repo_name:.*?}/summary',
544 544 controller='summary', conditions=dict(function=check_repo))
545 545
546 546 rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog',
547 547 controller='shortlog', conditions=dict(function=check_repo))
548 548
549 549 rmap.connect('shortlog_file_home', '/{repo_name:.*?}/shortlog/{revision}/{f_path:.*}',
550 550 controller='shortlog', f_path=None,
551 551 conditions=dict(function=check_repo))
552 552
553 553 rmap.connect('branches_home', '/{repo_name:.*?}/branches',
554 554 controller='branches', conditions=dict(function=check_repo))
555 555
556 556 rmap.connect('tags_home', '/{repo_name:.*?}/tags',
557 557 controller='tags', conditions=dict(function=check_repo))
558 558
559 559 rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks',
560 560 controller='bookmarks', conditions=dict(function=check_repo))
561 561
562 562 rmap.connect('changelog_home', '/{repo_name:.*?}/changelog',
563 563 controller='changelog', conditions=dict(function=check_repo))
564 564
565 565 rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}',
566 566 controller='changelog', action='changelog_details',
567 567 conditions=dict(function=check_repo))
568 568
569 569 rmap.connect('files_home', '/{repo_name:.*?}/files/{revision}/{f_path:.*}',
570 570 controller='files', revision='tip', f_path='',
571 571 conditions=dict(function=check_repo))
572 572
573 573 rmap.connect('files_history_home',
574 574 '/{repo_name:.*?}/history/{revision}/{f_path:.*}',
575 575 controller='files', action='history', revision='tip', f_path='',
576 576 conditions=dict(function=check_repo))
577 577
578 578 rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}',
579 579 controller='files', action='diff', revision='tip', f_path='',
580 580 conditions=dict(function=check_repo))
581 581
582 582 rmap.connect('files_rawfile_home',
583 583 '/{repo_name:.*?}/rawfile/{revision}/{f_path:.*}',
584 584 controller='files', action='rawfile', revision='tip',
585 585 f_path='', conditions=dict(function=check_repo))
586 586
587 587 rmap.connect('files_raw_home',
588 588 '/{repo_name:.*?}/raw/{revision}/{f_path:.*}',
589 589 controller='files', action='raw', revision='tip', f_path='',
590 590 conditions=dict(function=check_repo))
591 591
592 592 rmap.connect('files_annotate_home',
593 593 '/{repo_name:.*?}/annotate/{revision}/{f_path:.*}',
594 594 controller='files', action='index', revision='tip',
595 595 f_path='', annotate=True, conditions=dict(function=check_repo))
596 596
597 597 rmap.connect('files_edit_home',
598 598 '/{repo_name:.*?}/edit/{revision}/{f_path:.*}',
599 599 controller='files', action='edit', revision='tip',
600 600 f_path='', conditions=dict(function=check_repo))
601 601
602 602 rmap.connect('files_add_home',
603 603 '/{repo_name:.*?}/add/{revision}/{f_path:.*}',
604 604 controller='files', action='add', revision='tip',
605 605 f_path='', conditions=dict(function=check_repo))
606 606
607 607 rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}',
608 608 controller='files', action='archivefile',
609 609 conditions=dict(function=check_repo))
610 610
611 611 rmap.connect('files_nodelist_home',
612 612 '/{repo_name:.*?}/nodelist/{revision}/{f_path:.*}',
613 613 controller='files', action='nodelist',
614 614 conditions=dict(function=check_repo))
615 615
616 616 rmap.connect('repo_settings_delete', '/{repo_name:.*?}/settings',
617 617 controller='settings', action="delete",
618 618 conditions=dict(method=["DELETE"], function=check_repo))
619 619
620 620 rmap.connect('repo_settings_update', '/{repo_name:.*?}/settings',
621 621 controller='settings', action="update",
622 622 conditions=dict(method=["PUT"], function=check_repo))
623 623
624 624 rmap.connect('repo_settings_home', '/{repo_name:.*?}/settings',
625 625 controller='settings', action='index',
626 626 conditions=dict(function=check_repo))
627 627
628 628 rmap.connect('toggle_locking', "/{repo_name:.*?}/locking_toggle",
629 629 controller='settings', action="toggle_locking",
630 630 conditions=dict(method=["GET"], function=check_repo))
631 631
632 632 rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork',
633 633 controller='forks', action='fork_create',
634 634 conditions=dict(function=check_repo, method=["POST"]))
635 635
636 636 rmap.connect('repo_fork_home', '/{repo_name:.*?}/fork',
637 637 controller='forks', action='fork',
638 638 conditions=dict(function=check_repo))
639 639
640 640 rmap.connect('repo_forks_home', '/{repo_name:.*?}/forks',
641 641 controller='forks', action='forks',
642 642 conditions=dict(function=check_repo))
643 643
644 644 rmap.connect('repo_followers_home', '/{repo_name:.*?}/followers',
645 645 controller='followers', action='followers',
646 646 conditions=dict(function=check_repo))
647 647
648 648 return rmap
@@ -1,204 +1,199 b''
1 1 <%inherit file="/base/base.html"/>
2 2
3 3 <%def name="title()">
4 4 ${c.repo_name} ${_('New pull request')}
5 5 </%def>
6 6
7 7 <%def name="breadcrumbs_links()">
8 8 ${h.link_to(_(u'Home'),h.url('/'))}
9 9 &raquo;
10 10 ${h.link_to(c.repo_name,h.url('changelog_home',repo_name=c.repo_name))}
11 11 &raquo;
12 12 ${_('New pull request')}
13 13 </%def>
14 14
15 15 <%def name="main()">
16 16
17 17 <div class="box">
18 18 <!-- box / title -->
19 19 <div class="title">
20 20 ${self.breadcrumbs()}
21 21 </div>
22 22 ${h.form(url('pullrequest', repo_name=c.repo_name), method='post', id='pull_request_form')}
23 23 <div style="float:left;padding:0px 30px 30px 30px">
24 24 <input type="hidden" name="rev_start" value="${request.GET.get('rev_start')}" />
25 25 <input type="hidden" name="rev_end" value="${request.GET.get('rev_end')}" />
26 26
27 27 ##ORG
28 28 <div style="float:left">
29 29 <div class="fork_user">
30 30 <div class="gravatar">
31 31 <img alt="gravatar" src="${h.gravatar_url(c.rhodecode_db_repo.user.email,24)}"/>
32 32 </div>
33 33 <span style="font-size: 20px">
34 34 ${h.select('org_repo','',c.org_repos,class_='refs')}:${h.select('org_ref','',c.org_refs,class_='refs')}
35 35 </span>
36 36 <div style="padding:5px 3px 3px 42px;">${c.rhodecode_db_repo.description}</div>
37 37 </div>
38 38 <div style="clear:both;padding-top: 10px"></div>
39 39 </div>
40 40 <div style="float:left;font-size:24px;padding:0px 20px">
41 41 <img height=32 width=32 src="${h.url('/images/arrow_right_64.png')}"/>
42 42 </div>
43 43
44 44 ##OTHER, most Probably the PARENT OF THIS FORK
45 45 <div style="float:left">
46 46 <div class="fork_user">
47 47 <div class="gravatar">
48 48 <img id="other_repo_gravatar" alt="gravatar" src=""/>
49 49 </div>
50 50 <span style="font-size: 20px">
51 51 ${h.select('other_repo',c.default_pull_request ,c.other_repos,class_='refs')}:${h.select('other_ref',c.default_pull_request_rev,c.default_revs,class_='refs')}
52 52 </span>
53 53 <span style="padding:3px">
54 54 <a id="refresh" href="#" class="tooltip" title="${h.tooltip(_('refresh overview'))}">
55 55 <img style="margin:3px" class="icon" title="${_('Refresh')}" alt="${_('Refresh')}" src="${h.url('/images/icons/arrow_refresh.png')}"/>
56 56 </a>
57 57 </span>
58 58 <div id="other_repo_desc" style="padding:5px 3px 3px 42px;"></div>
59 59 </div>
60 60 <div style="clear:both;padding-top: 10px"></div>
61 61 </div>
62 62 <div style="clear:both;padding-top: 10px"></div>
63 63 ## overview pulled by ajax
64 64 <div style="float:left" id="pull_request_overview"></div>
65 65 <div style="float:left;clear:both;padding:10px 10px 10px 0px;display:none">
66 66 <a id="pull_request_overview_url" href="#">${_('Detailed compare view')}</a>
67 67 </div>
68 68 </div>
69 69 <div style="float:left; border-left:1px dashed #eee">
70 70 <h4>${_('Pull request reviewers')}</h4>
71 71 <div id="reviewers" style="padding:0px 0px 0px 15px">
72 72 ## members goes here !
73 73 <div class="group_members_wrap">
74 74 <ul id="review_members" class="group_members">
75 75 %for member in c.review_members:
76 76 <li id="reviewer_${member.user_id}">
77 77 <div class="reviewers_member">
78 78 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(member.email,14)}"/> </div>
79 79 <div style="float:left">${member.full_name} (${_('owner')})</div>
80 80 <input type="hidden" value="${member.user_id}" name="review_members" />
81 81 <span class="delete_icon action_button" onclick="removeReviewer(${member.user_id})"></span>
82 82 </div>
83 83 </li>
84 84 %endfor
85 85 </ul>
86 86 </div>
87 87
88 88 <div class='ac'>
89 89 <div class="reviewer_ac">
90 90 ${h.text('user', class_='yui-ac-input')}
91 91 <span class="help-block">${_('Add reviewer to this pull request.')}</span>
92 92 <div id="reviewers_container"></div>
93 93 </div>
94 94 </div>
95 95 </div>
96 96 </div>
97 97 <h3>${_('Create new pull request')}</h3>
98 98
99 99 <div class="form">
100 100 <!-- fields -->
101 101
102 102 <div class="fields">
103 103
104 104 <div class="field">
105 105 <div class="label">
106 106 <label for="pullrequest_title">${_('Title')}:</label>
107 107 </div>
108 108 <div class="input">
109 109 ${h.text('pullrequest_title',size=30)}
110 110 </div>
111 111 </div>
112 112
113 113 <div class="field">
114 114 <div class="label label-textarea">
115 115 <label for="pullrequest_desc">${_('description')}:</label>
116 116 </div>
117 117 <div class="textarea text-area editor">
118 118 ${h.textarea('pullrequest_desc',size=30)}
119 119 </div>
120 120 </div>
121 121
122 122 <div class="buttons">
123 123 ${h.submit('save',_('Send pull request'),class_="ui-btn large")}
124 124 ${h.reset('reset',_('Reset'),class_="ui-btn large")}
125 125 </div>
126 126 </div>
127 127 </div>
128 128 ${h.end_form()}
129 129
130 130 </div>
131 131
132 132 <script type="text/javascript">
133 133 var _USERS_AC_DATA = ${c.users_array|n};
134 134 var _GROUPS_AC_DATA = ${c.users_groups_array|n};
135 135 PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
136 136
137 137 var other_repos_info = ${c.other_repos_info|n};
138 138
139 139 var loadPreview = function(){
140 140 YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none');
141 //url template
141 142 var url = "${h.url('compare_url',
142 repo_name='org_repo',
143 org_ref_type='org_ref_type', org_ref='org_ref',
144 other_repo='other_repo',
145 other_ref_type='other_ref_type', other_ref='other_ref',
143 repo_name='__org_repo__',
144 org_ref_type='__org_ref_type__',
145 org_ref='__org_ref__',
146 other_repo='__other_repo__',
147 other_ref_type='__other_ref_type__',
148 other_ref='__other_ref__',
146 149 as_form=True,
147 150 rev_start=request.GET.get('rev_start',''),
148 151 rev_end=request.GET.get('rev_end',''))}";
152 var org_repo = YUQ('#pull_request_form #org_repo')[0].value;
153 var org_ref = YUQ('#pull_request_form #org_ref')[0].value.split(':');
154
155 var other_repo = YUQ('#pull_request_form #other_repo')[0].value;
156 var other_ref = YUQ('#pull_request_form #other_ref')[0].value.split(':');
149 157
150 158 var select_refs = YUQ('#pull_request_form select.refs')
151 var rev_data = {}; // gather the org/other ref and repo here
152 for(var i=0;i<select_refs.length;i++){
153 var select_ref = select_refs[i];
154 var select_ref_data = select_ref.value.split(':');
155 var key = null;
156 var val = null;
159 var rev_data = {
160 'org_repo': org_repo,
161 'org_ref': org_ref[1],
162 'org_ref_type': org_ref[0],
163 'other_repo': other_repo,
164 'other_ref': other_ref[1],
165 'other_ref_type': other_ref[0],
166 }; // gather the org/other ref and repo here
157 167
158 if(select_ref_data.length>1){
159 key = select_ref.name+"_type";
160 val = select_ref_data[0];
161 url = url.replace(key,val);
162 rev_data[key] = val;
163
164 key = select_ref.name;
165 val = select_ref_data[1];
166 url = url.replace(key,val);
167 rev_data[key] = val;
168
169 }else{
170 key = select_ref.name;
171 val = select_ref.value;
172 url = url.replace(key,val);
173 rev_data[key] = val;
174 }
168 for (k in rev_data){
169 url = url.replace('__'+k+'__',rev_data[k]);
175 170 }
176 171
177 172 YUE.on('other_repo', 'change', function(e){
178 173 var repo_name = e.currentTarget.value;
179 174 // replace the <select> of changed repo
180 175 YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs'];
181 176 });
182 177
183 178 ypjax(url,'pull_request_overview', function(data){
184 179 var sel_box = YUQ('#pull_request_form #other_repo')[0];
185 180 var repo_name = sel_box.options[sel_box.selectedIndex].value;
186 181 YUD.get('pull_request_overview_url').href = url;
187 182 YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','');
188 183 YUD.get('other_repo_gravatar').src = other_repos_info[repo_name]['gravatar'];
189 184 YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description'];
190 185 YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs'];
191 186 // select back the revision that was just compared
192 187 setSelectValue(YUD.get('other_ref'), rev_data['other_ref']);
193 188 })
194 189 }
195 190 YUE.on('refresh','click',function(e){
196 191 loadPreview()
197 192 })
198 193
199 194 //lazy load overview after 0.5s
200 195 setTimeout(loadPreview, 500)
201 196
202 197 </script>
203 198
204 199 </%def>
General Comments 0
You need to be logged in to leave comments. Login now