##// END OF EJS Templates
fixed missing permissions check on forks page
marcink -
r2176:162bf5c9 beta
parent child Browse files
Show More
@@ -1,615 +1,616 b''
1 1 .. _changelog:
2 2
3 3 =========
4 4 Changelog
5 5 =========
6 6
7 7 1.3.5 (**2012-XX-XX**)
8 8 ----------------------
9 9
10 10 :status: in-progress
11 11 :branch: beta
12 12
13 13 news
14 14 ++++
15 15
16 16 - use ext_json for json module
17 17
18 18 fixes
19 19 +++++
20 20
21 21 - fixed dev-version marker for stable when served from source codes
22 - fixed missing permission checks on show forks page
22 23
23 24 1.3.4 (**2012-03-28**)
24 25 ----------------------
25 26
26 27 news
27 28 ++++
28 29
29 30 - Whoosh logging is now controlled by the .ini files logging setup
30 31 - added clone-url into edit form on /settings page
31 32 - added help text into repo add/edit forms
32 33 - created rcextensions module with additional mappings (ref #322) and
33 34 post push/pull/create repo hooks callbacks
34 35 - implemented #377 Users view for his own permissions on account page
35 36 - #399 added inheritance of permissions for users group on repos groups
36 37 - #401 repository group is automatically pre-selected when adding repos
37 38 inside a repository group
38 39 - added alternative HTTP 403 response when client failed to authenticate. Helps
39 40 solving issues with Mercurial and LDAP
40 41 - #402 removed group prefix from repository name when listing repositories
41 42 inside a group
42 43 - added gravatars into permission view and permissions autocomplete
43 44 - #347 when running multiple RhodeCode instances, properly invalidates cache
44 45 for all registered servers
45 46
46 47 fixes
47 48 +++++
48 49
49 50 - fixed #390 cache invalidation problems on repos inside group
50 51 - fixed #385 clone by ID url was loosing proxy prefix in URL
51 52 - fixed some unicode problems with waitress
52 53 - fixed issue with escaping < and > in changeset commits
53 54 - fixed error occurring during recursive group creation in API
54 55 create_repo function
55 56 - fixed #393 py2.5 fixes for routes url generator
56 57 - fixed #397 Private repository groups shows up before login
57 58 - fixed #396 fixed problems with revoking users in nested groups
58 59 - fixed mysql unicode issues + specified InnoDB as default engine with
59 60 utf8 charset
60 61 - #406 trim long branch/tag names in changelog to not break UI
61 62
62 63 1.3.3 (**2012-03-02**)
63 64 ----------------------
64 65
65 66 news
66 67 ++++
67 68
68 69
69 70 fixes
70 71 +++++
71 72
72 73 - fixed some python2.5 compatibility issues
73 74 - fixed issues with removed repos was accidentally added as groups, after
74 75 full rescan of paths
75 76 - fixes #376 Cannot edit user (using container auth)
76 77 - fixes #378 Invalid image urls on changeset screen with proxy-prefix
77 78 configuration
78 79 - fixed initial sorting of repos inside repo group
79 80 - fixes issue when user tried to resubmit same permission into user/user_groups
80 81 - bumped beaker version that fixes #375 leap error bug
81 82 - fixed raw_changeset for git. It was generated with hg patch headers
82 83 - fixed vcs issue with last_changeset for filenodes
83 84 - fixed missing commit after hook delete
84 85 - fixed #372 issues with git operation detection that caused a security issue
85 86 for git repos
86 87
87 88 1.3.2 (**2012-02-28**)
88 89 ----------------------
89 90
90 91 news
91 92 ++++
92 93
93 94
94 95 fixes
95 96 +++++
96 97
97 98 - fixed git protocol issues with repos-groups
98 99 - fixed git remote repos validator that prevented from cloning remote git repos
99 100 - fixes #370 ending slashes fixes for repo and groups
100 101 - fixes #368 improved git-protocol detection to handle other clients
101 102 - fixes #366 When Setting Repository Group To Blank Repo Group Wont Be
102 103 Moved To Root
103 104 - fixes #371 fixed issues with beaker/sqlalchemy and non-ascii cache keys
104 105 - fixed #373 missing cascade drop on user_group_to_perm table
105 106
106 107 1.3.1 (**2012-02-27**)
107 108 ----------------------
108 109
109 110 news
110 111 ++++
111 112
112 113
113 114 fixes
114 115 +++++
115 116
116 117 - redirection loop occurs when remember-me wasn't checked during login
117 118 - fixes issues with git blob history generation
118 119 - don't fetch branch for git in file history dropdown. Causes unneeded slowness
119 120
120 121 1.3.0 (**2012-02-26**)
121 122 ----------------------
122 123
123 124 news
124 125 ++++
125 126
126 127 - code review, inspired by github code-comments
127 128 - #215 rst and markdown README files support
128 129 - #252 Container-based and proxy pass-through authentication support
129 130 - #44 branch browser. Filtering of changelog by branches
130 131 - mercurial bookmarks support
131 132 - new hover top menu, optimized to add maximum size for important views
132 133 - configurable clone url template with possibility to specify protocol like
133 134 ssh:// or http:// and also manually alter other parts of clone_url.
134 135 - enabled largefiles extension by default
135 136 - optimized summary file pages and saved a lot of unused space in them
136 137 - #239 option to manually mark repository as fork
137 138 - #320 mapping of commit authors to RhodeCode users
138 139 - #304 hashes are displayed using monospace font
139 140 - diff configuration, toggle white lines and context lines
140 141 - #307 configurable diffs, whitespace toggle, increasing context lines
141 142 - sorting on branches, tags and bookmarks using YUI datatable
142 143 - improved file filter on files page
143 144 - implements #330 api method for listing nodes ar particular revision
144 145 - #73 added linking issues in commit messages to chosen issue tracker url
145 146 based on user defined regular expression
146 147 - added linking of changesets in commit messages
147 148 - new compact changelog with expandable commit messages
148 149 - firstname and lastname are optional in user creation
149 150 - #348 added post-create repository hook
150 151 - #212 global encoding settings is now configurable from .ini files
151 152 - #227 added repository groups permissions
152 153 - markdown gets codehilite extensions
153 154 - new API methods, delete_repositories, grante/revoke permissions for groups
154 155 and repos
155 156
156 157
157 158 fixes
158 159 +++++
159 160
160 161 - rewrote dbsession management for atomic operations, and better error handling
161 162 - fixed sorting of repo tables
162 163 - #326 escape of special html entities in diffs
163 164 - normalized user_name => username in api attributes
164 165 - fixes #298 ldap created users with mixed case emails created conflicts
165 166 on saving a form
166 167 - fixes issue when owner of a repo couldn't revoke permissions for users
167 168 and groups
168 169 - fixes #271 rare JSON serialization problem with statistics
169 170 - fixes #337 missing validation check for conflicting names of a group with a
170 171 repositories group
171 172 - #340 fixed session problem for mysql and celery tasks
172 173 - fixed #331 RhodeCode mangles repository names if the a repository group
173 174 contains the "full path" to the repositories
174 175 - #355 RhodeCode doesn't store encrypted LDAP passwords
175 176
176 177 1.2.5 (**2012-01-28**)
177 178 ----------------------
178 179
179 180 news
180 181 ++++
181 182
182 183 fixes
183 184 +++++
184 185
185 186 - #340 Celery complains about MySQL server gone away, added session cleanup
186 187 for celery tasks
187 188 - #341 "scanning for repositories in None" log message during Rescan was missing
188 189 a parameter
189 190 - fixed creating archives with subrepos. Some hooks were triggered during that
190 191 operation leading to crash.
191 192 - fixed missing email in account page.
192 193 - Reverted Mercurial to 2.0.1 for windows due to bug in Mercurial that makes
193 194 forking on windows impossible
194 195
195 196 1.2.4 (**2012-01-19**)
196 197 ----------------------
197 198
198 199 news
199 200 ++++
200 201
201 202 - RhodeCode is bundled with mercurial series 2.0.X by default, with
202 203 full support to largefiles extension. Enabled by default in new installations
203 204 - #329 Ability to Add/Remove Groups to/from a Repository via AP
204 205 - added requires.txt file with requirements
205 206
206 207 fixes
207 208 +++++
208 209
209 210 - fixes db session issues with celery when emailing admins
210 211 - #331 RhodeCode mangles repository names if the a repository group
211 212 contains the "full path" to the repositories
212 213 - #298 Conflicting e-mail addresses for LDAP and RhodeCode users
213 214 - DB session cleanup after hg protocol operations, fixes issues with
214 215 `mysql has gone away` errors
215 216 - #333 doc fixes for get_repo api function
216 217 - #271 rare JSON serialization problem with statistics enabled
217 218 - #337 Fixes issues with validation of repository name conflicting with
218 219 a group name. A proper message is now displayed.
219 220 - #292 made ldap_dn in user edit readonly, to get rid of confusion that field
220 221 doesn't work
221 222 - #316 fixes issues with web description in hgrc files
222 223
223 224 1.2.3 (**2011-11-02**)
224 225 ----------------------
225 226
226 227 news
227 228 ++++
228 229
229 230 - added option to manage repos group for non admin users
230 231 - added following API methods for get_users, create_user, get_users_groups,
231 232 get_users_group, create_users_group, add_user_to_users_groups, get_repos,
232 233 get_repo, create_repo, add_user_to_repo
233 234 - implements #237 added password confirmation for my account
234 235 and admin edit user.
235 236 - implements #291 email notification for global events are now sent to all
236 237 administrator users, and global config email.
237 238
238 239 fixes
239 240 +++++
240 241
241 242 - added option for passing auth method for smtp mailer
242 243 - #276 issue with adding a single user with id>10 to usergroups
243 244 - #277 fixes windows LDAP settings in which missing values breaks the ldap auth
244 245 - #288 fixes managing of repos in a group for non admin user
245 246
246 247 1.2.2 (**2011-10-17**)
247 248 ----------------------
248 249
249 250 news
250 251 ++++
251 252
252 253 - #226 repo groups are available by path instead of numerical id
253 254
254 255 fixes
255 256 +++++
256 257
257 258 - #259 Groups with the same name but with different parent group
258 259 - #260 Put repo in group, then move group to another group -> repo becomes unavailable
259 260 - #258 RhodeCode 1.2 assumes egg folder is writable (lockfiles problems)
260 261 - #265 ldap save fails sometimes on converting attributes to booleans,
261 262 added getter and setter into model that will prevent from this on db model level
262 263 - fixed problems with timestamps issues #251 and #213
263 264 - fixes #266 RhodeCode allows to create repo with the same name and in
264 265 the same parent as group
265 266 - fixes #245 Rescan of the repositories on Windows
266 267 - fixes #248 cannot edit repos inside a group on windows
267 268 - fixes #219 forking problems on windows
268 269
269 270 1.2.1 (**2011-10-08**)
270 271 ----------------------
271 272
272 273 news
273 274 ++++
274 275
275 276
276 277 fixes
277 278 +++++
278 279
279 280 - fixed problems with basic auth and push problems
280 281 - gui fixes
281 282 - fixed logger
282 283
283 284 1.2.0 (**2011-10-07**)
284 285 ----------------------
285 286
286 287 news
287 288 ++++
288 289
289 290 - implemented #47 repository groups
290 291 - implemented #89 Can setup google analytics code from settings menu
291 292 - implemented #91 added nicer looking archive urls with more download options
292 293 like tags, branches
293 294 - implemented #44 into file browsing, and added follow branch option
294 295 - implemented #84 downloads can be enabled/disabled for each repository
295 296 - anonymous repository can be cloned without having to pass default:default
296 297 into clone url
297 298 - fixed #90 whoosh indexer can index chooses repositories passed in command
298 299 line
299 300 - extended journal with day aggregates and paging
300 301 - implemented #107 source code lines highlight ranges
301 302 - implemented #93 customizable changelog on combined revision ranges -
302 303 equivalent of githubs compare view
303 304 - implemented #108 extended and more powerful LDAP configuration
304 305 - implemented #56 users groups
305 306 - major code rewrites optimized codes for speed and memory usage
306 307 - raw and diff downloads are now in git format
307 308 - setup command checks for write access to given path
308 309 - fixed many issues with international characters and unicode. It uses utf8
309 310 decode with replace to provide less errors even with non utf8 encoded strings
310 311 - #125 added API KEY access to feeds
311 312 - #109 Repository can be created from external Mercurial link (aka. remote
312 313 repository, and manually updated (via pull) from admin panel
313 314 - beta git support - push/pull server + basic view for git repos
314 315 - added followers page and forks page
315 316 - server side file creation (with binary file upload interface)
316 317 and edition with commits powered by codemirror
317 318 - #111 file browser file finder, quick lookup files on whole file tree
318 319 - added quick login sliding menu into main page
319 320 - changelog uses lazy loading of affected files details, in some scenarios
320 321 this can improve speed of changelog page dramatically especially for
321 322 larger repositories.
322 323 - implements #214 added support for downloading subrepos in download menu.
323 324 - Added basic API for direct operations on rhodecode via JSON
324 325 - Implemented advanced hook management
325 326
326 327 fixes
327 328 +++++
328 329
329 330 - fixed file browser bug, when switching into given form revision the url was
330 331 not changing
331 332 - fixed propagation to error controller on simplehg and simplegit middlewares
332 333 - fixed error when trying to make a download on empty repository
333 334 - fixed problem with '[' chars in commit messages in journal
334 335 - fixed #99 Unicode errors, on file node paths with non utf-8 characters
335 336 - journal fork fixes
336 337 - removed issue with space inside renamed repository after deletion
337 338 - fixed strange issue on formencode imports
338 339 - fixed #126 Deleting repository on Windows, rename used incompatible chars.
339 340 - #150 fixes for errors on repositories mapped in db but corrupted in
340 341 filesystem
341 342 - fixed problem with ascendant characters in realm #181
342 343 - fixed problem with sqlite file based database connection pool
343 344 - whoosh indexer and code stats share the same dynamic extensions map
344 345 - fixes #188 - relationship delete of repo_to_perm entry on user removal
345 346 - fixes issue #189 Trending source files shows "show more" when no more exist
346 347 - fixes issue #197 Relative paths for pidlocks
347 348 - fixes issue #198 password will require only 3 chars now for login form
348 349 - fixes issue #199 wrong redirection for non admin users after creating a repository
349 350 - fixes issues #202, bad db constraint made impossible to attach same group
350 351 more than one time. Affects only mysql/postgres
351 352 - fixes #218 os.kill patch for windows was missing sig param
352 353 - improved rendering of dag (they are not trimmed anymore when number of
353 354 heads exceeds 5)
354 355
355 356 1.1.8 (**2011-04-12**)
356 357 ----------------------
357 358
358 359 news
359 360 ++++
360 361
361 362 - improved windows support
362 363
363 364 fixes
364 365 +++++
365 366
366 367 - fixed #140 freeze of python dateutil library, since new version is python2.x
367 368 incompatible
368 369 - setup-app will check for write permission in given path
369 370 - cleaned up license info issue #149
370 371 - fixes for issues #137,#116 and problems with unicode and accented characters.
371 372 - fixes crashes on gravatar, when passed in email as unicode
372 373 - fixed tooltip flickering problems
373 374 - fixed came_from redirection on windows
374 375 - fixed logging modules, and sql formatters
375 376 - windows fixes for os.kill issue #133
376 377 - fixes path splitting for windows issues #148
377 378 - fixed issue #143 wrong import on migration to 1.1.X
378 379 - fixed problems with displaying binary files, thanks to Thomas Waldmann
379 380 - removed name from archive files since it's breaking ui for long repo names
380 381 - fixed issue with archive headers sent to browser, thanks to Thomas Waldmann
381 382 - fixed compatibility for 1024px displays, and larger dpi settings, thanks to
382 383 Thomas Waldmann
383 384 - fixed issue #166 summary pager was skipping 10 revisions on second page
384 385
385 386
386 387 1.1.7 (**2011-03-23**)
387 388 ----------------------
388 389
389 390 news
390 391 ++++
391 392
392 393 fixes
393 394 +++++
394 395
395 396 - fixed (again) #136 installation support for FreeBSD
396 397
397 398
398 399 1.1.6 (**2011-03-21**)
399 400 ----------------------
400 401
401 402 news
402 403 ++++
403 404
404 405 fixes
405 406 +++++
406 407
407 408 - fixed #136 installation support for FreeBSD
408 409 - RhodeCode will check for python version during installation
409 410
410 411 1.1.5 (**2011-03-17**)
411 412 ----------------------
412 413
413 414 news
414 415 ++++
415 416
416 417 - basic windows support, by exchanging pybcrypt into sha256 for windows only
417 418 highly inspired by idea of mantis406
418 419
419 420 fixes
420 421 +++++
421 422
422 423 - fixed sorting by author in main page
423 424 - fixed crashes with diffs on binary files
424 425 - fixed #131 problem with boolean values for LDAP
425 426 - fixed #122 mysql problems thanks to striker69
426 427 - fixed problem with errors on calling raw/raw_files/annotate functions
427 428 with unknown revisions
428 429 - fixed returned rawfiles attachment names with international character
429 430 - cleaned out docs, big thanks to Jason Harris
430 431
431 432 1.1.4 (**2011-02-19**)
432 433 ----------------------
433 434
434 435 news
435 436 ++++
436 437
437 438 fixes
438 439 +++++
439 440
440 441 - fixed formencode import problem on settings page, that caused server crash
441 442 when that page was accessed as first after server start
442 443 - journal fixes
443 444 - fixed option to access repository just by entering http://server/<repo_name>
444 445
445 446 1.1.3 (**2011-02-16**)
446 447 ----------------------
447 448
448 449 news
449 450 ++++
450 451
451 452 - implemented #102 allowing the '.' character in username
452 453 - added option to access repository just by entering http://server/<repo_name>
453 454 - celery task ignores result for better performance
454 455
455 456 fixes
456 457 +++++
457 458
458 459 - fixed ehlo command and non auth mail servers on smtp_lib. Thanks to
459 460 apollo13 and Johan Walles
460 461 - small fixes in journal
461 462 - fixed problems with getting setting for celery from .ini files
462 463 - registration, password reset and login boxes share the same title as main
463 464 application now
464 465 - fixed #113: to high permissions to fork repository
465 466 - fixed problem with '[' chars in commit messages in journal
466 467 - removed issue with space inside renamed repository after deletion
467 468 - db transaction fixes when filesystem repository creation failed
468 469 - fixed #106 relation issues on databases different than sqlite
469 470 - fixed static files paths links to use of url() method
470 471
471 472 1.1.2 (**2011-01-12**)
472 473 ----------------------
473 474
474 475 news
475 476 ++++
476 477
477 478
478 479 fixes
479 480 +++++
480 481
481 482 - fixes #98 protection against float division of percentage stats
482 483 - fixed graph bug
483 484 - forced webhelpers version since it was making troubles during installation
484 485
485 486 1.1.1 (**2011-01-06**)
486 487 ----------------------
487 488
488 489 news
489 490 ++++
490 491
491 492 - added force https option into ini files for easier https usage (no need to
492 493 set server headers with this options)
493 494 - small css updates
494 495
495 496 fixes
496 497 +++++
497 498
498 499 - fixed #96 redirect loop on files view on repositories without changesets
499 500 - fixed #97 unicode string passed into server header in special cases (mod_wsgi)
500 501 and server crashed with errors
501 502 - fixed large tooltips problems on main page
502 503 - fixed #92 whoosh indexer is more error proof
503 504
504 505 1.1.0 (**2010-12-18**)
505 506 ----------------------
506 507
507 508 news
508 509 ++++
509 510
510 511 - rewrite of internals for vcs >=0.1.10
511 512 - uses mercurial 1.7 with dotencode disabled for maintaining compatibility
512 513 with older clients
513 514 - anonymous access, authentication via ldap
514 515 - performance upgrade for cached repos list - each repository has its own
515 516 cache that's invalidated when needed.
516 517 - performance upgrades on repositories with large amount of commits (20K+)
517 518 - main page quick filter for filtering repositories
518 519 - user dashboards with ability to follow chosen repositories actions
519 520 - sends email to admin on new user registration
520 521 - added cache/statistics reset options into repository settings
521 522 - more detailed action logger (based on hooks) with pushed changesets lists
522 523 and options to disable those hooks from admin panel
523 524 - introduced new enhanced changelog for merges that shows more accurate results
524 525 - new improved and faster code stats (based on pygments lexers mapping tables,
525 526 showing up to 10 trending sources for each repository. Additionally stats
526 527 can be disabled in repository settings.
527 528 - gui optimizations, fixed application width to 1024px
528 529 - added cut off (for large files/changesets) limit into config files
529 530 - whoosh, celeryd, upgrade moved to paster command
530 531 - other than sqlite database backends can be used
531 532
532 533 fixes
533 534 +++++
534 535
535 536 - fixes #61 forked repo was showing only after cache expired
536 537 - fixes #76 no confirmation on user deletes
537 538 - fixes #66 Name field misspelled
538 539 - fixes #72 block user removal when he owns repositories
539 540 - fixes #69 added password confirmation fields
540 541 - fixes #87 RhodeCode crashes occasionally on updating repository owner
541 542 - fixes #82 broken annotations on files with more than 1 blank line at the end
542 543 - a lot of fixes and tweaks for file browser
543 544 - fixed detached session issues
544 545 - fixed when user had no repos he would see all repos listed in my account
545 546 - fixed ui() instance bug when global hgrc settings was loaded for server
546 547 instance and all hgrc options were merged with our db ui() object
547 548 - numerous small bugfixes
548 549
549 550 (special thanks for TkSoh for detailed feedback)
550 551
551 552
552 553 1.0.2 (**2010-11-12**)
553 554 ----------------------
554 555
555 556 news
556 557 ++++
557 558
558 559 - tested under python2.7
559 560 - bumped sqlalchemy and celery versions
560 561
561 562 fixes
562 563 +++++
563 564
564 565 - fixed #59 missing graph.js
565 566 - fixed repo_size crash when repository had broken symlinks
566 567 - fixed python2.5 crashes.
567 568
568 569
569 570 1.0.1 (**2010-11-10**)
570 571 ----------------------
571 572
572 573 news
573 574 ++++
574 575
575 576 - small css updated
576 577
577 578 fixes
578 579 +++++
579 580
580 581 - fixed #53 python2.5 incompatible enumerate calls
581 582 - fixed #52 disable mercurial extension for web
582 583 - fixed #51 deleting repositories don't delete it's dependent objects
583 584
584 585
585 586 1.0.0 (**2010-11-02**)
586 587 ----------------------
587 588
588 589 - security bugfix simplehg wasn't checking for permissions on commands
589 590 other than pull or push.
590 591 - fixed doubled messages after push or pull in admin journal
591 592 - templating and css corrections, fixed repo switcher on chrome, updated titles
592 593 - admin menu accessible from options menu on repository view
593 594 - permissions cached queries
594 595
595 596 1.0.0rc4 (**2010-10-12**)
596 597 --------------------------
597 598
598 599 - fixed python2.5 missing simplejson imports (thanks to Jens BΓ€ckman)
599 600 - removed cache_manager settings from sqlalchemy meta
600 601 - added sqlalchemy cache settings to ini files
601 602 - validated password length and added second try of failure on paster setup-app
602 603 - fixed setup database destroy prompt even when there was no db
603 604
604 605
605 606 1.0.0rc3 (**2010-10-11**)
606 607 -------------------------
607 608
608 609 - fixed i18n during installation.
609 610
610 611 1.0.0rc2 (**2010-10-11**)
611 612 -------------------------
612 613
613 614 - Disabled dirsize in file browser, it's causing nasty bug when dir renames
614 615 occure. After vcs is fixed it'll be put back again.
615 616 - templating/css rewrites, optimized css. No newline at end of file
@@ -1,174 +1,180 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 rhodecode.controllers.forks
4 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 6 forks controller for rhodecode
7 7
8 8 :created_on: Apr 23, 2011
9 9 :author: marcink
10 10 :copyright: (C) 2011-2012 Marcin Kuzminski <marcin@python-works.com>
11 11 :license: GPLv3, see COPYING for more details.
12 12 """
13 13 # This program is free software: you can redistribute it and/or modify
14 14 # it under the terms of the GNU General Public License as published by
15 15 # the Free Software Foundation, either version 3 of the License, or
16 16 # (at your option) any later version.
17 17 #
18 18 # This program is distributed in the hope that it will be useful,
19 19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 21 # GNU General Public License for more details.
22 22 #
23 23 # You should have received a copy of the GNU General Public License
24 24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 25 import logging
26 26 import formencode
27 27 import traceback
28 28 from formencode import htmlfill
29 29
30 30 from pylons import tmpl_context as c, request, url
31 31 from pylons.controllers.util import redirect
32 32 from pylons.i18n.translation import _
33 33
34 34 import rhodecode.lib.helpers as h
35 35
36 36 from rhodecode.lib.helpers import Page
37 37 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator, \
38 NotAnonymous
38 NotAnonymous, HasRepoPermissionAny
39 39 from rhodecode.lib.base import BaseRepoController, render
40 40 from rhodecode.model.db import Repository, RepoGroup, UserFollowing, User
41 41 from rhodecode.model.repo import RepoModel
42 42 from rhodecode.model.forms import RepoForkForm
43 43
44 44 log = logging.getLogger(__name__)
45 45
46 46
47 47 class ForksController(BaseRepoController):
48 48
49 49 @LoginRequired()
50 50 def __before__(self):
51 51 super(ForksController, self).__before__()
52 52
53 53 def __load_defaults(self):
54 54 c.repo_groups = RepoGroup.groups_choices()
55 55 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
56 56
57 57 def __load_data(self, repo_name=None):
58 58 """
59 59 Load defaults settings for edit, and update
60 60
61 61 :param repo_name:
62 62 """
63 63 self.__load_defaults()
64 64
65 65 c.repo_info = db_repo = Repository.get_by_repo_name(repo_name)
66 66 repo = db_repo.scm_instance
67 67
68 68 if c.repo_info is None:
69 69 h.flash(_('%s repository is not mapped to db perhaps'
70 70 ' it was created or renamed from the filesystem'
71 71 ' please run the application again'
72 72 ' in order to rescan repositories') % repo_name,
73 73 category='error')
74 74
75 75 return redirect(url('repos'))
76 76
77 77 c.default_user_id = User.get_by_username('default').user_id
78 78 c.in_public_journal = UserFollowing.query()\
79 79 .filter(UserFollowing.user_id == c.default_user_id)\
80 80 .filter(UserFollowing.follows_repository == c.repo_info).scalar()
81 81
82 82 if c.repo_info.stats:
83 83 last_rev = c.repo_info.stats.stat_on_revision+1
84 84 else:
85 85 last_rev = 0
86 86 c.stats_revision = last_rev
87 87
88 88 c.repo_last_rev = repo.count() if repo.revisions else 0
89 89
90 90 if last_rev == 0 or c.repo_last_rev == 0:
91 91 c.stats_percentage = 0
92 92 else:
93 93 c.stats_percentage = '%.2f' % ((float((last_rev)) /
94 94 c.repo_last_rev) * 100)
95 95
96 96 defaults = RepoModel()._get_defaults(repo_name)
97 97 # add prefix to fork
98 98 defaults['repo_name'] = 'fork-' + defaults['repo_name']
99 99 return defaults
100 100
101 101 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
102 102 'repository.admin')
103 103 def forks(self, repo_name):
104 104 p = int(request.params.get('page', 1))
105 105 repo_id = c.rhodecode_db_repo.repo_id
106 d = Repository.get_repo_forks(repo_id)
106 d = []
107 for r in Repository.get_repo_forks(repo_id):
108 if not HasRepoPermissionAny(
109 'repository.read', 'repository.write', 'repository.admin'
110 )(r.repo_name, 'get forks check'):
111 continue
112 d.append(r)
107 113 c.forks_pager = Page(d, page=p, items_per_page=20)
108 114
109 115 c.forks_data = render('/forks/forks_data.html')
110 116
111 117 if request.environ.get('HTTP_X_PARTIAL_XHR'):
112 118 return c.forks_data
113 119
114 120 return render('/forks/forks.html')
115 121
116 122 @NotAnonymous()
117 123 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
118 124 'repository.admin')
119 125 def fork(self, repo_name):
120 126 c.repo_info = Repository.get_by_repo_name(repo_name)
121 127 if not c.repo_info:
122 128 h.flash(_('%s repository is not mapped to db perhaps'
123 129 ' it was created or renamed from the file system'
124 130 ' please run the application again'
125 131 ' in order to rescan repositories') % repo_name,
126 132 category='error')
127 133
128 134 return redirect(url('home'))
129 135
130 136 defaults = self.__load_data(repo_name)
131 137
132 138 return htmlfill.render(
133 139 render('forks/fork.html'),
134 140 defaults=defaults,
135 141 encoding="UTF-8",
136 142 force_defaults=False
137 143 )
138 144
139 145
140 146 @NotAnonymous()
141 147 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
142 148 'repository.admin')
143 149 def fork_create(self, repo_name):
144 150 self.__load_defaults()
145 151 c.repo_info = Repository.get_by_repo_name(repo_name)
146 152 _form = RepoForkForm(old_data={'repo_type': c.repo_info.repo_type},
147 153 repo_groups=c.repo_groups_choices,)()
148 154 form_result = {}
149 155 try:
150 156 form_result = _form.to_python(dict(request.POST))
151 157 # add org_path of repo so we can do a clone from it later
152 158 form_result['org_path'] = c.repo_info.repo_name
153 159
154 160 # create fork is done sometimes async on celery, db transaction
155 161 # management is handled there.
156 162 RepoModel().create_fork(form_result, self.rhodecode_user)
157 163 h.flash(_('forked %s repository as %s') \
158 164 % (repo_name, form_result['repo_name']),
159 165 category='success')
160 166 except formencode.Invalid, errors:
161 167 c.new_repo = errors.value['repo_name']
162 168
163 169 return htmlfill.render(
164 170 render('forks/fork.html'),
165 171 defaults=errors.value,
166 172 errors=errors.error_dict or {},
167 173 prefix_error=False,
168 174 encoding="UTF-8")
169 175 except Exception:
170 176 log.error(traceback.format_exc())
171 177 h.flash(_('An error occurred during repository forking %s') %
172 178 repo_name, category='error')
173 179
174 180 return redirect(url('home'))
@@ -1,86 +1,133 b''
1 1 from rhodecode.tests import *
2 2
3 3 from rhodecode.model.db import Repository
4 from rhodecode.model.repo import RepoModel
5 from rhodecode.model.user import UserModel
6
4 7
5 8 class TestForksController(TestController):
6 9
10 def setUp(self):
11 self.username = u'forkuser'
12 self.password = u'qweqwe'
13 self.u1 = UserModel().create_or_update(
14 username=self.username, password=self.password,
15 email=u'fork_king@rhodecode.org', name=u'u1', lastname=u'u1'
16 )
17 self.Session.commit()
18
19 def tearDown(self):
20 self.Session.delete(self.u1)
21 self.Session.commit()
22
7 23 def test_index(self):
8 24 self.log_user()
9 25 repo_name = HG_REPO
10 26 response = self.app.get(url(controller='forks', action='forks',
11 27 repo_name=repo_name))
12 28
13 29 self.assertTrue("""There are no forks yet""" in response.body)
14 30
15
16 31 def test_index_with_fork(self):
17 32 self.log_user()
18 33
19 34 # create a fork
20 35 fork_name = HG_FORK
21 36 description = 'fork of vcs test'
22 37 repo_name = HG_REPO
23 38 org_repo = Repository.get_by_repo_name(repo_name)
24 39 response = self.app.post(url(controller='forks',
25 40 action='fork_create',
26 41 repo_name=repo_name),
27 42 {'repo_name':fork_name,
28 43 'repo_group':'',
29 44 'fork_parent_id':org_repo.repo_id,
30 45 'repo_type':'hg',
31 46 'description':description,
32 47 'private':'False'})
33 48
34 49 response = self.app.get(url(controller='forks', action='forks',
35 50 repo_name=repo_name))
36 51
37
38 52 self.assertTrue("""<a href="/%s/summary">"""
39 53 """vcs_test_hg_fork</a>""" % fork_name
40 54 in response.body)
41 55
42 56 #remove this fork
43 57 response = self.app.delete(url('repo', repo_name=fork_name))
44 58
45
46
47
48 59 def test_z_fork_create(self):
49 60 self.log_user()
50 61 fork_name = HG_FORK
51 62 description = 'fork of vcs test'
52 63 repo_name = HG_REPO
53 64 org_repo = Repository.get_by_repo_name(repo_name)
54 65 response = self.app.post(url(controller='forks', action='fork_create',
55 66 repo_name=repo_name),
56 67 {'repo_name':fork_name,
57 68 'repo_group':'',
58 69 'fork_parent_id':org_repo.repo_id,
59 70 'repo_type':'hg',
60 71 'description':description,
61 72 'private':'False'})
62 73
63 74 #test if we have a message that fork is ok
64 75 self.assertTrue('forked %s repository as %s' \
65 76 % (repo_name, fork_name) in response.session['flash'][0])
66 77
67 78 #test if the fork was created in the database
68 79 fork_repo = self.Session.query(Repository)\
69 80 .filter(Repository.repo_name == fork_name).one()
70 81
71 82 self.assertEqual(fork_repo.repo_name, fork_name)
72 83 self.assertEqual(fork_repo.fork.repo_name, repo_name)
73 84
74
75 85 #test if fork is visible in the list ?
76 86 response = response.follow()
77 87
78
79 88 # check if fork is marked as fork
80 89 # wait for cache to expire
81 90 import time
82 91 time.sleep(10)
83 92 response = self.app.get(url(controller='summary', action='index',
84 93 repo_name=fork_name))
85 94
86 95 self.assertTrue('Fork of %s' % repo_name in response.body)
96
97 def test_zz_fork_permission_page(self):
98 usr = self.log_user(self.username, self.password)['user_id']
99 repo_name = HG_REPO
100
101 forks = self.Session.query(Repository)\
102 .filter(Repository.fork_id != None)\
103 .all()
104 self.assertEqual(1, len(forks))
105
106 # set read permissions for this
107 RepoModel().grant_user_permission(repo=forks[0],
108 user=usr,
109 perm='repository.read')
110 self.Session.commit()
111
112 response = self.app.get(url(controller='forks', action='forks',
113 repo_name=repo_name))
114
115 response.mustcontain('<div style="padding:5px 3px 3px 42px;">fork of vcs test</div>')
116
117 def test_zzz_fork_permission_page(self):
118 usr = self.log_user(self.username, self.password)['user_id']
119 repo_name = HG_REPO
120
121 forks = self.Session.query(Repository)\
122 .filter(Repository.fork_id != None)\
123 .all()
124 self.assertEqual(1, len(forks))
125
126 # set none
127 RepoModel().grant_user_permission(repo=forks[0],
128 user=usr, perm='repository.none')
129 self.Session.commit()
130 # fork shouldn't be there
131 response = self.app.get(url(controller='forks', action='forks',
132 repo_name=repo_name))
133 response.mustcontain('There are no forks yet')
General Comments 0
You need to be logged in to leave comments. Login now