Compare commits

..
159 Commits
Author SHA1 Message Date
Jean-Philippe Lang fd7354ac06 Updates for 1.4.7 release.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@11237 e93f8b46-1217-0410-a6f0-8f06a7374b81
2013-01-20 18:20:19 +00:00
Toshi MARUYAMA 5c077abb0e 1.4-stable: add a link to a mail posted on 14 Jan 2013 about Rails 2.3 CVE-2013-0155
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@11208 e93f8b46-1217-0410-a6f0-8f06a7374b81
2013-01-20 11:48:54 +00:00
Toshi MARUYAMA a1614e5e53 1.4-stable: add the patch for CVE-2013-0155 in Rails 2.3.15
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@11197 e93f8b46-1217-0410-a6f0-8f06a7374b81
2013-01-17 00:36:07 +00:00
Jean-Philippe Lang 284ee1080b Removed Rails patch.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@11154 e93f8b46-1217-0410-a6f0-8f06a7374b81
2013-01-09 15:18:37 +00:00
Jean-Philippe Lang 190fc8d9db Changes for 1.4.6 release.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@11149 e93f8b46-1217-0410-a6f0-8f06a7374b81
2013-01-09 13:43:38 +00:00
Jean-Philippe Lang cf5e29a83b Upgrade to Rails 2.3.15.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@11148 e93f8b46-1217-0410-a6f0-8f06a7374b81
2013-01-09 13:42:30 +00:00
Toshi MARUYAMA 2acfd0847c Merged r11051 from trunk to 1.4-stable (#12630)
Russian "x_hours" translation updated by Mikhail Velkin.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@11055 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-12-19 00:05:11 +00:00
Toshi MARUYAMA 2f2f360311 Merged r11035 from trunk to 1.4-stable (#12615)
Russian translation updated by Kirill Bezrukov.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@11039 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-12-17 23:54:47 +00:00
Toshi MARUYAMA 29b64fce8e Merged r11022 from trunk to 1.4-stable (#12614)
Dutch translation updated.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@11025 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-12-17 12:45:09 +00:00
Toshi MARUYAMA 759a3321f4 Merged r11014 from trunk to 1.4-stable (#12605)
Norwegian translation for 1.4-stable updated by Ketil Mehl.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@11020 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-12-16 07:42:04 +00:00
Jean-Philippe Lang b5c0a3313b Reverts r10896 (#12472).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10899 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-11-30 10:26:02 +00:00
Jean-Philippe Lang ca73f99056 Reverts r10896 (#12472).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10898 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-11-30 10:25:48 +00:00
Jean-Philippe Lang 8312fec63f Merged r10893 into 1.4-stable (#12472).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10896 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-11-30 08:59:57 +00:00
Toshi MARUYAMA 68c2588f85 Merged r10862 from trunk to 1.4-stable (#12409)
scm: git: change extra_report_last_commit type at unit test to string.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10864 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-11-22 01:18:23 +00:00
Toshi MARUYAMA 31e714f2db Merged r10856 and r10857 from trunk to 1.4-stable (#12409)
scm: git: fix changesets aren't read after clear_changesets call.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10859 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-11-21 09:59:22 +00:00
Toshi MARUYAMA 886d6f006b Merged r10840 from trunk to 1.4-stable
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10849 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-11-18 22:47:32 +00:00
Jean-Philippe Lang 628e63eefe Updates for 1.4.5 release.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10834 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-11-17 13:24:56 +00:00
Toshi MARUYAMA 83b356484a Merged r10709 from trunk to 1.4-stable (#12196)
fix "Page not found" on OK button in SCM "View all revisions" page.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10711 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-10-24 10:33:15 +00:00
Toshi MARUYAMA 5210b58226 Merged r10702 from trunk to 1.4-stable (#12189)
add tmp/pdf directory.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10704 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-10-23 11:01:49 +00:00
Toshi MARUYAMA a0932173a5 Merged r10689 from trunk to 1.4-stable
Partial backout r10263.

Backout replacing shoulda context of test/unit/helpers/issues_helper_test.rb.
Test methods in shoulda context do not run on Ruby 1.8.7-p370.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10693 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-10-22 03:29:14 +00:00
Toshi MARUYAMA e889fe9c8a Merged r10688 from trunk to 1.4-stable
Backout r10253.

Backout replacing shoulda context of test/unit/helpers/issues_helper_test.rb.
Test methods in shoulda context do not run on Ruby 1.8.7-p370.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10692 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-10-22 03:28:44 +00:00
Toshi MARUYAMA 16b1fcb079 Merged r10596 from trunk to 1.4-stable (#9732)
German translation updated by Raphael Kallensee.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10601 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-10-11 03:55:38 +00:00
Toshi MARUYAMA 3b7793561a Merged r10572 from trunk
add missing fixtures to test/unit/issue_relation_test.rb

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10579 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-10-09 11:58:27 +00:00
Toshi MARUYAMA 2c3c1d2a02 Merged r10571 from trunk
add missing fixture to test/integration/api_test/issues_test.rb

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10578 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-10-09 11:58:13 +00:00
Toshi MARUYAMA 49cb3aaca6 Merged r10503 from trunk to 1.4-stable (#11966)
add functional test of sub repository diff path.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10508 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-28 04:48:01 +00:00
Toshi MARUYAMA 8a8df72937 Merged r10502 from trunk to 1.4-stable (#11966)
add functional test of main repository diff path.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10507 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-28 04:47:46 +00:00
Toshi MARUYAMA ad238abd0c Merged r10490 from trunk to 1.4-stable (#11966)
explicitly define route at scm diff view.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10506 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-28 04:47:26 +00:00
Toshi MARUYAMA d69cae859f Merged r10501 from trunk
set user preference diff type nil at functional tests.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10504 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-28 03:51:33 +00:00
Toshi MARUYAMA 59d4d210a7 Merged r10498 from trunk
scm: git: use with_settings instead of assigned setting at functional test

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10500 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-28 00:19:09 +00:00
Toshi MARUYAMA 633b86236c Merged r10477 from trunk
set default_language en at test_commit_closing_a_subproject_issue of unit changeset test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10483 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-26 12:05:51 +00:00
Toshi MARUYAMA 91514dd682 add tests that i18n currency options are nil to 1.4-stable Rails2 (#11922)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10475 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-26 08:12:04 +00:00
Jean-Philippe Lang 917127f179 Updated 1.4 CHANGELOG.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10300 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-06 17:25:29 +00:00
Jean-Philippe Lang 49295481de Add namespace to Time (#11298).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10299 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-06 17:23:57 +00:00
Jean-Philippe Lang 8cc56cce66 Merged r10294 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10297 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-06 17:21:09 +00:00
Jean-Philippe Lang 8d5fadc773 Updated 1.4 CHANGELOG.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10296 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-06 17:19:27 +00:00
Jean-Philippe Lang eb3e79b70d Merged r10148 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10295 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-06 17:07:49 +00:00
Toshi MARUYAMA 5d3bdb66cd Merged r10253, r10257, r10263 and r10264 from trunk to 1.4-stable
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10266 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-01 07:22:52 +00:00
Toshi MARUYAMA 1974123562 Merged r10255 from trunk to 1.4-stable
add missing fixture to test/unit/lib/redmine/safe_attributes_test.rb.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10262 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-01 05:09:12 +00:00
Toshi MARUYAMA bcef197b41 Merged r10256 from trunk to 1.4-stable
add missing fixtures to test/unit/lib/redmine/hook_test.rb.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10261 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-01 05:08:57 +00:00
Toshi MARUYAMA 231145160f Merged r10249 from trunk to 1.4-stable
set language en to test_label_for at test/unit/query_test.rb.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10260 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-01 05:08:42 +00:00
Toshi MARUYAMA 0e1ae572c7 Merged r10252 from trunk to 1.4-stable (#11752)
scm: git: use with_settings at test_diff_truncated of functional test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10259 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-01 05:08:22 +00:00
Toshi MARUYAMA b3a86771ce Merged r10251 from trunk to 1.4-stable (#11752)
scm: git: use diff_max_lines_displayed setting at test_diff_with_rev_and_path of functional test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10258 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-01 05:08:06 +00:00
Toshi MARUYAMA 2516d4f408 Merged r9949 from trunk to 1.4-stable
Tests should not change settings.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10250 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-09-01 02:16:07 +00:00
Toshi MARUYAMA 03d6c4668e Merged r10245 from trunk to 1.4-stable (#11752)
scm: git: add functional test of diff with revision and path.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10248 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-31 23:55:56 +00:00
Toshi MARUYAMA a97d6baddd Merged r10230 from trunk (#11665)
add check default document category is not defined on database in tests.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10233 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-22 22:44:30 +00:00
Toshi MARUYAMA f3a8494cfb Merged r10219 from trunk to 1.4-stable (#11665)
add functional test to create non default document category.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10227 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-21 17:16:28 +00:00
Toshi MARUYAMA 14dcefaa97 set default category_id instead of the object (#11665)
Rails 2.3 still has issues with synchronizing the association_id
and association attributes of an object. That means, if you set the
association with an object first and then just set the id afterwards,
the object wins and the setting of the id gets lost.

This is not an issue in Rails >= 3.1 anymore.

Contributed by Holger Just.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10226 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-21 17:15:59 +00:00
Toshi MARUYAMA f4a7d6ca8c Merged r10221 from trunk to 1.4-stable (#11665)
force set default document category if it is not set on database.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10225 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-21 17:15:38 +00:00
Toshi MARUYAMA aedd5c5e35 Merged r10220 from trunk to 1.4-stable (#11665)
add unit test to get default document category defined on database.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10224 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-21 17:15:16 +00:00
Toshi MARUYAMA 554d6bcba2 Merged r10222 from trunk to 1.4-stable (#11665)
add position to DocumentCategory in enumerations fixture.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10223 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-21 17:14:53 +00:00
Toshi MARUYAMA 4fcec69a40 Merged r10216 from trunk
add missing fixtures to test/functional/documents_controller_test.rb

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10218 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-21 04:53:10 +00:00
Toshi MARUYAMA 7e6cc2f583 Merged r10213 from trunk
add missing fixtures to test/unit/document_test.rb

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10215 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-21 02:25:58 +00:00
Toshi MARUYAMA 16383ed386 Merged r10169 from trunk to 1.4-stable (#11600)
fix plural form of the abbreviation for hours in Brazilian Portuguese.

Contributed by Mauricio Piacentini.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10173 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-08 01:39:09 +00:00
Toshi MARUYAMA 27127e1a3b Merged r10167 from trunk to 1.4-stable
Gemfile: mocha version up 0.12.3.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10172 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-08 01:38:54 +00:00
Toshi MARUYAMA a92ef237d3 Merged r10155 from trunk to 1.4-stable
Gemfile: pin mocha version 0.12.1.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10168 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-08-07 23:21:45 +00:00
Toshi MARUYAMA a82a16378f Merged r10137 from trunk to 1.4-stable (#10320, #10818)
Gemfile: prevent "rake db:migrate RAILS_ENV=test" causes exception on Ruby 1.9.3.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10139 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-07-31 08:47:21 +00:00
Toshi MARUYAMA 886daba641 Merged r10055 from trunk to 1.4-stable (#11448)
Russian translation for 1.4-stable and 2.0-stable updated by Александр Закревский.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10057 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-07-20 10:12:18 +00:00
Toshi MARUYAMA ab8dd5aa6e Backported r10005 from trunk to 1.4-stable (#11406, #11404)
German translation for configurable session lifetime and timeout updated by Hannes Meier.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10008 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-07-16 14:17:35 +00:00
Jean-Philippe Lang dbc02e66dc Backported r9982 and r9984 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10000 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-07-15 16:00:58 +00:00
Jean-Philippe Lang 75e350f4e6 Merged r9924 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9960 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-07-08 12:38:57 +00:00
Jean-Philippe Lang 81553d396e Merged r9908 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9955 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-07-08 12:32:38 +00:00
Jean-Philippe Lang 77e03b508b Merged r9875 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9951 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-07-08 12:26:49 +00:00
Toshi MARUYAMA 1b0e717902 Merged r9911 from trunk to 1.4-stable (#11328)
Fix Japanese mistranslation for 'label_language_based'.

Contributed by Go MAEDA.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9918 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-07-05 13:10:27 +00:00
Toshi MARUYAMA 53b8de5e39 Backport r9890 from trunk to 1.4-stable
Simplified Chinese translation updated by Steven Wong (#11261).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9893 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-26 11:44:38 +00:00
Toshi MARUYAMA 34df573ec2 Merge r9870 from trunk
scm: git: fix unable to run unit lib test if git binary is not available on Windows.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9874 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-19 02:12:59 +00:00
Jean-Philippe Lang e2f00792a8 Updates for 1.4.4 release.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9866 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-18 18:46:53 +00:00
Jean-Philippe Lang 9ed998af9b Merged r9861 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9863 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-18 18:35:50 +00:00
Jean-Philippe Lang 1881706df4 Backported r9858 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9860 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-18 18:29:15 +00:00
Toshi MARUYAMA a3bf12ab9f Backport r9856 from trunk (#11186)
Traditional Chinese translation updated by ChunChang Lo.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9857 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-18 03:49:29 +00:00
Toshi MARUYAMA 668981b8cd Merged r9853 from trunk (#10688)
fix PDF export tables problems.

Contributed by Jun NAITOH.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9855 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-17 13:23:57 +00:00
Toshi MARUYAMA b303dddbe3 Merge r9750 from trunk
scm: git: skip Latin-1 path tests on Git for Windows above 1.7.10

Git for Windows (msysGit) changed internal API from ANSI to Unicode in 1.7.10.
http://code.google.com/p/msysgit/issues/detail?id=80

So, Latin-1 path tests fail on Japanese Windows.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9852 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-17 10:53:30 +00:00
Jean-Philippe Lang 933e96116e Fix for Rails vulnerabilities CVE-2012-2694 and CVE-2012-2695.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9849 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-17 09:21:16 +00:00
Jean-Philippe Lang 10711fda6d Merged r9837 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9847 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-17 09:01:17 +00:00
Jean-Philippe Lang b3b829c025 Merged r9831 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9844 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-17 08:57:15 +00:00
Jean-Philippe Lang 8cd0baf773 Merged r9822 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9842 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-17 08:54:12 +00:00
Jean-Philippe Lang 033aa68427 CHANGELOG updated.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9841 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-17 08:52:59 +00:00
Etienne Massip 1eb20d42bd Merged r9832 fro trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9833 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-14 21:09:00 +00:00
Toshi MARUYAMA a9dbecd5a5 Backported r9817 from trunk (#11130)
Simplified Chinese translation updated.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9821 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-11 07:30:25 +00:00
Toshi MARUYAMA a13218e9f4 Backported r9816 from trunk (#11129)
Bulgarian translation updated by Ivan Cenov.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9820 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-11 07:30:00 +00:00
Toshi MARUYAMA 57b0faf128 Backported r9815 from trunk (#11128)
Japanese translation updated by Go MAEDA.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9819 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-11 07:29:31 +00:00
Jean-Philippe Lang ba3828b49f Backported r9797 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9810 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-10 20:30:58 +00:00
Jean-Philippe Lang fe1a152e02 Merged r9798 to r9801 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9803 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-10 13:40:02 +00:00
Jean-Philippe Lang 69709a2513 CHANGELOG update.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9791 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-09 13:54:33 +00:00
Jean-Philippe Lang 7b7bca0b59 Merged r9783 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9790 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-09 13:53:37 +00:00
Toshi MARUYAMA 64b0cb336d Merged r9777 from trunk (#11113)
fix German "field_multiple" translation glitch by Andreas Deininger.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9779 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-08 07:50:40 +00:00
Toshi MARUYAMA 79b7b32980 1.4-stable: scm: git: backport creating and updating test from trunk r9616 (#10830)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9775 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-06 23:08:29 +00:00
Jean-Philippe Lang 1e1517e6ab Updates for 1.4.3 release.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9772 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-05 17:21:42 +00:00
Jean-Philippe Lang 70b0d5722b Rails CVE-2012-2660.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9767 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-03 20:08:23 +00:00
Jean-Philippe Lang 3883d5e2db Merged r9755 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9757 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-03 08:50:53 +00:00
Jean-Philippe Lang bca6c447cb Merged r9740 and r9741 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9754 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-03 08:13:58 +00:00
Jean-Philippe Lang b230429a61 Merged r9742 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9752 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-06-03 08:07:37 +00:00
Jean-Philippe Lang a06462548c Updates for 1.4.2 release.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9692 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-13 19:09:35 +00:00
Jean-Philippe Lang e62a40a719 Merged r9689 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9690 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-13 11:27:09 +00:00
Jean-Philippe Lang 5a1be1d8df Backported r9687 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9688 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-13 10:47:10 +00:00
Jean-Philippe Lang 81c207b193 Restored rescue statement removed in r9684.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9685 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-13 09:46:36 +00:00
Jean-Philippe Lang 60cdcd5522 Redirect to referer when deleting a user (#10865).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9684 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-13 09:17:56 +00:00
Jean-Philippe Lang da293fdfd8 Merged #10837.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9676 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-12 12:59:23 +00:00
Jean-Philippe Lang 9cfb7e1c87 Merged r9671 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9672 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-12 12:42:30 +00:00
Toshi MARUYAMA 78c185abde set svn:eol-style native to Albanian translation files (#10875)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9669 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-11 05:33:07 +00:00
Toshi MARUYAMA 3266265cad Merged r9666 from trunk (#10875)
Albanian translation added by Dimitri Toslluku.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9668 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-11 05:30:30 +00:00
Jean-Philippe Lang d9304e062a Fixed ActionController::TestUploadedFile#respond_to? for failing tests.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9656 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-08 11:18:31 +00:00
Jean-Philippe Lang 40af0a2cbf Merged r9654 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9655 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-08 11:05:37 +00:00
Jean-Philippe Lang eb53d600c9 Fixed that REST Uploads fail with fastcgi in 1.4-stable (#10832).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9653 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-08 10:39:42 +00:00
Jean-Philippe Lang fa4fdf91a4 Do not trigger model validations when rebuilding the nested set (#10829).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9631 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-05 09:37:12 +00:00
Jean-Philippe Lang e9ac98b249 Merged r9619 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9620 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-04 16:58:08 +00:00
Jean-Philippe Lang 9db20cd02c Merged r9551 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9607 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-01 16:14:07 +00:00
Jean-Philippe Lang b0951bff54 Merged r9582 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9606 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-01 16:13:00 +00:00
Jean-Philippe Lang 0a09984954 Merged r9553 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9593 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-30 18:50:05 +00:00
Toshi MARUYAMA 9b7105465e Merged r9591 from trunk (#10800)
Simplified Chinese translation updated.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9592 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-30 13:15:07 +00:00
Toshi MARUYAMA 45683d9c2a route: add revision requirement to repository raw action lost in 1.4-stable
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9545 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-27 15:41:07 +00:00
Toshi MARUYAMA dcba6f0400 Merged r9543 from trunk (#10785)
Bulgarian translation (jstoolbar) updated by Ivan Cenov.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9544 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-27 11:49:39 +00:00
Toshi MARUYAMA f11e9eb2d6 Merged r9523 from trunk (#10750)
Swedish translation updated by Nicklas Holm.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9524 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-24 09:49:07 +00:00
Toshi MARUYAMA 095d99cf9e Merged r9520 from trunk (#10745)
Japanese translation updated by Go MAEDA.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9521 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-24 07:33:17 +00:00
Toshi MARUYAMA 163ac957ba Merged r9509 from trunk (#10733)
Traditional Chinese translation updated by ChunChang Lo.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9512 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-23 08:38:28 +00:00
Jean-Philippe Lang 04a8a72491 Updates for 1.4.1 release.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9460 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-20 10:00:24 +00:00
Toshi MARUYAMA a1a6dcffca Merged r9444 from trunk (#10664)
Updated ru and uk locales.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9458 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-20 08:33:46 +00:00
Jean-Philippe Lang d31402734b Merged r9424, r9426, r9433 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9457 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-20 08:11:01 +00:00
Jean-Philippe Lang 5180ca0cdd Merged r9421 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9456 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-20 08:09:20 +00:00
Jean-Philippe Lang e5802895ce Merged r9417 from trunk (#10664).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9455 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-20 07:45:33 +00:00
Jean-Philippe Lang da1a3449ce Merged r9449 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9454 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-20 06:14:32 +00:00
Jean-Philippe Lang 2b2f721ef4 Merged r9452 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9453 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-20 06:13:37 +00:00
Jean-Philippe Lang 62114336cf Merged r9450 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9451 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-19 09:23:27 +00:00
Jean-Philippe Lang 4f48d1b4dd Merged r9442 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9443 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-19 07:19:30 +00:00
Jean-Philippe Lang d6d064f875 Merged r9420 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9436 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-18 17:42:50 +00:00
Jean-Philippe Lang 6d8649b9d3 Merged r9419 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9435 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-18 17:42:09 +00:00
Jean-Philippe Lang 39deb03855 Merged r9430 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9434 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-18 17:41:28 +00:00
Jean-Philippe Lang 70036a7ad0 Merged r9431 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9432 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-18 12:05:35 +00:00
Toshi MARUYAMA 68d421b978 Merged r9427 from trunk
German translation changed by Hannes Meier (#10693)

* mail_body_account_information_external
* label_overall_activity
* label_send_information

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9429 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-18 00:16:11 +00:00
Toshi MARUYAMA 268a9db47e Merged r9425 from trunk
German translation for 1.4.0 updated by Hannes Meier (#10693)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9428 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-18 00:15:33 +00:00
Jean-Philippe Lang a35b81b9fa Merged r9412 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9413 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 08:08:22 +00:00
Jean-Philippe Lang fd450fd2da Merged r9404, r9405 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9411 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 06:54:02 +00:00
Jean-Philippe Lang 2c0ba78f70 Merged r9409 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9410 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 06:53:10 +00:00
Jean-Philippe Lang f0f01d370e Merged r9406 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9408 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 06:32:18 +00:00
Jean-Philippe Lang 4c330a1241 Merged r9391 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9403 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 04:58:46 +00:00
Jean-Philippe Lang baa4ebd05f Merged r9389 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9402 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 04:57:13 +00:00
Jean-Philippe Lang 59f14478ed Merged r9387 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9401 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 04:53:47 +00:00
Jean-Philippe Lang 8fefb7c05b Merged r9390 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9400 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 04:52:49 +00:00
Jean-Philippe Lang 1feb373c89 Merged r9378 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9399 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 04:51:49 +00:00
Jean-Philippe Lang 32fd503cbb Merged r9381 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9398 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 04:50:58 +00:00
Jean-Philippe Lang cf31aeaf81 Merged r9380 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9397 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 04:45:44 +00:00
Jean-Philippe Lang 83ea66fd2c Merged r9379 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9395 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-14 04:43:41 +00:00
Jean-Philippe Lang ef2c5cab2d Merged r9392 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9393 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-13 19:41:05 +00:00
Etienne Massip dee6f6b138 Merged r9374 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9388 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-11 18:31:32 +00:00
Jean-Philippe Lang a4c0c18e3d Merged r9384, r9385 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9386 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-11 17:27:44 +00:00
Jean-Philippe Lang 4c82fbb6f8 Merged r9382 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9383 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-11 17:21:35 +00:00
Jean-Philippe Lang 68ded50edc Merged r9372 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9377 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-09 06:28:04 +00:00
Jean-Philippe Lang 72ecb80dc7 Merged r9358 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9376 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-09 06:27:07 +00:00
Jean-Philippe Lang 86ee285eb4 Merged r9367 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9375 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-09 06:22:31 +00:00
Jean-Philippe Lang c229ea6386 Merged r9371 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9373 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-08 21:01:20 +00:00
Jean-Philippe Lang 687fca170e Merged r9359 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9360 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-06 13:51:55 +00:00
Toshi MARUYAMA 26564b06f7 Merged r9355 from trunk
remove 1.3-stable merged issues from CHANGELOG 1.4.0 list

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9356 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-06 13:01:12 +00:00
Jean-Philippe Lang 34016c38bd Merged r9349 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9354 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-06 12:39:51 +00:00
Jean-Philippe Lang 15ff361894 Merged r9350 and r9351 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9352 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-06 12:23:07 +00:00
Jean-Philippe Lang b45b5f4322 Merged r9346 and r9347 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9348 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-06 11:17:31 +00:00
Toshi MARUYAMA 8addbc537a Merged r9343 from trunk
Simplified Chinese translation updated by fangzheng (#10611)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9344 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-06 10:45:24 +00:00
Jean-Philippe Lang 87eeacba80 Merged r9341 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9342 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-06 10:27:22 +00:00
Jean-Philippe Lang a7250c41e2 Merged r9339 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9340 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-06 10:25:03 +00:00
Jean-Philippe Lang 7c45396d92 Set version to stable.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9338 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-06 09:45:43 +00:00
Jean-Philippe Lang c1f98c835c Adds 1.4-stable branch.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9337 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-04-06 09:41:15 +00:00
1397 changed files with 33731 additions and 28281 deletions
-2
View File
@@ -5,7 +5,6 @@
/config/database.yml /config/database.yml
/config/email.yml /config/email.yml
/config/initializers/session_store.rb /config/initializers/session_store.rb
/config/initializers/secret_token.rb
/coverage /coverage
/db/*.db /db/*.db
/db/*.sqlite3 /db/*.sqlite3
@@ -23,7 +22,6 @@
/tmp/sessions/* /tmp/sessions/*
/tmp/sockets/* /tmp/sockets/*
/tmp/test/* /tmp/test/*
/tmp/thumbnails/*
/vendor/cache /vendor/cache
/vendor/rails /vendor/rails
*.rbc *.rbc
-2
View File
@@ -7,7 +7,6 @@ config/configuration.yml
config/database.yml config/database.yml
config/email.yml config/email.yml
config/initializers/session_store.rb config/initializers/session_store.rb
config/initializers/secret_token.rb
coverage coverage
db/*.db db/*.db
db/*.sqlite3 db/*.sqlite3
@@ -25,7 +24,6 @@ tmp/pdf/*
tmp/sessions/* tmp/sessions/*
tmp/sockets/* tmp/sockets/*
tmp/test/* tmp/test/*
tmp/thumbnails/*
vendor/cache vendor/cache
vendor/rails vendor/rails
*.rbc *.rbc
+10 -15
View File
@@ -1,11 +1,10 @@
source 'http://rubygems.org' source :rubygems
gem 'rails', '3.2.12' gem "rails", "2.3.15"
gem "jquery-rails", "~> 2.0.2" gem "i18n", "~> 0.4.2"
gem "i18n", "~> 0.6.0"
gem "coderay", "~> 1.0.6" gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0" gem "tzinfo", "~> 0.3.31"
# Optional gem for LDAP authentication # Optional gem for LDAP authentication
group :ldap do group :ldap do
@@ -15,7 +14,6 @@ end
# Optional gem for OpenID authentication # Optional gem for OpenID authentication
group :openid do group :openid do
gem "ruby-openid", "~> 2.1.4", :require => "openid" gem "ruby-openid", "~> 2.1.4", :require => "openid"
gem "rack-openid"
end end
# Optional gem for exporting the gantt to a PNG file, not supported with jruby # Optional gem for exporting the gantt to a PNG file, not supported with jruby
@@ -47,7 +45,7 @@ end
platforms :mri_19, :mingw_19 do platforms :mri_19, :mingw_19 do
group :mysql do group :mysql do
gem "mysql2", "~> 0.3.11" gem "mysql2", "~> 0.2.7"
end end
end end
@@ -69,16 +67,13 @@ end
group :development do group :development do
gem "rdoc", ">= 2.4.2" gem "rdoc", ">= 2.4.2"
gem "yard"
end end
group :test do group :test do
gem "shoulda", "~> 2.11" gem "shoulda", "~> 2.10.3"
# Shoulda does not work nice on Ruby 1.9.3 and JRuby 1.7. # Shoulda does not work nice on Ruby 1.9.3 and seems to need test-unit explicitely.
# It seems to need test-unit explicitely. gem "test-unit", :platforms => [:mri_19]
platforms = [:mri_19] gem "edavis10-object_daddy", :require => "object_daddy"
platforms << :jruby if defined?(JRUBY_VERSION) && JRUBY_VERSION >= "1.7"
gem "test-unit", :platforms => platforms
gem "mocha", "0.12.3" gem "mocha", "0.12.3"
end end
@@ -89,7 +84,7 @@ if File.exists?(local_gemfile)
end end
# Load plugins' Gemfiles # Load plugins' Gemfiles
Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file| Dir.glob File.expand_path("../vendor/plugins/*/Gemfile", __FILE__) do |file|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v` puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
instance_eval File.read(file) instance_eval File.read(file)
end end
+12 -4
View File
@@ -1,7 +1,15 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__) require(File.join(File.dirname(__FILE__), 'config', 'boot'))
RedmineApp::Application.load_tasks require 'rake'
require 'rake/testtask'
begin
require 'rdoc/task'
rescue LoadError
# RDoc is not available
end
require 'tasks/rails'
+20 -37
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -40,26 +40,19 @@ class AccountController < ApplicationController
redirect_to home_url redirect_to home_url
end end
# Lets user choose a new password # Enable user to choose a new password
def lost_password def lost_password
redirect_to(home_url) && return unless Setting.lost_password? redirect_to(home_url) && return unless Setting.lost_password?
if params[:token] if params[:token]
@token = Token.find_by_action_and_value("recovery", params[:token].to_s) @token = Token.find_by_action_and_value("recovery", params[:token])
if @token.nil? || @token.expired? redirect_to(home_url) && return unless @token and !@token.expired?
redirect_to home_url
return
end
@user = @token.user @user = @token.user
unless @user && @user.active?
redirect_to home_url
return
end
if request.post? if request.post?
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
if @user.save if @user.save
@token.destroy @token.destroy
flash[:notice] = l(:notice_account_password_updated) flash[:notice] = l(:notice_account_password_updated)
redirect_to signin_path redirect_to :action => 'login'
return return
end end
end end
@@ -67,23 +60,17 @@ class AccountController < ApplicationController
return return
else else
if request.post? if request.post?
user = User.find_by_mail(params[:mail].to_s) user = User.find_by_mail(params[:mail])
# user not found or not active # user not found in db
unless user && user.active? (flash.now[:error] = l(:notice_account_unknown_email); return) unless user
flash.now[:error] = l(:notice_account_unknown_email) # user uses an external authentification
return (flash.now[:error] = l(:notice_can_t_change_password); return) if user.auth_source_id
end
# user cannot change its password
unless user.change_password_allowed?
flash.now[:error] = l(:notice_can_t_change_password)
return
end
# create a new token for password recovery # create a new token for password recovery
token = Token.new(:user => user, :action => "recovery") token = Token.new(:user => user, :action => "recovery")
if token.save if token.save
Mailer.lost_password(token).deliver Mailer.deliver_lost_password(token)
flash[:notice] = l(:notice_account_lost_email_sent) flash[:notice] = l(:notice_account_lost_email_sent)
redirect_to signin_path redirect_to :action => 'login'
return return
end end
end end
@@ -97,9 +84,8 @@ class AccountController < ApplicationController
session[:auth_source_registration] = nil session[:auth_source_registration] = nil
@user = User.new(:language => Setting.default_language) @user = User.new(:language => Setting.default_language)
else else
user_params = params[:user] || {}
@user = User.new @user = User.new
@user.safe_attributes = user_params @user.safe_attributes = params[:user]
@user.admin = false @user.admin = false
@user.register @user.register
if session[:auth_source_registration] if session[:auth_source_registration]
@@ -114,9 +100,7 @@ class AccountController < ApplicationController
end end
else else
@user.login = params[:user][:login] @user.login = params[:user][:login]
unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank? @user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation]
@user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation]
end
case Setting.self_registration case Setting.self_registration
when '1' when '1'
@@ -142,7 +126,7 @@ class AccountController < ApplicationController
token.destroy token.destroy
flash[:notice] = l(:notice_account_activated) flash[:notice] = l(:notice_account_activated)
end end
redirect_to signin_path redirect_to :action => 'login'
end end
private private
@@ -169,7 +153,7 @@ class AccountController < ApplicationController
end end
def open_id_authenticate(openid_url) def open_id_authenticate(openid_url)
authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url, :method => :post) do |result, identity_url, registration| authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url) do |result, identity_url, registration|
if result.successful? if result.successful?
user = User.find_or_initialize_by_identity_url(identity_url) user = User.find_or_initialize_by_identity_url(identity_url)
if user.new_record? if user.new_record?
@@ -210,7 +194,6 @@ class AccountController < ApplicationController
end end
def successful_authentication(user) def successful_authentication(user)
logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}"
# Valid user # Valid user
self.logged_user = user self.logged_user = user
# generate a key and set cookie if autologin # generate a key and set cookie if autologin
@@ -252,9 +235,9 @@ class AccountController < ApplicationController
def register_by_email_activation(user, &block) def register_by_email_activation(user, &block)
token = Token.new(:user => user, :action => "register") token = Token.new(:user => user, :action => "register")
if user.save and token.save if user.save and token.save
Mailer.register(token).deliver Mailer.deliver_register(token)
flash[:notice] = l(:notice_account_register_done) flash[:notice] = l(:notice_account_register_done)
redirect_to signin_path redirect_to :action => 'login'
else else
yield if block_given? yield if block_given?
end end
@@ -282,7 +265,7 @@ class AccountController < ApplicationController
def register_manually_by_administrator(user, &block) def register_manually_by_administrator(user, &block)
if user.save if user.save
# Sends an email to the administrators # Sends an email to the administrators
Mailer.account_activation_request(user).deliver Mailer.deliver_account_activation_request(user)
account_pending account_pending
else else
yield if block_given? yield if block_given?
@@ -291,6 +274,6 @@ class AccountController < ApplicationController
def account_pending def account_pending
flash[:notice] = l(:notice_account_pending) flash[:notice] = l(:notice_account_pending)
redirect_to signin_path redirect_to :action => 'login'
end end
end end
+3 -3
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -40,10 +40,10 @@ class ActivitiesController < ApplicationController
events = @activity.events(@date_from, @date_to) events = @activity.events(@date_from, @date_to)
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, events.size, User.current, current_language]) if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
respond_to do |format| respond_to do |format|
format.html { format.html {
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} @events_by_day = events.group_by(&:event_date)
render :layout => false if request.xhr? render :layout => false if request.xhr?
} }
format.atom { format.atom {
+2 -2
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -63,7 +63,7 @@ class AdminController < ApplicationController
# Force ActionMailer to raise delivery errors so we can catch it # Force ActionMailer to raise delivery errors so we can catch it
ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.raise_delivery_errors = true
begin begin
@test = Mailer.test_email(User.current).deliver @test = Mailer.deliver_test_email(User.current)
flash[:notice] = l(:notice_email_sent, User.current.mail) flash[:notice] = l(:notice_email_sent, User.current.mail)
rescue Exception => e rescue Exception => e
flash[:error] = l(:notice_email_error, e.message) flash[:error] = l(:notice_email_error, e.message)
+80 -105
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -23,11 +23,8 @@ class Unauthorized < Exception; end
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include Redmine::I18n include Redmine::I18n
class_attribute :accept_api_auth_actions
class_attribute :accept_rss_auth_actions
class_attribute :model_object
layout 'base' layout 'base'
exempt_from_layout 'builder', 'rsb'
protect_from_forgery protect_from_forgery
def handle_unverified_request def handle_unverified_request
@@ -35,16 +32,44 @@ class ApplicationController < ActionController::Base
cookies.delete(:autologin) cookies.delete(:autologin)
end end
# FIXME: Remove this when all of Rack and Rails have learned how to
# properly use encodings
before_filter :params_filter
def params_filter
if RUBY_VERSION >= '1.9' && defined?(Rails) && Rails::VERSION::MAJOR < 3
self.utf8nize!(params)
end
end
def utf8nize!(obj)
if obj.frozen?
obj
elsif obj.is_a? String
obj.respond_to?(:force_encoding) ? obj.force_encoding("UTF-8") : obj
elsif obj.is_a? Hash
obj.each {|k, v| obj[k] = self.utf8nize!(v)}
elsif obj.is_a? Array
obj.each {|v| self.utf8nize!(v)}
else
obj
end
end
before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization
filter_parameter_logging :password
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
rescue_from ::Unauthorized, :with => :deny_access rescue_from ::Unauthorized, :with => :deny_access
rescue_from ::ActionView::MissingTemplate, :with => :missing_template
include Redmine::Search::Controller include Redmine::Search::Controller
include Redmine::MenuManager::MenuController include Redmine::MenuManager::MenuController
helper Redmine::MenuManager::MenuHelper helper Redmine::MenuManager::MenuHelper
Redmine::Scm::Base.all.each do |scm|
require_dependency "repository/#{scm.underscore}"
end
def session_expiration def session_expiration
if session[:user_id] if session[:user_id]
if session_expired? && !try_to_autologin if session_expired? && !try_to_autologin
@@ -82,46 +107,30 @@ class ApplicationController < ActionController::Base
Setting.check_cache Setting.check_cache
# Find the current user # Find the current user
User.current = find_current_user User.current = find_current_user
logger.info(" Current user: " + (User.current.logged? ? "#{User.current.login} (id=#{User.current.id})" : "anonymous")) if logger
end end
# Returns the current user or nil if no user is logged in # Returns the current user or nil if no user is logged in
# and starts a session if needed # and starts a session if needed
def find_current_user def find_current_user
user = nil if session[:user_id]
unless api_request? # existing session
if session[:user_id] (User.active.find(session[:user_id]) rescue nil)
# existing session elsif user = try_to_autologin
user = (User.active.find(session[:user_id]) rescue nil) user
elsif autologin_user = try_to_autologin elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?
user = autologin_user # RSS key authentication does not start a session
elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth? User.find_by_rss_key(params[:key])
# RSS key authentication does not start a session elsif Setting.rest_api_enabled? && accept_api_auth?
user = User.find_by_rss_key(params[:key])
end
end
if user.nil? && Setting.rest_api_enabled? && accept_api_auth?
if (key = api_key_from_request) if (key = api_key_from_request)
# Use API key # Use API key
user = User.find_by_api_key(key) User.find_by_api_key(key)
else else
# HTTP Basic, either username/password or API key/random # HTTP Basic, either username/password or API key/random
authenticate_with_http_basic do |username, password| authenticate_with_http_basic do |username, password|
user = User.try_to_login(username, password) || User.find_by_api_key(username) User.try_to_login(username, password) || User.find_by_api_key(username)
end
end
# Switch user if requested by an admin user
if user && user.admin? && (username = api_switch_user_from_request)
su = User.find_by_login(username)
if su && su.active?
logger.info(" User switched by: #{user.login} (id=#{user.id})") if logger
user = su
else
render_error :message => 'Invalid X-Redmine-Switch-User header', :status => 412
end end
end end
end end
user
end end
def try_to_autologin def try_to_autologin
@@ -263,7 +272,7 @@ class ApplicationController < ActionController::Base
end end
def find_model_object def find_model_object
model = self.class.model_object model = self.class.read_inheritable_attribute('model_object')
if model if model
@object = model.find(params[:id]) @object = model.find(params[:id])
self.instance_variable_set('@' + controller_name.singularize, @object) if @object self.instance_variable_set('@' + controller_name.singularize, @object) if @object
@@ -273,27 +282,17 @@ class ApplicationController < ActionController::Base
end end
def self.model_object(model) def self.model_object(model)
self.model_object = model write_inheritable_attribute('model_object', model)
end end
# Find the issue whose id is the :id parameter # Filter for bulk issue operations
# Raises a Unauthorized exception if the issue is not visible
def find_issue
# Issue.visible.find(...) can not be used to redirect user to the login form
# if the issue actually exists but requires authentication
@issue = Issue.find(params[:id])
raise Unauthorized unless @issue.visible?
@project = @issue.project
rescue ActiveRecord::RecordNotFound
render_404
end
# Find issues with a single :id param or :ids array param
# Raises a Unauthorized exception if one of the issues is not visible
def find_issues def find_issues
@issues = Issue.find_all_by_id(params[:id] || params[:ids]) @issues = Issue.find_all_by_id(params[:id] || params[:ids])
raise ActiveRecord::RecordNotFound if @issues.empty? raise ActiveRecord::RecordNotFound if @issues.empty?
raise Unauthorized unless @issues.all?(&:visible?) if @issues.detect {|issue| !issue.visible?}
deny_access
return
end
@projects = @issues.collect(&:project).compact.uniq @projects = @issues.collect(&:project).compact.uniq
@project = @projects.first if @projects.size == 1 @project = @projects.first if @projects.size == 1
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
@@ -303,7 +302,7 @@ class ApplicationController < ActionController::Base
# make sure that the user is a member of the project (or admin) if project is private # make sure that the user is a member of the project (or admin) if project is private
# used as a before_filter for actions that do not require any particular permission on the project # used as a before_filter for actions that do not require any particular permission on the project
def check_project_privacy def check_project_privacy
if @project && !@project.archived? if @project && @project.active?
if @project.visible? if @project.visible?
true true
else else
@@ -317,16 +316,12 @@ class ApplicationController < ActionController::Base
end end
def back_url def back_url
url = params[:back_url] params[:back_url] || request.env['HTTP_REFERER']
if url.nil? && referer = request.env['HTTP_REFERER']
url = CGI.unescape(referer.to_s)
end
url
end end
def redirect_back_or_default(default) def redirect_back_or_default(default)
back_url = params[:back_url].to_s back_url = CGI.unescape(params[:back_url].to_s)
if back_url.present? if !back_url.blank?
begin begin
uri = URI.parse(back_url) uri = URI.parse(back_url)
# do not redirect user to another host or to the login or register page # do not redirect user to another host or to the login or register page
@@ -335,7 +330,6 @@ class ApplicationController < ActionController::Base
return return
end end
rescue URI::InvalidURIError rescue URI::InvalidURIError
logger.warn("Could not redirect to invalid URL #{back_url}")
# redirect to default # redirect to default
end end
end end
@@ -343,19 +337,6 @@ class ApplicationController < ActionController::Base
false false
end end
# Redirects to the request referer if present, redirects to args or call block otherwise.
def redirect_to_referer_or(*args, &block)
redirect_to :back
rescue ::ActionController::RedirectBackError
if args.any?
redirect_to *args
elsif block_given?
block.call
else
raise "#redirect_to_referer_or takes arguments or a block"
end
end
def render_403(options={}) def render_403(options={})
@project = nil @project = nil
render_error({:message => :notice_not_authorized, :status => 403}.merge(options)) render_error({:message => :notice_not_authorized, :status => 403}.merge(options))
@@ -379,17 +360,13 @@ class ApplicationController < ActionController::Base
format.html { format.html {
render :template => 'common/error', :layout => use_layout, :status => @status render :template => 'common/error', :layout => use_layout, :status => @status
} }
format.any { head @status } format.atom { head @status }
format.xml { head @status }
format.js { head @status }
format.json { head @status }
end end
end end
# Handler for ActionView::MissingTemplate exception
def missing_template
logger.warn "Missing template, responding with 404"
@project = nil
render_404
end
# Filter for actions that provide an API response # Filter for actions that provide an API response
# but have no HTML representation for non admin users # but have no HTML representation for non admin users
def require_admin_or_api_request def require_admin_or_api_request
@@ -422,15 +399,15 @@ class ApplicationController < ActionController::Base
@items.sort! {|x,y| y.event_datetime <=> x.event_datetime } @items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
@items = @items.slice(0, Setting.feeds_limit.to_i) @items = @items.slice(0, Setting.feeds_limit.to_i)
@title = options[:title] || Setting.app_title @title = options[:title] || Setting.app_title
render :template => "common/feed", :formats => [:atom], :layout => false, render :template => "common/feed.atom", :layout => false,
:content_type => 'application/atom+xml' :content_type => 'application/atom+xml'
end end
def self.accept_rss_auth(*actions) def self.accept_rss_auth(*actions)
if actions.any? if actions.any?
self.accept_rss_auth_actions = actions write_inheritable_attribute('accept_rss_auth_actions', actions)
else else
self.accept_rss_auth_actions || [] read_inheritable_attribute('accept_rss_auth_actions') || []
end end
end end
@@ -440,9 +417,9 @@ class ApplicationController < ActionController::Base
def self.accept_api_auth(*actions) def self.accept_api_auth(*actions)
if actions.any? if actions.any?
self.accept_api_auth_actions = actions write_inheritable_attribute('accept_api_auth_actions', actions)
else else
self.accept_api_auth_actions || [] read_inheritable_attribute('accept_api_auth_actions') || []
end end
end end
@@ -528,11 +505,6 @@ class ApplicationController < ActionController::Base
end end
end end
# Returns the API 'switch user' value if present
def api_switch_user_from_request
request.headers["X-Redmine-Switch-User"].to_s.presence
end
# Renders a warning flash if obj has unsaved attachments # Renders a warning flash if obj has unsaved attachments
def render_attachment_warning_if_needed(obj) def render_attachment_warning_if_needed(obj)
flash[:warning] = l(:warning_attachments_not_saved, obj.unsaved_attachments.size) if obj.unsaved_attachments.present? flash[:warning] = l(:warning_attachments_not_saved, obj.unsaved_attachments.size) if obj.unsaved_attachments.present?
@@ -561,17 +533,6 @@ class ApplicationController < ActionController::Base
render_error "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator." render_error "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator."
end end
# Renders a 200 response for successfull updates or deletions via the API
def render_api_ok
render_api_head :ok
end
# Renders a head API response
def render_api_head(status)
# #head would return a response body with one space
render :text => '', :status => status, :layout => nil
end
# Renders API response on validation failure # Renders API response on validation failure
def render_validation_errors(objects) def render_validation_errors(objects)
if objects.is_a?(Array) if objects.is_a?(Array)
@@ -579,12 +540,26 @@ class ApplicationController < ActionController::Base
else else
@error_messages = objects.errors.full_messages @error_messages = objects.errors.full_messages
end end
render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => nil render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => false
end end
# Overrides #_include_layout? so that #render with no arguments # Overrides #default_template so that the api template
# is used automatically if it exists
def default_template(action_name = self.action_name)
if api_request?
begin
return self.view_paths.find_template(default_template_name(action_name), 'api')
rescue ::ActionView::MissingTemplate
# the api template was not found
# fallback to the default behaviour
end
end
super
end
# Overrides #pick_layout so that #render with no arguments
# doesn't use the layout for api requests # doesn't use the layout for api requests
def _include_layout?(*args) def pick_layout(*args)
api_request? ? false : super api_request? ? nil : super
end end
end end
+10 -23
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -17,7 +17,7 @@
class AttachmentsController < ApplicationController class AttachmentsController < ApplicationController
before_filter :find_project, :except => :upload before_filter :find_project, :except => :upload
before_filter :file_readable, :read_authorize, :only => [:show, :download, :thumbnail] before_filter :file_readable, :read_authorize, :only => [:show, :download]
before_filter :delete_authorize, :only => :destroy before_filter :delete_authorize, :only => :destroy
before_filter :authorize_global, :only => :upload before_filter :authorize_global, :only => :upload
@@ -52,26 +52,11 @@ class AttachmentsController < ApplicationController
@attachment.increment_download @attachment.increment_download
end end
if stale?(:etag => @attachment.digest) # images are sent inline
# images are sent inline send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), :type => detect_content_type(@attachment),
:type => detect_content_type(@attachment), :disposition => (@attachment.image? ? 'inline' : 'attachment')
:disposition => (@attachment.image? ? 'inline' : 'attachment')
end
end
def thumbnail
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
if stale?(:etag => thumbnail)
send_file thumbnail,
:filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),
:disposition => 'inline'
end
else
# No thumbnail for the attachment or thumbnail could not be created
render :nothing => true, :status => 404
end
end end
def upload def upload
@@ -84,7 +69,7 @@ class AttachmentsController < ApplicationController
@attachment = Attachment.new(:file => request.raw_post) @attachment = Attachment.new(:file => request.raw_post)
@attachment.author = User.current @attachment.author = User.current
@attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16) @attachment.filename = Redmine::Utils.random_hex(16)
if @attachment.save if @attachment.save
respond_to do |format| respond_to do |format|
@@ -103,7 +88,9 @@ class AttachmentsController < ApplicationController
end end
# Make sure association callbacks are called # Make sure association callbacks are called
@attachment.container.attachments.delete(@attachment) @attachment.container.attachments.delete(@attachment)
redirect_to_referer_or project_path(@project) redirect_to :back
rescue ::ActionController::RedirectBackError
redirect_to :controller => 'projects', :action => 'show', :id => @project
end end
private private
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+11 -28
View File
@@ -1,44 +1,27 @@
# Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class AutoCompletesController < ApplicationController class AutoCompletesController < ApplicationController
before_filter :find_project before_filter :find_project
def issues def issues
@issues = [] @issues = []
q = (params[:q] || params[:term]).to_s.strip q = params[:q].to_s
if q.present? query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues
scope = (params[:scope] == "all" || @project.nil? ? Issue : @project.issues).visible if q.match(/^\d+$/)
if q.match(/^\d+$/) @issues << query.visible.find_by_id(q.to_i)
@issues << scope.find_by_id(q.to_i)
end
@issues += scope.where("LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%").order("#{Issue.table_name}.id DESC").limit(10).all
@issues.compact!
end end
unless q.blank?
@issues += query.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
end
@issues.compact!
render :layout => false render :layout => false
end end
private private
def find_project def find_project
if params[:project_id].present? project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
@project = Project.find(params[:project_id]) @project = Project.find(project_id)
end
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
render_404 render_404
end end
end end
+4 -4
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -25,7 +25,7 @@ class BoardsController < ApplicationController
helper :watchers helper :watchers
def index def index
@boards = @project.boards.includes(:last_message => :author).all @boards = @project.boards
# show the board if there is only one # show the board if there is only one
if @boards.size == 1 if @boards.size == 1
@board = @boards.first @board = @boards.first
@@ -43,10 +43,10 @@ class BoardsController < ApplicationController
@topic_count = @board.topics.count @topic_count = @board.topics.count
@topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC").order(sort_clause).all( @topics = @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '),
:include => [:author, {:last_reply => :author}], :include => [:author, {:last_reply => :author}],
:limit => @topic_pages.items_per_page, :limit => @topic_pages.items_per_page,
:offset => @topic_pages.current.offset) :offset => @topic_pages.current.offset
@message = Message.new(:board => @board) @message = Message.new(:board => @board)
render :action => 'show', :layout => !request.xhr? render :action => 'show', :layout => !request.xhr?
} }
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -1,20 +1,3 @@
# Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class ContextMenusController < ApplicationController class ContextMenusController < ApplicationController
helper :watchers helper :watchers
helper :issues helper :issues
@@ -24,7 +7,6 @@ class ContextMenusController < ApplicationController
if (@issues.size == 1) if (@issues.size == 1)
@issue = @issues.first @issue = @issues.first
end end
@issue_ids = @issues.map(&:id).sort
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
@projects = @issues.collect(&:project).compact.uniq @projects = @issues.collect(&:project).compact.uniq
@@ -49,7 +31,6 @@ class ContextMenusController < ApplicationController
@assignables = @projects.map(&:assignable_users).reduce(:&) @assignables = @projects.map(&:assignable_users).reduce(:&)
@trackers = @projects.map(&:trackers).reduce(:&) @trackers = @projects.map(&:trackers).reduce(:&)
end end
@versions = @projects.map {|p| p.shared_versions.open}.reduce(:&)
@priorities = IssuePriority.active.reverse @priorities = IssuePriority.active.reverse
@back = back_url @back = back_url
@@ -67,7 +48,6 @@ class ContextMenusController < ApplicationController
end end
end end
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
render :layout => false render :layout => false
end end
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+2 -4
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -86,9 +86,7 @@ class DocumentsController < ApplicationController
attachments = Attachment.attach_files(@document, params[:attachments]) attachments = Attachment.attach_files(@document, params[:attachments])
render_attachment_warning_if_needed(@document) render_attachment_warning_if_needed(@document)
if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added') Mailer.deliver_attachments_added(attachments[:files]) if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
Mailer.attachments_added(attachments[:files]).deliver
end
redirect_to :action => 'show', :id => @document redirect_to :action => 'show', :id => @document
end end
end end
+4 -17
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -18,26 +18,13 @@
class EnumerationsController < ApplicationController class EnumerationsController < ApplicationController
layout 'admin' layout 'admin'
before_filter :require_admin, :except => :index before_filter :require_admin
before_filter :require_admin_or_api_request, :only => :index
before_filter :build_new_enumeration, :only => [:new, :create] before_filter :build_new_enumeration, :only => [:new, :create]
before_filter :find_enumeration, :only => [:edit, :update, :destroy] before_filter :find_enumeration, :only => [:edit, :update, :destroy]
accept_api_auth :index
helper :custom_fields helper :custom_fields
def index def index
respond_to do |format|
format.html
format.api {
@klass = Enumeration.get_subclass(params[:type])
if @klass
@enumerations = @klass.shared.sorted.all
else
render_404
end
}
end
end end
def new def new
@@ -46,7 +33,7 @@ class EnumerationsController < ApplicationController
def create def create
if request.post? && @enumeration.save if request.post? && @enumeration.save
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index' redirect_to :action => 'index', :type => @enumeration.type
else else
render :action => 'new' render :action => 'new'
end end
@@ -58,7 +45,7 @@ class EnumerationsController < ApplicationController
def update def update
if request.put? && @enumeration.update_attributes(params[:enumeration]) if request.put? && @enumeration.update_attributes(params[:enumeration])
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'index' redirect_to :action => 'index', :type => @enumeration.type
else else
render :action => 'edit' render :action => 'edit'
end end
+1 -18
View File
@@ -1,20 +1,3 @@
# Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class FilesController < ApplicationController class FilesController < ApplicationController
menu_item :files menu_item :files
@@ -46,7 +29,7 @@ class FilesController < ApplicationController
render_attachment_warning_if_needed(container) render_attachment_warning_if_needed(container)
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
Mailer.attachments_added(attachments[:files]).deliver Mailer.deliver_attachments_added(attachments[:files])
end end
redirect_to project_files_path(@project) redirect_to project_files_path(@project)
end end
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+69 -37
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -19,34 +19,51 @@ class GroupsController < ApplicationController
layout 'admin' layout 'admin'
before_filter :require_admin before_filter :require_admin
before_filter :find_group, :except => [:index, :new, :create]
accept_api_auth :index, :show, :create, :update, :destroy, :add_users, :remove_user
helper :custom_fields helper :custom_fields
# GET /groups
# GET /groups.xml
def index def index
@groups = Group.sorted.all @groups = Group.find(:all, :order => 'lastname')
respond_to do |format| respond_to do |format|
format.html format.html # index.html.erb
format.api format.xml { render :xml => @groups }
end end
end end
# GET /groups/1
# GET /groups/1.xml
def show def show
@group = Group.find(params[:id])
respond_to do |format| respond_to do |format|
format.html format.html # show.html.erb
format.api format.xml { render :xml => @group }
end end
end end
# GET /groups/new
# GET /groups/new.xml
def new def new
@group = Group.new @group = Group.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @group }
end
end end
# GET /groups/1/edit
def edit
@group = Group.find(params[:id], :include => :projects)
end
# POST /groups
# POST /groups.xml
def create def create
@group = Group.new @group = Group.new(params[:group])
@group.safe_attributes = params[:group]
respond_to do |format| respond_to do |format|
if @group.save if @group.save
@@ -54,87 +71,102 @@ class GroupsController < ApplicationController
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to(params[:continue] ? new_group_path : groups_path) redirect_to(params[:continue] ? new_group_path : groups_path)
} }
format.api { render :action => 'show', :status => :created, :location => group_url(@group) } format.xml { render :xml => @group, :status => :created, :location => @group }
else else
format.html { render :action => "new" } format.html { render :action => "new" }
format.api { render_validation_errors(@group) } format.xml { render :xml => @group.errors, :status => :unprocessable_entity }
end end
end end
end end
def edit # PUT /groups/1
end # PUT /groups/1.xml
def update def update
@group.safe_attributes = params[:group] @group = Group.find(params[:id])
respond_to do |format| respond_to do |format|
if @group.save if @group.update_attributes(params[:group])
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
format.html { redirect_to(groups_path) } format.html { redirect_to(groups_path) }
format.api { render_api_ok } format.xml { head :ok }
else else
format.html { render :action => "edit" } format.html { render :action => "edit" }
format.api { render_validation_errors(@group) } format.xml { render :xml => @group.errors, :status => :unprocessable_entity }
end end
end end
end end
# DELETE /groups/1
# DELETE /groups/1.xml
def destroy def destroy
@group = Group.find(params[:id])
@group.destroy @group.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to(groups_url) } format.html { redirect_to(groups_url) }
format.api { render_api_ok } format.xml { head :ok }
end end
end end
def add_users def add_users
@users = User.find_all_by_id(params[:user_id] || params[:user_ids]) @group = Group.find(params[:id])
@group.users << @users if request.post? users = User.find_all_by_id(params[:user_ids])
@group.users << users if request.post?
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' } format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
format.js format.js {
format.api { render_api_ok } render(:update) {|page|
page.replace_html "tab-content-users", :partial => 'groups/users'
users.each {|user| page.visual_effect(:highlight, "user-#{user.id}") }
}
}
end end
end end
def remove_user def remove_user
@group = Group.find(params[:id])
@group.users.delete(User.find(params[:user_id])) if request.delete? @group.users.delete(User.find(params[:user_id])) if request.delete?
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' } format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
format.js format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} }
format.api { render_api_ok }
end end
end end
def autocomplete_for_user def autocomplete_for_user
@group = Group.find(params[:id])
@users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100) @users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100)
render :layout => false render :layout => false
end end
def edit_membership def edit_membership
@group = Group.find(params[:id])
@membership = Member.edit_membership(params[:membership_id], params[:membership], @group) @membership = Member.edit_membership(params[:membership_id], params[:membership], @group)
@membership.save if request.post? @membership.save if request.post?
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' } if @membership.valid?
format.js format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
format.js {
render(:update) {|page|
page.replace_html "tab-content-memberships", :partial => 'groups/memberships'
page.visual_effect(:highlight, "member-#{@membership.id}")
}
}
else
format.js {
render(:update) {|page|
page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
}
}
end
end end
end end
def destroy_membership def destroy_membership
@group = Group.find(params[:id])
Member.find(params[:membership_id]).destroy if request.post? Member.find(params[:membership_id]).destroy if request.post?
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' } format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
format.js format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'groups/memberships'} }
end end
end end
private
def find_group
@group = Group.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
end end
+12 -10
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -41,11 +41,6 @@ class IssueCategoriesController < ApplicationController
def new def new
@category = @project.issue_categories.build @category = @project.issue_categories.build
@category.safe_attributes = params[:issue_category] @category.safe_attributes = params[:issue_category]
respond_to do |format|
format.html
format.js
end
end end
def create def create
@@ -57,13 +52,20 @@ class IssueCategoriesController < ApplicationController
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
end end
format.js format.js do
# IE doesn't support the replace_html rjs method for select box options
render(:update) {|page| page.replace "issue_category_id",
content_tag('select', content_tag('option') + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
}
end
format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) } format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
end end
else else
respond_to do |format| respond_to do |format|
format.html { render :action => 'new'} format.html { render :action => 'new'}
format.js { render :action => 'new'} format.js do
render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) }
end
format.api { render_validation_errors(@category) } format.api { render_validation_errors(@category) }
end end
end end
@@ -80,7 +82,7 @@ class IssueCategoriesController < ApplicationController
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
} }
format.api { render_api_ok } format.api { head :ok }
end end
else else
respond_to do |format| respond_to do |format|
@@ -100,7 +102,7 @@ class IssueCategoriesController < ApplicationController
@category.destroy(reassign_to) @category.destroy(reassign_to)
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' } format.html { redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' }
format.api { render_api_ok } format.api { head :ok }
end end
return return
end end
+12 -5
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -49,9 +49,16 @@ class IssueRelationsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
format.js { format.js do
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
} render :update do |page|
page.replace_html "relations", :partial => 'issues/relations'
if @relation.errors.empty?
page << "$('relation_delay').value = ''"
page << "$('relation_issue_to_id').value = ''"
end
end
end
format.api { format.api {
if saved if saved
render :action => 'show', :status => :created, :location => relation_url(@relation) render :action => 'show', :status => :created, :location => relation_url(@relation)
@@ -68,8 +75,8 @@ class IssueRelationsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { redirect_to issue_path } # TODO : does this really work since @issue is always nil? What is it useful to? format.html { redirect_to issue_path } # TODO : does this really work since @issue is always nil? What is it useful to?
format.js format.js { render(:update) {|page| page.remove "relation-#{@relation.id}"} }
format.api { render_api_ok } format.api { head :ok }
end end
end end
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+44 -33
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -50,13 +50,13 @@ class IssuesController < ApplicationController
include SortHelper include SortHelper
include IssuesHelper include IssuesHelper
helper :timelog helper :timelog
helper :gantt
include Redmine::Export::PDF include Redmine::Export::PDF
def index def index
retrieve_query retrieve_query
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
sort_update(@query.sortable_columns) sort_update(@query.sortable_columns)
@query.sort_criteria = sort_criteria.to_a
if @query.valid? if @query.valid?
case params[:format] case params[:format]
@@ -82,7 +82,7 @@ class IssuesController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { render :template => 'issues/index', :layout => !request.xhr? } format.html { render :template => 'issues/index', :layout => !request.xhr? }
format.api { format.api {
Issue.load_visible_relations(@issues) if include_in_api_response?('relations') Issue.load_relations(@issues) if include_in_api_response?('relations')
} }
format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") } format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
format.csv { send_data(issues_to_csv(@issues, @project, @query, params), :type => 'text/csv; header=present', :filename => 'export.csv') } format.csv { send_data(issues_to_csv(@issues, @project, @query, params), :type => 'text/csv; header=present', :filename => 'export.csv') }
@@ -100,9 +100,8 @@ class IssuesController < ApplicationController
end end
def show def show
@journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
@journals.each_with_index {|j,i| j.indice = i+1} @journals.each_with_index {|j,i| j.indice = i+1}
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
@journals.reverse! if User.current.wants_comments_in_reverse_order? @journals.reverse! if User.current.wants_comments_in_reverse_order?
@changesets = @issue.changesets.visible.all @changesets = @issue.changesets.visible.all
@@ -120,10 +119,7 @@ class IssuesController < ApplicationController
} }
format.api format.api
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
format.pdf { format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
pdf = issue_to_pdf(@issue, :journals => @journals)
send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf")
}
end end
end end
@@ -132,7 +128,17 @@ class IssuesController < ApplicationController
def new def new
respond_to do |format| respond_to do |format|
format.html { render :action => 'new', :layout => !request.xhr? } format.html { render :action => 'new', :layout => !request.xhr? }
format.js { render :partial => 'update_form' } format.js {
render(:update) { |page|
if params[:project_change]
page.replace_html 'all_attributes', :partial => 'form'
else
page.replace_html 'attributes', :partial => 'attributes'
end
m = User.current.allowed_to?(:log_time, @issue.project) ? 'show' : 'hide'
page << "if ($('log_time')) {Element.#{m}('log_time');}"
}
}
end end
end end
@@ -144,7 +150,7 @@ class IssuesController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { format.html {
render_attachment_warning_if_needed(@issue) render_attachment_warning_if_needed(@issue)
flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject)) flash[:notice] = l(:notice_issue_successful_create, :id => "<a href='#{issue_path(@issue)}'>##{@issue.id}</a>")
redirect_to(params[:continue] ? { :action => 'new', :project_id => @issue.project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } : redirect_to(params[:continue] ? { :action => 'new', :project_id => @issue.project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
{ :action => 'show', :id => @issue }) { :action => 'show', :id => @issue })
} }
@@ -177,8 +183,12 @@ class IssuesController < ApplicationController
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError
@conflict = true @conflict = true
if params[:last_journal_id] if params[:last_journal_id]
@conflict_journals = @issue.journals_after(params[:last_journal_id]).all if params[:last_journal_id].present?
@conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project) last_journal_id = params[:last_journal_id].to_i
@conflict_journals = @issue.journals.all(:conditions => ["#{Journal.table_name}.id > ?", last_journal_id])
else
@conflict_journals = @issue.journals.all
end
end end
end end
@@ -188,7 +198,7 @@ class IssuesController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } format.html { redirect_back_or_default({:action => 'show', :id => @issue}) }
format.api { render_api_ok } format.api { head :ok }
end end
else else
respond_to do |format| respond_to do |format|
@@ -227,7 +237,6 @@ class IssuesController < ApplicationController
@categories = target_projects.map {|p| p.issue_categories}.reduce(:&) @categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
if @copy if @copy
@attachments_present = @issues.detect {|i| i.attachments.any?}.present? @attachments_present = @issues.detect {|i| i.attachments.any?}.present?
@subtasks_present = @issues.detect {|i| !i.leaf?}.present?
end end
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
@@ -241,20 +250,10 @@ class IssuesController < ApplicationController
unsaved_issue_ids = [] unsaved_issue_ids = []
moved_issues = [] moved_issues = []
if @copy && params[:copy_subtasks].present?
# Descendant issues will be copied with the parent task
# Don't copy them twice
@issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
end
@issues.each do |issue| @issues.each do |issue|
issue.reload issue.reload
if @copy if @copy
issue = issue.copy({}, issue = issue.copy({}, :attachments => params[:copy_attachments].present?)
:attachments => params[:copy_attachments].present?,
:subtasks => params[:copy_subtasks].present?
)
end end
journal = issue.init_journal(User.current, params[:notes]) journal = issue.init_journal(User.current, params[:notes])
issue.safe_attributes = attributes issue.safe_attributes = attributes
@@ -309,11 +308,23 @@ class IssuesController < ApplicationController
end end
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_default(:action => 'index', :project_id => @project) } format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
format.api { render_api_ok } format.api { head :ok }
end end
end end
private private
def find_issue
# Issue.visible.find(...) can not be used to redirect user to the login form
# if the issue actually exists but requires authentication
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
unless @issue.visible?
deny_access
return
end
@project = @issue.project
rescue ActiveRecord::RecordNotFound
render_404
end
def find_project def find_project
project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id]) project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id])
@@ -348,7 +359,8 @@ class IssuesController < ApplicationController
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
@time_entry.attributes = params[:time_entry] @time_entry.attributes = params[:time_entry]
@issue.init_journal(User.current) @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
@issue.init_journal(User.current, @notes)
issue_attributes = params[:issue] issue_attributes = params[:issue]
if issue_attributes && params[:conflict_resolution] if issue_attributes && params[:conflict_resolution]
@@ -357,7 +369,7 @@ class IssuesController < ApplicationController
issue_attributes = issue_attributes.dup issue_attributes = issue_attributes.dup
issue_attributes.delete(:lock_version) issue_attributes.delete(:lock_version)
when 'add_notes' when 'add_notes'
issue_attributes = issue_attributes.slice(:notes) issue_attributes = {}
when 'cancel' when 'cancel'
redirect_to issue_path(@issue) redirect_to issue_path(@issue)
return false return false
@@ -378,8 +390,7 @@ class IssuesController < ApplicationController
begin begin
@copy_from = Issue.visible.find(params[:copy_from]) @copy_from = Issue.visible.find(params[:copy_from])
@copy_attachments = params[:copy_attachments].present? || request.get? @copy_attachments = params[:copy_attachments].present? || request.get?
@copy_subtasks = params[:copy_subtasks].present? || request.get? @issue.copy_from(@copy_from, :attachments => @copy_attachments)
@issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks)
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
render_404 render_404
return return
@@ -391,7 +402,7 @@ class IssuesController < ApplicationController
end end
@issue.project = @project @issue.project = @project
@issue.author ||= User.current @issue.author = User.current
# Tracker must be set before custom field values # Tracker must be set before custom field values
@issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
if @issue.tracker.nil? if @issue.tracker.nil?
+24 -10
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -57,20 +57,26 @@ class JournalsController < ApplicationController
end end
def new def new
@journal = Journal.visible.find(params[:journal_id]) if params[:journal_id] journal = Journal.find(params[:journal_id]) if params[:journal_id]
if @journal if journal
user = @journal.user user = journal.user
text = @journal.notes text = journal.notes
else else
user = @issue.author user = @issue.author
text = @issue.description text = @issue.description
end end
# Replaces pre blocks with [...] # Replaces pre blocks with [...]
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]') text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
@content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
rescue ActiveRecord::RecordNotFound
render_404 render(:update) { |page|
page.<< "$('notes').value = \"#{escape_javascript content}\";"
page.show 'update'
page << "Form.Element.focus('notes');"
page << "Element.scrollTo('update');"
page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
}
end end
def edit def edit
@@ -97,9 +103,17 @@ class JournalsController < ApplicationController
private private
def find_journal def find_journal
@journal = Journal.visible.find(params[:id]) @journal = Journal.find(params[:id])
@project = @journal.journalized.project @project = @journal.journalized.project
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
render_404 render_404
end end
# TODO: duplicated in IssuesController
def find_issue
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
@project = @issue.project
rescue ActiveRecord::RecordNotFound
render_404
end
end end
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+40 -14
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -63,16 +63,31 @@ class MembersController < ApplicationController
end end
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } if members.present? && members.all? {|m| m.valid? }
format.js { @members = members } format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
format.api { format.js {
@member = members.first render(:update) {|page|
if @member.valid? page.replace_html "tab-content-members", :partial => 'projects/settings/members'
page << 'hideOnLoad()'
members.each {|member| page.visual_effect(:highlight, "member-#{member.id}") }
}
}
format.api {
@member = members.first
render :action => 'show', :status => :created, :location => membership_url(@member) render :action => 'show', :status => :created, :location => membership_url(@member)
else }
render_validation_errors(@member) else
end format.js {
} render(:update) {|page|
errors = members.collect {|m|
m.errors.full_messages
}.flatten.uniq
page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', ')))
}
}
format.api { render_validation_errors(members.first) }
end
end end
end end
@@ -83,10 +98,16 @@ class MembersController < ApplicationController
saved = @member.save saved = @member.save
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
format.js format.js {
render(:update) {|page|
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
page << 'hideOnLoad()'
page.visual_effect(:highlight, "member-#{@member.id}")
}
}
format.api { format.api {
if saved if saved
render_api_ok head :ok
else else
render_validation_errors(@member) render_validation_errors(@member)
end end
@@ -100,10 +121,14 @@ class MembersController < ApplicationController
end end
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
format.js format.js { render(:update) {|page|
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
page << 'hideOnLoad()'
}
}
format.api { format.api {
if @member.destroyed? if @member.destroyed?
render_api_ok head :ok
else else
head :unprocessable_entity head :unprocessable_entity
end end
@@ -115,4 +140,5 @@ class MembersController < ApplicationController
@principals = Principal.active.not_member_of(@project).like(params[:q]).all(:limit => 100) @principals = Principal.active.not_member_of(@project).like(params[:q]).all(:limit => 100)
render :layout => false render :layout => false
end end
end end
+21 -17
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -22,7 +22,6 @@ class MessagesController < ApplicationController
before_filter :find_message, :except => [:new, :preview] before_filter :find_message, :except => [:new, :preview]
before_filter :authorize, :except => [:preview, :edit, :destroy] before_filter :authorize, :except => [:preview, :edit, :destroy]
helper :boards
helper :watchers helper :watchers
helper :attachments helper :attachments
include AttachmentsHelper include AttachmentsHelper
@@ -60,7 +59,7 @@ class MessagesController < ApplicationController
if @message.save if @message.save
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
render_attachment_warning_if_needed(@message) render_attachment_warning_if_needed(@message)
redirect_to board_message_path(@board, @message) redirect_to :action => 'show', :id => @message
end end
end end
end end
@@ -77,7 +76,7 @@ class MessagesController < ApplicationController
attachments = Attachment.attach_files(@reply, params[:attachments]) attachments = Attachment.attach_files(@reply, params[:attachments])
render_attachment_warning_if_needed(@reply) render_attachment_warning_if_needed(@reply)
end end
redirect_to board_message_path(@board, @topic, :r => @reply) redirect_to :action => 'show', :id => @topic, :r => @reply
end end
# Edit a message # Edit a message
@@ -89,35 +88,40 @@ class MessagesController < ApplicationController
render_attachment_warning_if_needed(@message) render_attachment_warning_if_needed(@message)
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
@message.reload @message.reload
redirect_to board_message_path(@message.board, @message.root, :r => (@message.parent_id && @message.id)) redirect_to :action => 'show', :board_id => @message.board, :id => @message.root, :r => (@message.parent_id && @message.id)
end end
end end
# Delete a messages # Delete a messages
def destroy def destroy
(render_403; return false) unless @message.destroyable_by?(User.current) (render_403; return false) unless @message.destroyable_by?(User.current)
r = @message.to_param
@message.destroy @message.destroy
if @message.parent redirect_to @message.parent.nil? ?
redirect_to board_message_path(@board, @message.parent, :r => r) { :controller => 'boards', :action => 'show', :project_id => @project, :id => @board } :
else { :action => 'show', :id => @message.parent, :r => @message }
redirect_to project_board_path(@project, @board)
end
end end
def quote def quote
@subject = @message.subject user = @message.author
@subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') text = @message.content
subject = @message.subject.gsub('"', '\"')
@content = "#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> " subject = "RE: #{subject}" unless subject.starts_with?('RE:')
@content << @message.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> "
content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n"
render(:update) { |page|
page << "$('message_subject').value = \"#{subject}\";"
page.<< "$('message_content').value = \"#{content}\";"
page.show 'reply'
page << "Form.Element.focus('message_content');"
page << "Element.scrollTo('reply');"
page << "$('message_content').scrollTop = $('message_content').scrollHeight - $('message_content').clientHeight;"
}
end end
def preview def preview
message = @board.messages.find_by_id(params[:id]) message = @board.messages.find_by_id(params[:id])
@attachements = message.attachments if message @attachements = message.attachments if message
@text = (params[:message] || params[:reply])[:content] @text = (params[:message] || params[:reply])[:content]
@previewed = message
render :partial => 'common/preview' render :partial => 'common/preview'
end end
+14 -20
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -135,11 +135,7 @@ class MyController < ApplicationController
@user = User.current @user = User.current
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup
@block_options = [] @block_options = []
BLOCKS.each do |k, v| BLOCKS.each {|k, v| @block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize]}
unless %w(top left right).detect {|f| (@blocks[f] ||= []).include?(k)}
@block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize]
end
end
end end
# Add a block to user's page # Add a block to user's page
@@ -147,17 +143,16 @@ class MyController < ApplicationController
# params[:block] : id of the block to add # params[:block] : id of the block to add
def add_block def add_block
block = params[:block].to_s.underscore block = params[:block].to_s.underscore
if block.present? && BLOCKS.key?(block) (render :nothing => true; return) unless block && (BLOCKS.keys.include? block)
@user = User.current @user = User.current
layout = @user.pref[:my_page_layout] || {} layout = @user.pref[:my_page_layout] || {}
# remove if already present in a group # remove if already present in a group
%w(top left right).each {|f| (layout[f] ||= []).delete block } %w(top left right).each {|f| (layout[f] ||= []).delete block }
# add it on top # add it on top
layout['top'].unshift block layout['top'].unshift block
@user.pref[:my_page_layout] = layout @user.pref[:my_page_layout] = layout
@user.pref.save @user.pref.save
end render :partial => "block", :locals => {:user => @user, :block_name => block}
redirect_to :action => 'page_layout'
end end
# Remove a block to user's page # Remove a block to user's page
@@ -170,7 +165,7 @@ class MyController < ApplicationController
%w(top left right).each {|f| (layout[f] ||= []).delete block } %w(top left right).each {|f| (layout[f] ||= []).delete block }
@user.pref[:my_page_layout] = layout @user.pref[:my_page_layout] = layout
@user.pref.save @user.pref.save
redirect_to :action => 'page_layout' render :nothing => true
end end
# Change blocks order on user's page # Change blocks order on user's page
@@ -180,8 +175,7 @@ class MyController < ApplicationController
group = params[:group] group = params[:group]
@user = User.current @user = User.current
if group.is_a?(String) if group.is_a?(String)
group_items = (params["blocks"] || []).collect(&:underscore) group_items = (params["list-#{group}"] || []).collect(&:underscore)
group_items.each {|s| s.sub!(/^block_/, '')}
if group_items and group_items.is_a? Array if group_items and group_items.is_a? Array
layout = @user.pref[:my_page_layout] || {} layout = @user.pref[:my_page_layout] || {}
# remove group blocks if they are presents in other groups # remove group blocks if they are presents in other groups
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+2 -7
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -26,8 +26,7 @@ class PreviewsController < ApplicationController
if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n") if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
@description = nil @description = nil
end end
# params[:notes] is useful for preview of notes in issue history @notes = params[:notes]
@notes = params[:notes] || (params[:issue] ? params[:issue][:notes] : nil)
else else
@description = (params[:issue] ? params[:issue][:description] : nil) @description = (params[:issue] ? params[:issue][:description] : nil)
end end
@@ -35,10 +34,6 @@ class PreviewsController < ApplicationController
end end
def news def news
if params[:id].present? && news = News.visible.find_by_id(params[:id])
@previewed = news
@attachments = news.attachments
end
@text = (params[:news] ? params[:news][:description] : nil) @text = (params[:news] ? params[:news][:description] : nil)
render :partial => 'common/preview' render :partial => 'common/preview'
end end
@@ -1,20 +1,3 @@
# Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class ProjectEnumerationsController < ApplicationController class ProjectEnumerationsController < ApplicationController
before_filter :find_project_by_project_id before_filter :find_project_by_project_id
before_filter :authorize before_filter :authorize
+20 -27
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -48,11 +48,7 @@ class ProjectsController < ApplicationController
def index def index
respond_to do |format| respond_to do |format|
format.html { format.html {
scope = Project @projects = Project.visible.find(:all, :order => 'lft')
unless params[:closed]
scope = scope.active
end
@projects = scope.visible.order('lft').all
} }
format.api { format.api {
@offset, @limit = api_offset_and_limit @offset, @limit = api_offset_and_limit
@@ -69,14 +65,14 @@ class ProjectsController < ApplicationController
def new def new
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
@trackers = Tracker.sorted.all @trackers = Tracker.all
@project = Project.new @project = Project.new
@project.safe_attributes = params[:project] @project.safe_attributes = params[:project]
end end
def create def create
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
@trackers = Tracker.sorted.all @trackers = Tracker.all
@project = Project.new @project = Project.new
@project.safe_attributes = params[:project] @project.safe_attributes = params[:project]
@@ -109,14 +105,18 @@ class ProjectsController < ApplicationController
def copy def copy
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
@trackers = Tracker.sorted.all @trackers = Tracker.all
@root_projects = Project.find(:all, @root_projects = Project.find(:all,
:conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}", :conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
:order => 'name') :order => 'name')
@source_project = Project.find(params[:id]) @source_project = Project.find(params[:id])
if request.get? if request.get?
@project = Project.copy_from(@source_project) @project = Project.copy_from(@source_project)
@project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? if @project
@project.identifier = Project.next_identifier if Setting.sequential_project_identifiers?
else
redirect_to :controller => 'admin', :action => 'projects'
end
else else
Mailer.with_deliveries(params[:notifications] == '1') do Mailer.with_deliveries(params[:notifications] == '1') do
@project = Project.new @project = Project.new
@@ -135,8 +135,7 @@ class ProjectsController < ApplicationController
end end
end end
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
# source_project not found redirect_to :controller => 'admin', :action => 'projects'
render_404
end end
# Show @project # Show @project
@@ -153,8 +152,12 @@ class ProjectsController < ApplicationController
cond = @project.project_condition(Setting.display_subprojects_issues?) cond = @project.project_condition(Setting.display_subprojects_issues?)
@open_issues_by_tracker = Issue.visible.open.where(cond).count(:group => :tracker) @open_issues_by_tracker = Issue.visible.count(:group => :tracker,
@total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker) :include => [:project, :status, :tracker],
:conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false])
@total_issues_by_tracker = Issue.visible.count(:group => :tracker,
:include => [:project, :status, :tracker],
:conditions => cond)
if User.current.allowed_to?(:view_time_entries, @project) if User.current.allowed_to?(:view_time_entries, @project)
@total_hours = TimeEntry.visible.sum(:hours, :include => :project, :conditions => cond).to_f @total_hours = TimeEntry.visible.sum(:hours, :include => :project, :conditions => cond).to_f
@@ -172,7 +175,7 @@ class ProjectsController < ApplicationController
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
@issue_category ||= IssueCategory.new @issue_category ||= IssueCategory.new
@member ||= @project.members.new @member ||= @project.members.new
@trackers = Tracker.sorted.all @trackers = Tracker.all
@wiki ||= @project.wiki @wiki ||= @project.wiki
end end
@@ -188,7 +191,7 @@ class ProjectsController < ApplicationController
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'settings', :id => @project redirect_to :action => 'settings', :id => @project
} }
format.api { render_api_ok } format.api { head :ok }
end end
else else
respond_to do |format| respond_to do |format|
@@ -221,16 +224,6 @@ class ProjectsController < ApplicationController
redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status]))
end end
def close
@project.close
redirect_to project_path(@project)
end
def reopen
@project.reopen
redirect_to project_path(@project)
end
# Delete @project # Delete @project
def destroy def destroy
@project_to_destroy = @project @project_to_destroy = @project
@@ -238,7 +231,7 @@ class ProjectsController < ApplicationController
@project_to_destroy.destroy @project_to_destroy.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'admin', :action => 'projects' } format.html { redirect_to :controller => 'admin', :action => 'projects' }
format.api { render_api_ok } format.api { head :ok }
end end
end end
# hide project in layout # hide project in layout
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+3 -3
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -22,7 +22,7 @@ class ReportsController < ApplicationController
def issue_report def issue_report
@trackers = @project.trackers @trackers = @project.trackers
@versions = @project.shared_versions.sort @versions = @project.shared_versions.sort
@priorities = IssuePriority.all.reverse @priorities = IssuePriority.all
@categories = @project.issue_categories @categories = @project.issue_categories
@assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort
@authors = @project.users.sort @authors = @project.users.sort
@@ -53,7 +53,7 @@ class ReportsController < ApplicationController
@report_title = l(:field_version) @report_title = l(:field_version)
when "priority" when "priority"
@field = "priority_id" @field = "priority_id"
@rows = IssuePriority.all.reverse @rows = IssuePriority.all
@data = Issue.by_priority(@project) @data = Issue.by_priority(@project)
@report_title = l(:field_priority) @report_title = l(:field_priority)
when "category" when "category"
+40 -47
View File
@@ -18,7 +18,6 @@
require 'SVG/Graph/Bar' require 'SVG/Graph/Bar'
require 'SVG/Graph/BarHorizontal' require 'SVG/Graph/BarHorizontal'
require 'digest/sha1' require 'digest/sha1'
require 'redmine/scm/adapters/abstract_adapter'
class ChangesetNotFound < Exception; end class ChangesetNotFound < Exception; end
class InvalidRevisionParam < Exception; end class InvalidRevisionParam < Exception; end
@@ -42,15 +41,11 @@ class RepositoriesController < ApplicationController
@repository = Repository.factory(scm) @repository = Repository.factory(scm)
@repository.is_default = @project.repository.nil? @repository.is_default = @project.repository.nil?
@repository.project = @project @repository.project = @project
render :layout => !request.xhr?
end end
def create def create
attrs = pickup_extra_info @repository = Repository.factory(params[:repository_scm], params[:repository])
@repository = Repository.factory(params[:repository_scm])
@repository.safe_attributes = params[:repository]
if attrs[:attrs_extra].keys.any?
@repository.merge_extra_info(attrs[:attrs_extra])
end
@repository.project = @project @repository.project = @project
if request.post? && @repository.save if request.post? && @repository.save
redirect_to settings_project_path(@project, :tab => 'repositories') redirect_to settings_project_path(@project, :tab => 'repositories')
@@ -63,11 +58,7 @@ class RepositoriesController < ApplicationController
end end
def update def update
attrs = pickup_extra_info @repository.attributes = params[:repository]
@repository.safe_attributes = attrs[:attrs]
if attrs[:attrs_extra].keys.any?
@repository.merge_extra_info(attrs[:attrs_extra])
end
@repository.project = @project @repository.project = @project
if request.put? && @repository.save if request.put? && @repository.save
redirect_to settings_project_path(@project, :tab => 'repositories') redirect_to settings_project_path(@project, :tab => 'repositories')
@@ -76,20 +67,6 @@ class RepositoriesController < ApplicationController
end end
end end
def pickup_extra_info
p = {}
p_extra = {}
params[:repository].each do |k, v|
if k =~ /^extra_/
p_extra[k] = v
else
p[k] = v
end
end
{:attrs => p, :attrs_extra => p_extra}
end
private :pickup_extra_info
def committers def committers
@committers = @repository.committers @committers = @repository.committers
@users = @project.users @users = @project.users
@@ -152,15 +129,7 @@ class RepositoriesController < ApplicationController
end end
end end
def raw
entry_and_raw(true)
end
def entry def entry
entry_and_raw(false)
end
def entry_and_raw(is_raw)
@entry = @repository.entry(@path, @rev) @entry = @repository.entry(@path, @rev)
(show_error_not_found; return) unless @entry (show_error_not_found; return) unless @entry
@@ -169,14 +138,13 @@ class RepositoriesController < ApplicationController
@content = @repository.cat(@path, @rev) @content = @repository.cat(@path, @rev)
(show_error_not_found; return) unless @content (show_error_not_found; return) unless @content
if is_raw || if 'raw' == params[:format] ||
(@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
! is_entry_text_data?(@content, @path) ! is_entry_text_data?(@content, @path)
# Force the download # Force the download
send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) } send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
send_type = Redmine::MimeType.of(@path) send_type = Redmine::MimeType.of(@path)
send_opt[:type] = send_type.to_s if send_type send_opt[:type] = send_type.to_s if send_type
send_opt[:disposition] = (Redmine::MimeType.is_type?('image', @path) && !is_raw ? 'inline' : 'attachment')
send_data @content, send_opt send_data @content, send_opt
else else
# Prevent empty lines when displaying a file with Windows style eol # Prevent empty lines when displaying a file with Windows style eol
@@ -186,7 +154,6 @@ class RepositoriesController < ApplicationController
@changeset = @repository.find_changeset_by_name(@rev) @changeset = @repository.find_changeset_by_name(@rev)
end end
end end
private :entry_and_raw
def is_entry_text_data?(ent, path) def is_entry_text_data?(ent, path)
# UTF-16 contains "\x00". # UTF-16 contains "\x00".
@@ -235,6 +202,22 @@ class RepositoriesController < ApplicationController
if @issue if @issue
@changeset.issues << @issue @changeset.issues << @issue
respond_to do |format|
format.js {
render :update do |page|
page.replace_html "related-issues", :partial => "related_issues"
page.visual_effect :highlight, "related-issue-#{@issue.id}"
end
}
end
else
respond_to do |format|
format.js {
render :update do |page|
page.alert(l(:label_issue) + ' ' + l('activerecord.errors.messages.invalid'))
end
}
end
end end
end end
@@ -245,6 +228,14 @@ class RepositoriesController < ApplicationController
if @issue if @issue
@changeset.issues.delete(@issue) @changeset.issues.delete(@issue)
end end
respond_to do |format|
format.js {
render :update do |page|
page.remove "related-issue-#{@issue.id}"
end if @issue
}
end
end end
def diff def diff
@@ -316,7 +307,8 @@ class RepositoriesController < ApplicationController
@repository = @project.repository @repository = @project.repository
end end
(render_404; return false) unless @repository (render_404; return false) unless @repository
@path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s @path = params[:path].join('/') unless params[:path].nil?
@path ||= ''
@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip
@rev_to = params[:rev_to] @rev_to = params[:rev_to]
@@ -351,17 +343,17 @@ class RepositoriesController < ApplicationController
@date_to = Date.today @date_to = Date.today
@date_from = @date_to << 11 @date_from = @date_to << 11
@date_from = Date.civil(@date_from.year, @date_from.month, 1) @date_from = Date.civil(@date_from.year, @date_from.month, 1)
commits_by_day = Changeset.count( commits_by_day = repository.changesets.count(
:all, :group => :commit_date, :all, :group => :commit_date,
:conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
commits_by_month = [0] * 12 commits_by_month = [0] * 12
commits_by_day.each {|c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last } commits_by_day.each {|c| commits_by_month[c.first.to_date.months_ago] += c.last }
changes_by_day = Change.count( changes_by_day = repository.changes.count(
:all, :group => :commit_date, :include => :changeset, :all, :group => :commit_date,
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
changes_by_month = [0] * 12 changes_by_month = [0] * 12
changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last } changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last }
fields = [] fields = []
12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)} 12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)}
@@ -392,10 +384,10 @@ class RepositoriesController < ApplicationController
end end
def graph_commits_per_author(repository) def graph_commits_per_author(repository)
commits_by_author = Changeset.count(:all, :group => :committer, :conditions => ["repository_id = ?", repository.id]) commits_by_author = repository.changesets.count(:all, :group => :committer)
commits_by_author.to_a.sort! {|x, y| x.last <=> y.last} commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}
changes_by_author = Change.count(:all, :group => :committer, :include => :changeset, :conditions => ["#{Changeset.table_name}.repository_id = ?", repository.id]) changes_by_author = repository.changes.count(:all, :group => :committer)
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o} h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
fields = commits_by_author.collect {|r| r.first} fields = commits_by_author.collect {|r| r.first}
@@ -431,3 +423,4 @@ class RepositoriesController < ApplicationController
graph.burn graph.burn
end end
end end
+7 -16
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -18,10 +18,10 @@
class RolesController < ApplicationController class RolesController < ApplicationController
layout 'admin' layout 'admin'
before_filter :require_admin, :except => [:index, :show] before_filter :require_admin, :except => :index
before_filter :require_admin_or_api_request, :only => [:index, :show] before_filter :require_admin_or_api_request, :only => :index
before_filter :find_role, :only => [:show, :edit, :update, :destroy] before_filter :find_role, :only => [:edit, :update, :destroy]
accept_api_auth :index, :show accept_api_auth :index
def index def index
respond_to do |format| respond_to do |format|
@@ -35,18 +35,9 @@ class RolesController < ApplicationController
end end
end end
def show
respond_to do |format|
format.api
end
end
def new def new
# Prefills the form with 'Non member' role permissions by default # Prefills the form with 'Non member' role permissions
@role = Role.new(params[:role] || {:permissions => Role.non_member.permissions}) @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions})
if params[:copy].present? && @copy_from = Role.find_by_id(params[:copy])
@role.copy_from(@copy_from)
end
@roles = Role.sorted.all @roles = Role.sorted.all
end end
@@ -55,7 +46,7 @@ class RolesController < ApplicationController
if request.post? && @role.save if request.post? && @role.save
# workflow copy # workflow copy
if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from])) if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
@role.workflow_rules.copy(copy_from) @role.workflows.copy(copy_from)
end end
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index' redirect_to :action => 'index'
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+2 -3
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -39,8 +39,7 @@ class SettingsController < ApplicationController
redirect_to :action => 'edit', :tab => params[:tab] redirect_to :action => 'edit', :tab => params[:tab]
else else
@options = {} @options = {}
user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]} @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
@options[:user_format] = user_format.collect{|f| [User.current.name(f[0]), f[0].to_s]}
@deliveries = ActionMailer::Base.perform_deliveries @deliveries = ActionMailer::Base.perform_deliveries
@guessed_host_and_path = request.host_with_port.dup @guessed_host_and_path = request.host_with_port.dup
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+3 -6
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -171,7 +171,7 @@ class TimelogController < ApplicationController
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_back_or_default :action => 'index', :project_id => @time_entry.project redirect_back_or_default :action => 'index', :project_id => @time_entry.project
} }
format.api { render_api_ok } format.api { head :ok }
end end
else else
respond_to do |format| respond_to do |format|
@@ -223,7 +223,7 @@ class TimelogController < ApplicationController
} }
format.api { format.api {
if destroyed if destroyed
render_api_ok head :ok
else else
render_validation_errors(@time_entries) render_validation_errors(@time_entries)
end end
@@ -308,9 +308,6 @@ private
when 'last_week' when 'last_week'
@from = Date.today - 7 - (Date.today.cwday - 1)%7 @from = Date.today - 7 - (Date.today.cwday - 1)%7
@to = @from + 6 @to = @from + 6
when 'last_2_weeks'
@from = Date.today - 14 - (Date.today.cwday - 1)%7
@to = @from + 13
when '7_days' when '7_days'
@from = Date.today - 7 @from = Date.today - 7
@to = Date.today @to = Date.today
+3 -21
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -29,7 +29,7 @@ class TrackersController < ApplicationController
render :action => "index", :layout => false if request.xhr? render :action => "index", :layout => false if request.xhr?
} }
format.api { format.api {
@trackers = Tracker.sorted.all @trackers = Tracker.all
} }
end end
end end
@@ -45,7 +45,7 @@ class TrackersController < ApplicationController
if request.post? and @tracker.save if request.post? and @tracker.save
# workflow copy # workflow copy
if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from])) if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
@tracker.workflow_rules.copy(copy_from) @tracker.workflows.copy(copy_from)
end end
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index' redirect_to :action => 'index'
@@ -80,22 +80,4 @@ class TrackersController < ApplicationController
end end
redirect_to :action => 'index' redirect_to :action => 'index'
end end
def fields
if request.post? && params[:trackers]
params[:trackers].each do |tracker_id, tracker_params|
tracker = Tracker.find_by_id(tracker_id)
if tracker
tracker.core_fields = tracker_params[:core_fields]
tracker.custom_field_ids = tracker_params[:custom_field_ids]
tracker.save
end
end
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'fields'
return
end
@trackers = Tracker.sorted.all
@custom_fields = IssueCustomField.all.sort
end
end end
+29 -12
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -99,11 +99,11 @@ class UsersController < ApplicationController
@user.pref.save @user.pref.save
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
Mailer.account_information(@user, params[:user][:password]).deliver if params[:send_information] Mailer.deliver_account_information(@user, params[:user][:password]) if params[:send_information]
respond_to do |format| respond_to do |format|
format.html { format.html {
flash[:notice] = l(:notice_user_successful_create, :id => view_context.link_to(@user.login, user_path(@user))) flash[:notice] = l(:notice_successful_create)
redirect_to(params[:continue] ? redirect_to(params[:continue] ?
{:controller => 'users', :action => 'new'} : {:controller => 'users', :action => 'new'} :
{:controller => 'users', :action => 'edit', :id => @user} {:controller => 'users', :action => 'edit', :id => @user}
@@ -146,17 +146,17 @@ class UsersController < ApplicationController
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
if was_activated if was_activated
Mailer.account_activated(@user).deliver Mailer.deliver_account_activated(@user)
elsif @user.active? && params[:send_information] && !params[:user][:password].blank? && @user.auth_source_id.nil? elsif @user.active? && params[:send_information] && !params[:user][:password].blank? && @user.auth_source_id.nil?
Mailer.account_information(@user, params[:user][:password]).deliver Mailer.deliver_account_information(@user, params[:user][:password])
end end
respond_to do |format| respond_to do |format|
format.html { format.html {
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to_referer_or edit_user_path(@user) redirect_to :back
} }
format.api { render_api_ok } format.api { head :ok }
end end
else else
@auth_sources = AuthSource.find(:all) @auth_sources = AuthSource.find(:all)
@@ -169,22 +169,39 @@ class UsersController < ApplicationController
format.api { render_validation_errors(@user) } format.api { render_validation_errors(@user) }
end end
end end
rescue ::ActionController::RedirectBackError
redirect_to :controller => 'users', :action => 'edit', :id => @user
end end
def destroy def destroy
@user.destroy @user.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_default(users_url) } format.html { redirect_to :back }
format.api { render_api_ok } format.api { head :ok }
end end
rescue ::ActionController::RedirectBackError
redirect_to(users_url)
end end
def edit_membership def edit_membership
@membership = Member.edit_membership(params[:membership_id], params[:membership], @user) @membership = Member.edit_membership(params[:membership_id], params[:membership], @user)
@membership.save @membership.save
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' } if @membership.valid?
format.js format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
format.js {
render(:update) {|page|
page.replace_html "tab-content-memberships", :partial => 'users/memberships'
page.visual_effect(:highlight, "member-#{@membership.id}")
}
}
else
format.js {
render(:update) {|page|
page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
}
}
end
end end
end end
@@ -195,7 +212,7 @@ class UsersController < ApplicationController
end end
respond_to do |format| respond_to do |format|
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' } format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
format.js format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'users/memberships'} }
end end
end end
+33 -9
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -20,7 +20,7 @@ class VersionsController < ApplicationController
model_object Version model_object Version
before_filter :find_model_object, :except => [:index, :new, :create, :close_completed] before_filter :find_model_object, :except => [:index, :new, :create, :close_completed]
before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed] before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed]
before_filter :find_project_by_project_id, :only => [:index, :new, :create, :close_completed] before_filter :find_project, :only => [:index, :new, :create, :close_completed]
before_filter :authorize before_filter :authorize
accept_api_auth :index, :show, :create, :update, :destroy accept_api_auth :index, :show, :create, :update, :destroy
@@ -78,7 +78,13 @@ class VersionsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html format.html
format.js format.js do
render :update do |page|
page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
page << "showModal('ajax-modal', '600px');"
page << "Form.Element.focus('version_name');"
end
end
end end
end end
@@ -97,7 +103,14 @@ class VersionsController < ApplicationController
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
end end
format.js format.js do
render(:update) {|page|
page << 'hideModal();'
# IE doesn't support the replace_html rjs method for select box options
page.replace "issue_fixed_version_id",
content_tag('select', content_tag('option') + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]')
}
end
format.api do format.api do
render :action => 'show', :status => :created, :location => version_url(@version) render :action => 'show', :status => :created, :location => version_url(@version)
end end
@@ -105,7 +118,12 @@ class VersionsController < ApplicationController
else else
respond_to do |format| respond_to do |format|
format.html { render :action => 'new' } format.html { render :action => 'new' }
format.js { render :action => 'new' } format.js do
render :update do |page|
page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
page << "Form.Element.focus('version_name');"
end
end
format.api { render_validation_errors(@version) } format.api { render_validation_errors(@version) }
end end
end end
@@ -126,7 +144,7 @@ class VersionsController < ApplicationController
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
} }
format.api { render_api_ok } format.api { head :ok }
end end
else else
respond_to do |format| respond_to do |format|
@@ -149,7 +167,7 @@ class VersionsController < ApplicationController
@version.destroy @version.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project } format.html { redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project }
format.api { render_api_ok } format.api { head :ok }
end end
else else
respond_to do |format| respond_to do |format|
@@ -165,11 +183,16 @@ class VersionsController < ApplicationController
def status_by def status_by
respond_to do |format| respond_to do |format|
format.html { render :action => 'show' } format.html { render :action => 'show' }
format.js format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} }
end end
end end
private private
def find_project
@project = Project.find(params[:project_id])
rescue ActiveRecord::RecordNotFound
render_404
end
def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil) def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil)
if ids = params[:tracker_ids] if ids = params[:tracker_ids]
@@ -178,4 +201,5 @@ class VersionsController < ApplicationController
@selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s } @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s }
end end
end end
end end
+49 -8
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -33,6 +33,15 @@ class WatchersController < ApplicationController
end end
def new def new
respond_to do |format|
format.js do
render :update do |page|
page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched}
page << "showModal('ajax-modal', '400px');"
page << "$('ajax-modal').addClassName('new-watcher');"
end
end
end
end end
def create def create
@@ -43,15 +52,34 @@ class WatchersController < ApplicationController
end end
end end
respond_to do |format| respond_to do |format|
format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}} format.html { redirect_to :back }
format.js format.js do
render :update do |page|
page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched}
page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
end
end
end end
rescue ::ActionController::RedirectBackError
render :text => 'Watcher added.', :layout => true
end end
def append def append
if params[:watcher].is_a?(Hash) if params[:watcher].is_a?(Hash)
user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]] user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]]
@users = User.active.find_all_by_id(user_ids) users = User.active.find_all_by_id(user_ids)
respond_to do |format|
format.js do
render :update do |page|
users.each do |user|
page.select("#issue_watcher_user_ids_#{user.id}").each do |item|
page.remove item
end
end
page.insert_html :bottom, 'watchers_inputs', :text => watchers_checkboxes(nil, users, true)
end
end
end
end end
end end
@@ -59,7 +87,11 @@ class WatchersController < ApplicationController
@watched.set_watcher(User.find(params[:user_id]), false) if request.post? @watched.set_watcher(User.find(params[:user_id]), false) if request.post?
respond_to do |format| respond_to do |format|
format.html { redirect_to :back } format.html { redirect_to :back }
format.js format.js do
render :update do |page|
page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
end
end
end end
end end
@@ -79,7 +111,7 @@ private
@watched = klass.find(params[:object_id]) @watched = klass.find(params[:object_id])
@project = @watched.project @project = @watched.project
elsif params[:project_id] elsif params[:project_id]
@project = Project.visible.find_by_param(params[:project_id]) @project = Project.visible.find(params[:project_id])
end end
rescue rescue
render_404 render_404
@@ -88,8 +120,17 @@ private
def set_watcher(user, watching) def set_watcher(user, watching)
@watched.set_watcher(user, watching) @watched.set_watcher(user, watching)
respond_to do |format| respond_to do |format|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} format.html { redirect_to :back }
format.js { render :partial => 'set_watcher', :locals => {:user => user, :watched => @watched} } format.js do
render(:update) do |page|
c = watcher_css(@watched)
page.select(".#{c}").each do |item|
page.replace_html item, watcher_link(@watched, user)
end
end
end
end end
rescue ::ActionController::RedirectBackError
render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true
end end
end end
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+34 -72
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -35,8 +35,7 @@ class WikiController < ApplicationController
default_search_scope :wiki_pages default_search_scope :wiki_pages
before_filter :find_wiki, :authorize before_filter :find_wiki, :authorize
before_filter :find_existing_or_new_page, :only => [:show, :edit, :update] before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy, :destroy_version] before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
accept_api_auth :index, :show, :update, :destroy
helper :attachments helper :attachments
include AttachmentsHelper include AttachmentsHelper
@@ -46,13 +45,7 @@ class WikiController < ApplicationController
# List of pages, sorted alphabetically and by parent (hierarchy) # List of pages, sorted alphabetically and by parent (hierarchy)
def index def index
load_pages_for_index load_pages_for_index
@pages_by_parent_id = @pages.group_by(&:parent_id)
respond_to do |format|
format.html {
@pages_by_parent_id = @pages.group_by(&:parent_id)
}
format.api
end
end end
# List of page, by last update # List of page, by last update
@@ -64,7 +57,7 @@ class WikiController < ApplicationController
# display a page (in editing mode if it doesn't exist) # display a page (in editing mode if it doesn't exist)
def show def show
if @page.new_record? if @page.new_record?
if User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request? if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
edit edit
render :action => 'edit' render :action => 'edit'
else else
@@ -73,7 +66,8 @@ class WikiController < ApplicationController
return return
end end
if params[:version] && !User.current.allowed_to?(:view_wiki_edits, @project) if params[:version] && !User.current.allowed_to?(:view_wiki_edits, @project)
deny_access # Redirects user to the current version if he's not allowed to view previous versions
redirect_to :version => nil
return return
end end
@content = @page.content_for_version(params[:version]) @content = @page.content_for_version(params[:version])
@@ -95,10 +89,7 @@ class WikiController < ApplicationController
@content.current_version? && @content.current_version? &&
Redmine::WikiFormatting.supports_section_edit? Redmine::WikiFormatting.supports_section_edit?
respond_to do |format| render :action => 'show'
format.html
format.api
end
end end
# edit an existing page or a new one # edit an existing page or a new one
@@ -130,65 +121,48 @@ class WikiController < ApplicationController
# Creates a new page or updates an existing one # Creates a new page or updates an existing one
def update def update
return render_403 unless editable? return render_403 unless editable?
was_new_page = @page.new_record?
@page.content = WikiContent.new(:page => @page) if @page.new_record? @page.content = WikiContent.new(:page => @page) if @page.new_record?
@page.safe_attributes = params[:wiki_page] @page.safe_attributes = params[:wiki_page]
@content = @page.content @content = @page.content_for_version(params[:version])
content_params = params[:content] @content.text = initial_page_content(@page) if @content.text.blank?
if content_params.nil? && params[:wiki_page].is_a?(Hash) # don't keep previous comment
content_params = params[:wiki_page].slice(:text, :comments, :version) @content.comments = nil
end
content_params ||= {}
@content.comments = content_params[:comments] if !@page.new_record? && params[:content].present? && @content.text == params[:content][:text]
@text = content_params[:text] attachments = Attachment.attach_files(@page, params[:attachments])
render_attachment_warning_if_needed(@page)
# don't save content if text wasn't changed
@page.save
redirect_to :action => 'show', :project_id => @project, :id => @page.title
return
end
@content.comments = params[:content][:comments]
@text = params[:content][:text]
if params[:section].present? && Redmine::WikiFormatting.supports_section_edit? if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
@section = params[:section].to_i @section = params[:section].to_i
@section_hash = params[:section_hash] @section_hash = params[:section_hash]
@content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(params[:section].to_i, @text, @section_hash) @content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(params[:section].to_i, @text, @section_hash)
else else
@content.version = content_params[:version] if content_params[:version] @content.version = params[:content][:version]
@content.text = @text @content.text = @text
end end
@content.author = User.current @content.author = User.current
@page.content = @content
if @page.save_with_content if @page.save
attachments = Attachment.attach_files(@page, params[:attachments]) attachments = Attachment.attach_files(@page, params[:attachments])
render_attachment_warning_if_needed(@page) render_attachment_warning_if_needed(@page)
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page}) call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
redirect_to :action => 'show', :project_id => @project, :id => @page.title
respond_to do |format|
format.html { redirect_to :action => 'show', :project_id => @project, :id => @page.title }
format.api {
if was_new_page
render :action => 'show', :status => :created, :location => url_for(:controller => 'wiki', :action => 'show', :project_id => @project, :id => @page.title)
else
render_api_ok
end
}
end
else else
respond_to do |format| render :action => 'edit'
format.html { render :action => 'edit' }
format.api { render_validation_errors(@content) }
end
end end
rescue ActiveRecord::StaleObjectError, Redmine::WikiFormatting::StaleSectionError rescue ActiveRecord::StaleObjectError, Redmine::WikiFormatting::StaleSectionError
# Optimistic locking exception # Optimistic locking exception
respond_to do |format| flash.now[:error] = l(:notice_locking_conflict)
format.html { render :action => 'edit'
flash.now[:error] = l(:notice_locking_conflict)
render :action => 'edit'
}
format.api { render_api_head :conflict }
end
rescue ActiveRecord::RecordNotSaved
respond_to do |format|
format.html { render :action => 'edit' }
format.api { render_validation_errors(@content) }
end
end end
# rename a page # rename a page
@@ -211,7 +185,7 @@ class WikiController < ApplicationController
# show page history # show page history
def history def history
@version_count = @page.content.versions.count @version_count = @page.content.versions.count
@version_pages = Paginator.new self, @version_count, per_page_option, params['page'] @version_pages = Paginator.new self, @version_count, per_page_option, params['p']
# don't load text # don't load text
@versions = @page.content.versions.find :all, @versions = @page.content.versions.find :all,
:select => "id, author_id, comments, updated_on, version", :select => "id, author_id, comments, updated_on, version",
@@ -254,28 +228,16 @@ class WikiController < ApplicationController
end end
else else
@reassignable_to = @wiki.pages - @page.self_and_descendants @reassignable_to = @wiki.pages - @page.self_and_descendants
# display the destroy form if it's a user request return
return unless api_request?
end end
end end
@page.destroy @page.destroy
respond_to do |format| redirect_to :action => 'index', :project_id => @project
format.html { redirect_to :action => 'index', :project_id => @project }
format.api { render_api_ok }
end
end
def destroy_version
return render_403 unless editable?
@content = @page.content_for_version(params[:version])
@content.destroy
redirect_to_referer_or :action => 'history', :id => @page.title, :project_id => @project
end end
# Export wiki to a single pdf or html file # Export wiki to a single pdf or html file
def export def export
@pages = @wiki.pages.all(:order => 'title', :include => [:content, {:attachments => :author}]) @pages = @wiki.pages.all(:order => 'title', :include => [:content, :attachments], :limit => 75)
respond_to do |format| respond_to do |format|
format.html { format.html {
export = render_to_string :action => 'export_multiple', :layout => false export = render_to_string :action => 'export_multiple', :layout => false
@@ -349,6 +311,6 @@ private
end end
def load_pages_for_index def load_pages_for_index
@pages = @wiki.pages.with_updated_on.order("#{WikiPage.table_name}.title").includes(:wiki => :project).includes(:parent).all @pages = @wiki.pages.with_updated_on.all(:order => 'title', :include => {:wiki => :project})
end end
end end
+2 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -24,6 +24,7 @@ class WikisController < ApplicationController
@wiki = @project.wiki || Wiki.new(:project => @project) @wiki = @project.wiki || Wiki.new(:project => @project)
@wiki.safe_attributes = params[:wiki] @wiki.safe_attributes = params[:wiki]
@wiki.save if request.post? @wiki.save if request.post?
render(:update) {|page| page.replace_html "tab-content-wiki", :partial => 'projects/settings/wiki'}
end end
# Delete a project's wiki # Delete a project's wiki
+16 -42
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -18,27 +18,30 @@
class WorkflowsController < ApplicationController class WorkflowsController < ApplicationController
layout 'admin' layout 'admin'
before_filter :require_admin, :find_roles, :find_trackers before_filter :require_admin
before_filter :find_roles
before_filter :find_trackers
def index def index
@workflow_counts = WorkflowTransition.count_by_tracker_and_role @workflow_counts = Workflow.count_by_tracker_and_role
end end
def edit def edit
@role = Role.find_by_id(params[:role_id]) if params[:role_id] @role = Role.find_by_id(params[:role_id])
@tracker = Tracker.find_by_id(params[:tracker_id]) if params[:tracker_id] @tracker = Tracker.find_by_id(params[:tracker_id])
if request.post? if request.post?
WorkflowTransition.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id]) Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
(params[:issue_status] || []).each { |status_id, transitions| (params[:issue_status] || []).each { |status_id, transitions|
transitions.each { |new_status_id, options| transitions.each { |new_status_id, options|
author = options.is_a?(Array) && options.include?('author') && !options.include?('always') author = options.is_a?(Array) && options.include?('author') && !options.include?('always')
assignee = options.is_a?(Array) && options.include?('assignee') && !options.include?('always') assignee = options.is_a?(Array) && options.include?('assignee') && !options.include?('always')
WorkflowTransition.create(:role_id => @role.id, :tracker_id => @tracker.id, :old_status_id => status_id, :new_status_id => new_status_id, :author => author, :assignee => assignee) @role.workflows.build(:tracker_id => @tracker.id, :old_status_id => status_id, :new_status_id => new_status_id, :author => author, :assignee => assignee)
} }
} }
if @role.save if @role.save
redirect_to :action => 'edit', :role_id => @role, :tracker_id => @tracker, :used_statuses_only => params[:used_statuses_only] flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'edit', :role_id => @role, :tracker_id => @tracker
return return
end end
end end
@@ -47,10 +50,10 @@ class WorkflowsController < ApplicationController
if @tracker && @used_statuses_only && @tracker.issue_statuses.any? if @tracker && @used_statuses_only && @tracker.issue_statuses.any?
@statuses = @tracker.issue_statuses @statuses = @tracker.issue_statuses
end end
@statuses ||= IssueStatus.sorted.all @statuses ||= IssueStatus.find(:all, :order => 'position')
if @tracker && @role && @statuses.any? if @tracker && @role && @statuses.any?
workflows = WorkflowTransition.where(:role_id => @role.id, :tracker_id => @tracker.id).all workflows = Workflow.all(:conditions => {:role_id => @role.id, :tracker_id => @tracker.id})
@workflows = {} @workflows = {}
@workflows['always'] = workflows.select {|w| !w.author && !w.assignee} @workflows['always'] = workflows.select {|w| !w.author && !w.assignee}
@workflows['author'] = workflows.select {|w| w.author} @workflows['author'] = workflows.select {|w| w.author}
@@ -58,35 +61,6 @@ class WorkflowsController < ApplicationController
end end
end end
def permissions
@role = Role.find_by_id(params[:role_id]) if params[:role_id]
@tracker = Tracker.find_by_id(params[:tracker_id]) if params[:tracker_id]
if request.post? && @role && @tracker
WorkflowPermission.replace_permissions(@tracker, @role, params[:permissions] || {})
redirect_to :action => 'permissions', :role_id => @role, :tracker_id => @tracker, :used_statuses_only => params[:used_statuses_only]
return
end
@used_statuses_only = (params[:used_statuses_only] == '0' ? false : true)
if @tracker && @used_statuses_only && @tracker.issue_statuses.any?
@statuses = @tracker.issue_statuses
end
@statuses ||= IssueStatus.sorted.all
if @role && @tracker
@fields = (Tracker::CORE_FIELDS_ALL - @tracker.disabled_core_fields).map {|field| [field, l("field_"+field.sub(/_id$/, ''))]}
@custom_fields = @tracker.custom_fields
@permissions = WorkflowPermission.where(:tracker_id => @tracker.id, :role_id => @role.id).all.inject({}) do |h, w|
h[w.old_status_id] ||= {}
h[w.old_status_id][w.field_name] = w.rule
h
end
@statuses.each {|status| @permissions[status.id] ||= {}}
end
end
def copy def copy
if params[:source_tracker_id].blank? || params[:source_tracker_id] == 'any' if params[:source_tracker_id].blank? || params[:source_tracker_id] == 'any'
@@ -109,7 +83,7 @@ class WorkflowsController < ApplicationController
elsif @target_trackers.nil? || @target_roles.nil? elsif @target_trackers.nil? || @target_roles.nil?
flash.now[:error] = l(:error_workflow_copy_target) flash.now[:error] = l(:error_workflow_copy_target)
else else
WorkflowRule.copy(@source_tracker, @source_role, @target_trackers, @target_roles) Workflow.copy(@source_tracker, @source_role, @target_trackers, @target_roles)
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'copy', :source_tracker_id => @source_tracker, :source_role_id => @source_role redirect_to :action => 'copy', :source_tracker_id => @source_tracker, :source_role_id => @source_role
end end
@@ -119,10 +93,10 @@ class WorkflowsController < ApplicationController
private private
def find_roles def find_roles
@roles = Role.sorted.all @roles = Role.find(:all, :order => 'builtin, position')
end end
def find_trackers def find_trackers
@trackers = Tracker.sorted.all @trackers = Tracker.find(:all, :order => 'position')
end end
end end
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+2 -4
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -20,8 +20,6 @@
module AdminHelper module AdminHelper
def project_status_options_for_select(selected) def project_status_options_for_select(selected)
options_for_select([[l(:label_all), ''], options_for_select([[l(:label_all), ''],
[l(:project_status_active), '1'], [l(:status_active), '1']], selected.to_s)
[l(:project_status_closed), '5'],
[l(:project_status_archived), '9']], selected.to_s)
end end
end end
+132 -287
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -43,12 +43,18 @@ module ApplicationHelper
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action]) link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
end end
# Display a link to remote if user is authorized
def link_to_remote_if_authorized(name, options = {}, html_options = nil)
url = options[:url] || {}
link_to_remote(name, options, html_options) if authorize_for(url[:controller] || params[:controller], url[:action])
end
# Displays a link to user's account page if active # Displays a link to user's account page if active
def link_to_user(user, options={}) def link_to_user(user, options={})
if user.is_a?(User) if user.is_a?(User)
name = h(user.name(options[:format])) name = h(user.name(options[:format]))
if user.active? || (User.current.admin? && user.logged?) if user.active?
link_to name, user_path(user), :class => user.css_classes link_to name, :controller => 'users', :action => 'show', :id => user
else else
name name
end end
@@ -64,12 +70,10 @@ module ApplicationHelper
# link_to_issue(issue, :truncate => 6) # => Defect #6: This i... # link_to_issue(issue, :truncate => 6) # => Defect #6: This i...
# link_to_issue(issue, :subject => false) # => Defect #6 # link_to_issue(issue, :subject => false) # => Defect #6
# link_to_issue(issue, :project => true) # => Foo - Defect #6 # link_to_issue(issue, :project => true) # => Foo - Defect #6
# link_to_issue(issue, :subject => false, :tracker => false) # => #6
# #
def link_to_issue(issue, options={}) def link_to_issue(issue, options={})
title = nil title = nil
subject = nil subject = nil
text = options[:tracker] == false ? "##{issue.id}" : "#{issue.tracker} ##{issue.id}"
if options[:subject] == false if options[:subject] == false
title = truncate(issue.subject, :length => 60) title = truncate(issue.subject, :length => 60)
else else
@@ -78,7 +82,9 @@ module ApplicationHelper
subject = truncate(subject, :length => options[:truncate]) subject = truncate(subject, :length => options[:truncate])
end end
end end
s = link_to text, issue_path(issue), :class => issue.css_classes, :title => title s = link_to "#{h(issue.tracker)} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue},
:class => issue.css_classes,
:title => title
s << h(": #{subject}") if subject s << h(": #{subject}") if subject
s = h("#{issue.project} - ") + s if options[:project] s = h("#{issue.project} - ") + s if options[:project]
s s
@@ -122,7 +128,7 @@ module ApplicationHelper
h(truncate(message.subject, :length => 60)), h(truncate(message.subject, :length => 60)),
{ :controller => 'messages', :action => 'show', { :controller => 'messages', :action => 'show',
:board_id => message.board_id, :board_id => message.board_id,
:id => (message.parent_id || message.id), :id => message.root,
:r => (message.parent_id && message.id), :r => (message.parent_id && message.id),
:anchor => (message.parent_id ? "message-#{message.id}" : nil) :anchor => (message.parent_id ? "message-#{message.id}" : nil)
}.merge(options), }.merge(options),
@@ -139,27 +145,17 @@ module ApplicationHelper
# link_to_project(project, {}, :class => "project") # => html options with default url (project overview) # link_to_project(project, {}, :class => "project") # => html options with default url (project overview)
# #
def link_to_project(project, options={}, html_options = nil) def link_to_project(project, options={}, html_options = nil)
if project.archived? if project.active?
h(project)
else
url = {:controller => 'projects', :action => 'show', :id => project}.merge(options) url = {:controller => 'projects', :action => 'show', :id => project}.merge(options)
link_to(h(project), url, html_options) link_to(h(project), url, html_options)
else
h(project)
end end
end end
def wiki_page_path(page, options={})
url_for({:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title}.merge(options))
end
def thumbnail_tag(attachment)
link_to image_tag(url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment)),
{:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename},
:title => attachment.filename
end
def toggle_link(name, id, options={}) def toggle_link(name, id, options={})
onclick = "$('##{id}').toggle(); " onclick = "Element.toggle('#{id}'); "
onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ") onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
onclick << "return false;" onclick << "return false;"
link_to(name, "#", :onclick => onclick) link_to(name, "#", :onclick => onclick)
end end
@@ -172,12 +168,17 @@ module ApplicationHelper
})) }))
end end
def prompt_to_remote(name, text, param, url, html_options = {})
html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
link_to name, {}, html_options
end
def format_activity_title(text) def format_activity_title(text)
h(truncate_single_line(text, :length => 100)) h(truncate_single_line(text, :length => 100))
end end
def format_activity_day(date) def format_activity_day(date)
date == User.current.today ? l(:label_today).titleize : format_date(date) date == Date.today ? l(:label_today).titleize : format_date(date)
end end
def format_activity_description(text) def format_activity_description(text)
@@ -199,46 +200,13 @@ module ApplicationHelper
end end
end end
# Renders a tree of projects as a nested set of unordered lists
# The given collection may be a subset of the whole project tree
# (eg. some intermediate nodes are private and can not be seen)
def render_project_nested_lists(projects)
s = ''
if projects.any?
ancestors = []
original_project = @project
projects.sort_by(&:lft).each do |project|
# set the project environment to please macros.
@project = project
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n"
else
ancestors.pop
s << "</li>"
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
ancestors.pop
s << "</ul></li>\n"
end
end
classes = (ancestors.empty? ? 'root' : 'child')
s << "<li class='#{classes}'><div class='#{classes}'>"
s << h(block_given? ? yield(project) : project.name)
s << "</div>\n"
ancestors << project
end
s << ("</li></ul>\n" * ancestors.size)
@project = original_project
end
s.html_safe
end
def render_page_hierarchy(pages, node=nil, options={}) def render_page_hierarchy(pages, node=nil, options={})
content = '' content = ''
if pages[node] if pages[node]
content << "<ul class=\"pages-hierarchy\">\n" content << "<ul class=\"pages-hierarchy\">\n"
pages[node].each do |page| pages[node].each do |page|
content << "<li>" content << "<li>"
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title, :version => nil}, content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title},
:title => (options[:timestamp] && page.updated_on ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil)) :title => (options[:timestamp] && page.updated_on ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
content << "\n" + render_page_hierarchy(pages, page.id, options) if pages[page.id] content << "\n" + render_page_hierarchy(pages, page.id, options) if pages[page.id]
content << "</li>\n" content << "</li>\n"
@@ -252,7 +220,7 @@ module ApplicationHelper
def render_flash_messages def render_flash_messages
s = '' s = ''
flash.each do |k,v| flash.each do |k,v|
s << content_tag('div', v.html_safe, :class => "flash #{k}", :id => "flash_#{k}") s << (content_tag('div', v.html_safe, :class => "flash #{k}"))
end end
s.html_safe s.html_safe
end end
@@ -269,24 +237,23 @@ module ApplicationHelper
# Renders the project quick-jump box # Renders the project quick-jump box
def render_project_jump_box def render_project_jump_box
return unless User.current.logged? return unless User.current.logged?
projects = User.current.memberships.collect(&:project).compact.select(&:active?).uniq projects = User.current.memberships.collect(&:project).compact.uniq
if projects.any? if projects.any?
options = s = '<select onchange="if (this.value != \'\') { window.location = this.value; }">' +
("<option value=''>#{ l(:label_jump_to_a_project) }</option>" + "<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
'<option value="" disabled="disabled">---</option>').html_safe '<option value="" disabled="disabled">---</option>'
s << project_tree_options_for_select(projects, :selected => @project) do |p|
options << project_tree_options_for_select(projects, :selected => @project) do |p| { :value => url_for(:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item) }
{ :value => project_path(:id => p, :jump => current_menu_item) }
end end
s << '</select>'
select_tag('project_quick_jump_box', options, :onchange => 'if (this.value != \'\') { window.location = this.value; }') s.html_safe
end end
end end
def project_tree_options_for_select(projects, options = {}) def project_tree_options_for_select(projects, options = {})
s = '' s = ''
project_tree(projects) do |project, level| project_tree(projects) do |project, level|
name_prefix = (level > 0 ? '&nbsp;' * 2 * level + '&#187; ' : '').html_safe name_prefix = (level > 0 ? ('&nbsp;' * 2 * level + '&#187; ').html_safe : '')
tag_options = {:value => project.id} tag_options = {:value => project.id}
if project == options[:selected] || (options[:selected].respond_to?(:include?) && options[:selected].include?(project)) if project == options[:selected] || (options[:selected].respond_to?(:include?) && options[:selected].include?(project))
tag_options[:selected] = 'selected' tag_options[:selected] = 'selected'
@@ -306,6 +273,30 @@ module ApplicationHelper
Project.project_tree(projects, &block) Project.project_tree(projects, &block)
end end
def project_nested_ul(projects, &block)
s = ''
if projects.any?
ancestors = []
projects.sort_by(&:lft).each do |project|
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
s << "<ul>\n"
else
ancestors.pop
s << "</li>"
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
ancestors.pop
s << "</ul></li>\n"
end
end
s << "<li>"
s << yield(project).to_s
ancestors << project
end
s << ("</li></ul>\n" * ancestors.size)
end
s.html_safe
end
def principals_check_box_tags(name, principals) def principals_check_box_tags(name, principals)
s = '' s = ''
principals.sort.each do |principal| principals.sort.each do |principal|
@@ -318,7 +309,7 @@ module ApplicationHelper
def principals_options_for_select(collection, selected=nil) def principals_options_for_select(collection, selected=nil)
s = '' s = ''
if collection.include?(User.current) if collection.include?(User.current)
s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id) s << content_tag('option', "<< #{l(:label_me)} >>".html_safe, :value => User.current.id)
end end
groups = '' groups = ''
collection.sort.each do |element| collection.sort.each do |element|
@@ -328,16 +319,7 @@ module ApplicationHelper
unless groups.empty? unless groups.empty?
s << %(<optgroup label="#{h(l(:label_group_plural))}">#{groups}</optgroup>) s << %(<optgroup label="#{h(l(:label_group_plural))}">#{groups}</optgroup>)
end end
s.html_safe s
end
# Options for the new membership projects combo-box
def options_for_membership_project_select(principal, projects)
options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
options << project_tree_options_for_select(projects) do |p|
{:disabled => principal.projects.include?(p)}
end
options
end end
# Truncates and returns the string as a single line # Truncates and returns the string as a single line
@@ -370,7 +352,7 @@ module ApplicationHelper
def time_tag(time) def time_tag(time)
text = distance_of_time_in_words(Time.now, time) text = distance_of_time_in_words(Time.now, time)
if @project if @project
link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => User.current.time_to_date(time)}, :title => format_time(time)) link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => time.to_date}, :title => format_time(time))
else else
content_tag('acronym', text, :title => format_time(time)) content_tag('acronym', text, :title => format_time(time))
end end
@@ -387,8 +369,7 @@ module ApplicationHelper
end end
def to_path_param(path) def to_path_param(path)
str = path.to_s.split(%r{[/\\]}).select{|p| !p.blank?}.join("/") path.to_s.split(%r{[/\\]}).select {|p| !p.blank?}
str.blank? ? nil : str
end end
def pagination_links_full(paginator, count=nil, options={}) def pagination_links_full(paginator, count=nil, options={})
@@ -417,7 +398,7 @@ module ApplicationHelper
unless count.nil? unless count.nil?
html << " (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})" html << " (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})"
if per_page_links != false && links = per_page_links(paginator.items_per_page, count) if per_page_links != false && links = per_page_links(paginator.items_per_page)
html << " | #{links}" html << " | #{links}"
end end
end end
@@ -425,23 +406,11 @@ module ApplicationHelper
html.html_safe html.html_safe
end end
def per_page_links(selected=nil, item_count=nil) def per_page_links(selected=nil)
values = Setting.per_page_options_array links = Setting.per_page_options_array.collect do |n|
if item_count && values.any?
if item_count > values.first
max = values.detect {|value| value >= item_count} || item_count
else
max = item_count
end
values = values.select {|value| value <= max || value == selected}
end
if values.empty? || (values.size == 1 && values.first == selected)
return nil
end
links = values.collect do |n|
n == selected ? n : link_to_content_update(n, params.merge(:per_page => n)) n == selected ? n : link_to_content_update(n, params.merge(:per_page => n))
end end
l(:label_display_per_page, links.join(', ')) links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
end end
def reorder_links(name, url, method = :post) def reorder_links(name, url, method = :post)
@@ -540,8 +509,6 @@ module ApplicationHelper
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil) project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
only_path = options.delete(:only_path) == false ? false : true only_path = options.delete(:only_path) == false ? false : true
text = text.dup
macros = catch_macros(text)
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr) text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr)
@parsed_headings = [] @parsed_headings = []
@@ -549,8 +516,8 @@ module ApplicationHelper
@current_section = 0 if options[:edit_section_links] @current_section = 0 if options[:edit_section_links]
parse_sections(text, project, obj, attr, only_path, options) parse_sections(text, project, obj, attr, only_path, options)
text = parse_non_pre_blocks(text, obj, macros) do |text| text = parse_non_pre_blocks(text) do |text|
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name| [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros].each do |method_name|
send method_name, text, project, obj, attr, only_path, options send method_name, text, project, obj, attr, only_path, options
end end
end end
@@ -563,7 +530,7 @@ module ApplicationHelper
text.html_safe text.html_safe
end end
def parse_non_pre_blocks(text, obj, macros) def parse_non_pre_blocks(text)
s = StringScanner.new(text) s = StringScanner.new(text)
tags = [] tags = []
parsed = '' parsed = ''
@@ -572,9 +539,6 @@ module ApplicationHelper
text, full_tag, closing, tag = s[1], s[2], s[3], s[4] text, full_tag, closing, tag = s[1], s[2], s[3], s[4]
if tags.empty? if tags.empty?
yield text yield text
inject_macros(text, obj, macros) if macros.any?
else
inject_macros(text, obj, macros, false) if macros.any?
end end
parsed << text parsed << text
if tag if tag
@@ -597,9 +561,8 @@ module ApplicationHelper
def parse_inline_attachments(text, project, obj, attr, only_path, options) def parse_inline_attachments(text, project, obj, attr, only_path, options)
# when using an image link, try to use an attachment, if possible # when using an image link, try to use an attachment, if possible
attachments = options[:attachments] || [] if options[:attachments] || (obj && obj.respond_to?(:attachments))
attachments += obj.attachments if obj.respond_to?(:attachments) attachments = options[:attachments] || obj.attachments
if attachments.present?
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m| text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
filename, ext, alt, alttext = $1.downcase, $2, $3, $4 filename, ext, alt, alttext = $1.downcase, $2, $3, $4
# search for the picture in attachments # search for the picture in attachments
@@ -658,7 +621,7 @@ module ApplicationHelper
wiki_page_id = page.present? ? Wiki.titleize(page) : nil wiki_page_id = page.present? ? Wiki.titleize(page) : nil
parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project, url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project,
:id => wiki_page_id, :version => nil, :anchor => anchor, :parent => parent) :id => wiki_page_id, :anchor => anchor, :parent => parent)
end end
end end
link_to(title.present? ? title.html_safe : h(page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new'))) link_to(title.present? ? title.html_safe : h(page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
@@ -704,11 +667,10 @@ module ApplicationHelper
# identifier:document:"Some document" # identifier:document:"Some document"
# identifier:version:1.0.0 # identifier:version:1.0.0
# identifier:source:some/file # identifier:source:some/file
def parse_redmine_links(text, default_project, obj, attr, only_path, options) def parse_redmine_links(text, project, obj, attr, only_path, options)
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-_]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m| text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $18, $14 || $19, $15, $17 leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $18, $14 || $19, $15, $17
link = nil link = nil
project = default_project
if project_identifier if project_identifier
project = Project.visible.find_by_identifier(project_identifier) project = Project.visible.find_by_identifier(project_identifier)
end end
@@ -732,7 +694,7 @@ module ApplicationHelper
oid = identifier.to_i oid = identifier.to_i
case prefix case prefix
when nil when nil
if oid.to_s == identifier && issue = Issue.visible.find_by_id(oid, :include => :status) if issue = Issue.visible.find_by_id(oid, :include => :status)
anchor = comment_id ? "note-#{comment_id}" : nil anchor = comment_id ? "note-#{comment_id}" : nil
link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor}, link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
:class => issue.css_classes, :class => issue.css_classes,
@@ -794,7 +756,7 @@ module ApplicationHelper
when 'commit', 'source', 'export' when 'commit', 'source', 'export'
if project if project
repository = nil repository = nil
if name =~ %r{^(([a-z0-9\-_]+)\|)(.+)$} if name =~ %r{^(([a-z0-9\-]+)\|)(.+)$}
repo_prefix, repo_identifier, name = $1, $2, $3 repo_prefix, repo_identifier, name = $1, $2, $3
repository = project.repositories.detect {|repo| repo.identifier == repo_identifier} repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
else else
@@ -810,10 +772,11 @@ module ApplicationHelper
if repository && User.current.allowed_to?(:browse_repository, project) if repository && User.current.allowed_to?(:browse_repository, project)
name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$} name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$}
path, rev, anchor = $1, $3, $5 path, rev, anchor = $1, $3, $5
link = link_to h("#{project_prefix}#{prefix}:#{repo_prefix}#{name}"), {:controller => 'repositories', :action => (prefix == 'export' ? 'raw' : 'entry'), :id => project, :repository_id => repository.identifier_param, link = link_to h("#{project_prefix}#{prefix}:#{repo_prefix}#{name}"), {:controller => 'repositories', :action => 'entry', :id => project, :repository_id => repository.identifier_param,
:path => to_path_param(path), :path => to_path_param(path),
:rev => rev, :rev => rev,
:anchor => anchor}, :anchor => anchor,
:format => (prefix == 'export' ? 'raw' : nil)},
:class => (prefix == 'export' ? 'source download' : 'source') :class => (prefix == 'export' ? 'source download' : 'source')
end end
end end
@@ -821,7 +784,7 @@ module ApplicationHelper
end end
when 'attachment' when 'attachment'
attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil) attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
if attachments && attachment = Attachment.latest_attach(attachments, name) if attachments && attachment = attachments.detect {|a| a.filename == name }
link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment}, link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment},
:class => 'attachment' :class => 'attachment'
end end
@@ -875,57 +838,31 @@ module ApplicationHelper
end end
end end
MACROS_RE = /( MACROS_RE = /
(!)? # escaping (!)? # escaping
( (
\{\{ # opening tag \{\{ # opening tag
([\w]+) # macro name ([\w]+) # macro name
(\(([^\n\r]*?)\))? # optional arguments (\(([^\}]*)\))? # optional arguments
([\n\r].*?[\n\r])? # optional block of text
\}\} # closing tag \}\} # closing tag
) )
)/mx unless const_defined?(:MACROS_RE) /x unless const_defined?(:MACROS_RE)
MACRO_SUB_RE = /( # Macros substitution
\{\{ def parse_macros(text, project, obj, attr, only_path, options)
macro\((\d+)\)
\}\}
)/x unless const_defined?(:MACRO_SUB_RE)
# Extracts macros from text
def catch_macros(text)
macros = {}
text.gsub!(MACROS_RE) do text.gsub!(MACROS_RE) do
all, macro = $1, $4.downcase esc, all, macro = $1, $2, $3.downcase
if macro_exists?(macro) || all =~ MACRO_SUB_RE args = ($5 || '').split(',').each(&:strip)
index = macros.size if esc.nil?
macros[index] = all begin
"{{macro(#{index})}}" exec_macro(macro, obj, args)
rescue => e
"<div class=\"flash error\">Error executing the <strong>#{macro}</strong> macro (#{e})</div>"
end || all
else else
all all
end end
end end
macros
end
# Executes and replaces macros in text
def inject_macros(text, obj, macros, execute=true)
text.gsub!(MACRO_SUB_RE) do
all, index = $1, $2.to_i
orig = macros.delete(index)
if execute && orig && orig =~ MACROS_RE
esc, all, macro, args, block = $2, $3, $4.downcase, $6.to_s, $7.try(:strip)
if esc.nil?
h(exec_macro(macro, obj, args, block) || all)
else
h(all)
end
elsif orig
h(orig)
else
h(all)
end
end
end end
TOC_RE = /<p>\{\{([<>]?)toc\}\}<\/p>/i unless const_defined?(:TOC_RE) TOC_RE = /<p>\{\{([<>]?)toc\}\}<\/p>/i unless const_defined?(:TOC_RE)
@@ -973,7 +910,8 @@ module ApplicationHelper
end end
def lang_options_for_select(blank=true) def lang_options_for_select(blank=true)
(blank ? [["(auto)", ""]] : []) + languages_options (blank ? [["(auto)", ""]] : []) +
valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last }
end end
def label_tag_for(name, option_tags = nil, options = {}) def label_tag_for(name, option_tags = nil, options = {})
@@ -981,12 +919,19 @@ module ApplicationHelper
content_tag("label", label_text) content_tag("label", label_text)
end end
def labelled_tabular_form_for(*args, &proc)
ActiveSupport::Deprecation.warn "ApplicationHelper#labelled_tabular_form_for is deprecated and will be removed in Redmine 1.5. Use #labelled_form_for instead."
args << {} unless args.last.is_a?(Hash)
options = args.last
options[:html] ||= {}
options[:html][:class] = 'tabular' unless options[:html].has_key?(:class)
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
form_for(*args, &proc)
end
def labelled_form_for(*args, &proc) def labelled_form_for(*args, &proc)
args << {} unless args.last.is_a?(Hash) args << {} unless args.last.is_a?(Hash)
options = args.last options = args.last
if args.first.is_a?(Symbol)
options.merge!(:as => args.shift)
end
options.merge!({:builder => Redmine::Views::LabelledFormBuilder}) options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
form_for(*args, &proc) form_for(*args, &proc)
end end
@@ -999,11 +944,10 @@ module ApplicationHelper
end end
def labelled_remote_form_for(*args, &proc) def labelled_remote_form_for(*args, &proc)
ActiveSupport::Deprecation.warn "ApplicationHelper#labelled_remote_form_for is deprecated and will be removed in Redmine 2.2."
args << {} unless args.last.is_a?(Hash) args << {} unless args.last.is_a?(Hash)
options = args.last options = args.last
options.merge!({:builder => Redmine::Views::LabelledFormBuilder, :remote => true}) options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
form_for(*args, &proc) remote_form_for(*args, &proc)
end end
def error_messages_for(*objects) def error_messages_for(*objects)
@@ -1020,44 +964,10 @@ module ApplicationHelper
html.html_safe html.html_safe
end end
def delete_link(url, options={})
options = {
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'icon icon-del'
}.merge(options)
link_to l(:button_delete), url, options
end
def preview_link(url, form, target='preview', options={})
content_tag 'a', l(:label_preview), {
:href => "#",
:onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|,
:accesskey => accesskey(:preview)
}.merge(options)
end
def link_to_function(name, function, html_options={})
content_tag(:a, name, {:href => '#', :onclick => "#{function}; return false;"}.merge(html_options))
end
# Helper to render JSON in views
def raw_json(arg)
arg.to_json.to_s.gsub('/', '\/').html_safe
end
def back_url
url = params[:back_url]
if url.nil? && referer = request.env['HTTP_REFERER']
url = CGI.unescape(referer.to_s)
end
url
end
def back_url_hidden_field_tag def back_url_hidden_field_tag
url = back_url back_url = params[:back_url] || request.env['HTTP_REFERER']
hidden_field_tag('back_url', url, :id => nil) unless url.blank? back_url = CGI.unescape(back_url.to_s)
hidden_field_tag('back_url', CGI.escape(back_url), :id => nil) unless back_url.blank?
end end
def check_all_links(form_name) def check_all_links(form_name)
@@ -1101,89 +1011,37 @@ module ApplicationHelper
end end
@context_menu_included = true @context_menu_included = true
end end
javascript_tag "contextMenuInit('#{ url_for(url) }')" javascript_tag "new ContextMenu('#{ url_for(url) }')"
end end
def calendar_for(field_id) def calendar_for(field_id)
include_calendar_headers_tags include_calendar_headers_tags
javascript_tag("$(function() { $('##{field_id}').datepicker(datepickerOptions); });") image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
end end
def include_calendar_headers_tags def include_calendar_headers_tags
unless @calendar_headers_tags_included unless @calendar_headers_tags_included
@calendar_headers_tags_included = true @calendar_headers_tags_included = true
content_for :header_tags do content_for :header_tags do
start_of_week = Setting.start_of_week start_of_week = case Setting.start_of_week.to_i
start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank? when 1
# Redmine uses 1..7 (monday..sunday) in settings and locales 'Calendar._FD = 1;' # Monday
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0 when 7
start_of_week = start_of_week.to_i % 7 'Calendar._FD = 0;' # Sunday
when 6
tags = javascript_tag( 'Calendar._FD = 6;' # Saturday
"var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
path_to_image('/images/calendar.png') +
"', showButtonPanel: true};")
jquery_locale = l('jquery.locale', :default => current_language.to_s)
unless jquery_locale == 'en'
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
end
tags
end
end
end
# Overrides Rails' stylesheet_link_tag with themes and plugins support.
# Examples:
# stylesheet_link_tag('styles') # => picks styles.css from the current theme or defaults
# stylesheet_link_tag('styles', :plugin => 'foo) # => picks styles.css from plugin's assets
#
def stylesheet_link_tag(*sources)
options = sources.last.is_a?(Hash) ? sources.pop : {}
plugin = options.delete(:plugin)
sources = sources.map do |source|
if plugin
"/plugin_assets/#{plugin}/stylesheets/#{source}"
elsif current_theme && current_theme.stylesheets.include?(source)
current_theme.stylesheet_path(source)
else
source
end
end
super sources, options
end
# Overrides Rails' image_tag with themes and plugins support.
# Examples:
# image_tag('image.png') # => picks image.png from the current theme or defaults
# image_tag('image.png', :plugin => 'foo) # => picks image.png from plugin's assets
#
def image_tag(source, options={})
if plugin = options.delete(:plugin)
source = "/plugin_assets/#{plugin}/images/#{source}"
elsif current_theme && current_theme.images.include?(source)
source = current_theme.image_path(source)
end
super source, options
end
# Overrides Rails' javascript_include_tag with plugins support
# Examples:
# javascript_include_tag('scripts') # => picks scripts.js from defaults
# javascript_include_tag('scripts', :plugin => 'foo) # => picks scripts.js from plugin's assets
#
def javascript_include_tag(*sources)
options = sources.last.is_a?(Hash) ? sources.pop : {}
if plugin = options.delete(:plugin)
sources = sources.map do |source|
if plugin
"/plugin_assets/#{plugin}/javascripts/#{source}"
else else
source '' # use language
end end
javascript_include_tag('calendar/calendar') +
javascript_include_tag("calendar/lang/calendar-#{current_language.to_s.downcase}.js") +
javascript_tag(start_of_week) +
javascript_include_tag('calendar/calendar-setup') +
stylesheet_link_tag('calendar')
end end
end end
super sources, options
end end
def content_for(name, content = nil, &block) def content_for(name, content = nil, &block)
@@ -1196,14 +1054,6 @@ module ApplicationHelper
(@has_content && @has_content[name]) || false (@has_content && @has_content[name]) || false
end end
def sidebar_content?
has_content?(:sidebar) || view_layouts_base_sidebar_hook_response.present?
end
def view_layouts_base_sidebar_hook_response
@view_layouts_base_sidebar_hook_response ||= call_hook(:view_layouts_base_sidebar)
end
def email_delivery_enabled? def email_delivery_enabled?
!!ActionMailer::Base.perform_deliveries !!ActionMailer::Base.perform_deliveries
end end
@@ -1212,7 +1062,7 @@ module ApplicationHelper
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>') # +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
def avatar(user, options = { }) def avatar(user, options = { })
if Setting.gravatar_enabled? if Setting.gravatar_enabled?
options.merge!({:ssl => (request && request.ssl?), :default => Setting.gravatar_default}) options.merge!({:ssl => (defined?(request) && request.ssl?), :default => Setting.gravatar_default})
email = nil email = nil
if user.respond_to?(:mail) if user.respond_to?(:mail)
email = user.mail email = user.mail
@@ -1226,19 +1076,14 @@ module ApplicationHelper
end end
def sanitize_anchor_name(anchor) def sanitize_anchor_name(anchor)
if ''.respond_to?(:encoding) || RUBY_PLATFORM == 'java' anchor.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
anchor.gsub(%r{[^\p{Word}\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
else
# TODO: remove when ruby1.8 is no longer supported
anchor.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
end
end end
# Returns the javascript tags that are included in the html layout head # Returns the javascript tags that are included in the html layout head
def javascript_heads def javascript_heads
tags = javascript_include_tag('jquery-1.7.2-ui-1.8.21-ujs-2.0.3', 'application') tags = javascript_include_tag(:defaults)
unless User.current.pref.warn_on_leaving_unsaved == '0' unless User.current.pref.warn_on_leaving_unsaved == '0'
tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });") tags << "\n".html_safe + javascript_tag("Event.observe(window, 'load', function(){ new WarnLeavingUnsaved('#{escape_javascript( l(:text_warn_on_leaving_unsaved) )}'); });")
end end
tags tags
end end
+3 -5
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -21,14 +21,12 @@ module AttachmentsHelper
# Displays view/delete links to the attachments of the given object # Displays view/delete links to the attachments of the given object
# Options: # Options:
# :author -- author names are not displayed if set to false # :author -- author names are not displayed if set to false
# :thumbails -- display thumbnails if enabled in settings
def link_to_attachments(container, options = {}) def link_to_attachments(container, options = {})
options.assert_valid_keys(:author, :thumbnails) options.assert_valid_keys(:author)
if container.attachments.any? if container.attachments.any?
options = {:deletable => container.attachments_deletable?, :author => true}.merge(options) options = {:deletable => container.attachments_deletable?, :author => true}.merge(options)
render :partial => 'attachments/links', render :partial => 'attachments/links', :locals => {:attachments => container.attachments, :options => options}
:locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)}
end end
end end
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+1 -21
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -18,24 +18,4 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module BoardsHelper module BoardsHelper
def board_breadcrumb(item)
board = item.is_a?(Message) ? item.board : item
links = [link_to(l(:label_board_plural), project_boards_path(item.project))]
boards = board.ancestors.reverse
if item.is_a?(Message)
boards << board
end
links += boards.map {|ancestor| link_to(h(ancestor.name), project_board_path(ancestor.project, ancestor))}
breadcrumb links
end
def boards_options_for_select(boards)
options = []
Board.board_tree(boards) do |board, level|
label = (level > 0 ? '&nbsp;' * 2 * level + '&#187; ' : '').html_safe
label << board.name
options << [label, board.id]
end
options
end
end end
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+3 -3
View File
@@ -26,8 +26,8 @@ module ContextMenusHelper
end end
if options.delete(:disabled) if options.delete(:disabled)
options.delete(:method) options.delete(:method)
options.delete(:data) options.delete(:confirm)
options[:onclick] = 'return false;' options.delete(:onclick)
options[:class] << ' disabled' options[:class] << ' disabled'
url = '#' url = '#'
end end
@@ -36,7 +36,7 @@ module ContextMenusHelper
def bulk_update_custom_field_context_menu_link(field, text, value) def bulk_update_custom_field_context_menu_link(field, text, value)
context_menu_link h(text), context_menu_link h(text),
{:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'custom_field_values' => {field.id => value}}, :back_url => @back}, {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'custom_field_values' => {field.id => value}}, :back_url => @back},
:method => :post, :method => :post,
:selected => (@issue && @issue.custom_field_value(field) == value) :selected => (@issue && @issue.custom_field_value(field) == value)
end end
+30 -27
View File
@@ -20,7 +20,16 @@
module CustomFieldsHelper module CustomFieldsHelper
def custom_fields_tabs def custom_fields_tabs
CustomField::CUSTOM_FIELDS_TABS tabs = [{:name => 'IssueCustomField', :partial => 'custom_fields/index', :label => :label_issue_plural},
{:name => 'TimeEntryCustomField', :partial => 'custom_fields/index', :label => :label_spent_time},
{:name => 'ProjectCustomField', :partial => 'custom_fields/index', :label => :label_project_plural},
{:name => 'VersionCustomField', :partial => 'custom_fields/index', :label => :label_version_plural},
{:name => 'UserCustomField', :partial => 'custom_fields/index', :label => :label_user_plural},
{:name => 'GroupCustomField', :partial => 'custom_fields/index', :label => :label_group_plural},
{:name => 'TimeEntryActivityCustomField', :partial => 'custom_fields/index', :label => TimeEntryActivity::OptionName},
{:name => 'IssuePriorityCustomField', :partial => 'custom_fields/index', :label => IssuePriority::OptionName},
{:name => 'DocumentCategoryCustomField', :partial => 'custom_fields/index', :label => DocumentCategory::OptionName}
]
end end
# Return custom field html tag corresponding to its format # Return custom field html tag corresponding to its format
@@ -30,79 +39,73 @@ module CustomFieldsHelper
field_name << "[]" if custom_field.multiple? field_name << "[]" if custom_field.multiple?
field_id = "#{name}_custom_field_values_#{custom_field.id}" field_id = "#{name}_custom_field_values_#{custom_field.id}"
tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"}
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format) field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
case field_format.try(:edit_as) case field_format.try(:edit_as)
when "date" when "date"
text_field_tag(field_name, custom_value.value, tag_options.merge(:size => 10)) + text_field_tag(field_name, custom_value.value, :id => field_id, :size => 10) +
calendar_for(field_id) calendar_for(field_id)
when "text" when "text"
text_area_tag(field_name, custom_value.value, tag_options.merge(:rows => 3)) text_area_tag(field_name, custom_value.value, :id => field_id, :rows => 3, :style => 'width:90%')
when "bool" when "bool"
hidden_field_tag(field_name, '0') + check_box_tag(field_name, '1', custom_value.true?, tag_options) hidden_field_tag(field_name, '0') + check_box_tag(field_name, '1', custom_value.true?, :id => field_id)
when "list" when "list"
blank_option = ''.html_safe blank_option = ''
unless custom_field.multiple? unless custom_field.multiple?
if custom_field.is_required? if custom_field.is_required?
unless custom_field.default_value.present? unless custom_field.default_value.present?
blank_option = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---", :value => '') blank_option = "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>"
end end
else else
blank_option = content_tag('option') blank_option = '<option></option>'
end end
end end
s = select_tag(field_name, blank_option + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value), s = select_tag(field_name, blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value),
tag_options.merge(:multiple => custom_field.multiple?)) :id => field_id, :multiple => custom_field.multiple?)
if custom_field.multiple? if custom_field.multiple?
s << hidden_field_tag(field_name, '') s << hidden_field_tag(field_name, '')
end end
s s
else else
text_field_tag(field_name, custom_value.value, tag_options) text_field_tag(field_name, custom_value.value, :id => field_id)
end end
end end
# Return custom field label tag # Return custom field label tag
def custom_field_label_tag(name, custom_value, options={}) def custom_field_label_tag(name, custom_value)
required = options[:required] || custom_value.custom_field.is_required?
content_tag "label", h(custom_value.custom_field.name) + content_tag "label", h(custom_value.custom_field.name) +
(required ? " <span class=\"required\">*</span>".html_safe : ""), (custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>".html_safe : ""),
:for => "#{name}_custom_field_values_#{custom_value.custom_field.id}" :for => "#{name}_custom_field_values_#{custom_value.custom_field.id}"
end end
# Return custom field tag with its label tag # Return custom field tag with its label tag
def custom_field_tag_with_label(name, custom_value, options={}) def custom_field_tag_with_label(name, custom_value)
custom_field_label_tag(name, custom_value, options) + custom_field_tag(name, custom_value) custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value)
end end
def custom_field_tag_for_bulk_edit(name, custom_field, projects=nil) def custom_field_tag_for_bulk_edit(name, custom_field, projects=nil)
field_name = "#{name}[custom_field_values][#{custom_field.id}]" field_name = "#{name}[custom_field_values][#{custom_field.id}]"
field_name << "[]" if custom_field.multiple? field_name << "[]" if custom_field.multiple?
field_id = "#{name}_custom_field_values_#{custom_field.id}" field_id = "#{name}_custom_field_values_#{custom_field.id}"
tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"}
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format) field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
case field_format.try(:edit_as) case field_format.try(:edit_as)
when "date" when "date"
text_field_tag(field_name, '', tag_options.merge(:size => 10)) + text_field_tag(field_name, '', :id => field_id, :size => 10) +
calendar_for(field_id) calendar_for(field_id)
when "text" when "text"
text_area_tag(field_name, '', tag_options.merge(:rows => 3)) text_area_tag(field_name, '', :id => field_id, :rows => 3, :style => 'width:90%')
when "bool" when "bool"
select_tag(field_name, options_for_select([[l(:label_no_change_option), ''], select_tag(field_name, options_for_select([[l(:label_no_change_option), ''],
[l(:general_text_yes), '1'], [l(:general_text_yes), '1'],
[l(:general_text_no), '0']]), tag_options) [l(:general_text_no), '0']]), :id => field_id)
when "list" when "list"
options = [] options = []
options << [l(:label_no_change_option), ''] unless custom_field.multiple? options << [l(:label_no_change_option), ''] unless custom_field.multiple?
options << [l(:label_none), '__none__'] unless custom_field.is_required? options << [l(:label_none), '__none__'] unless custom_field.is_required?
options += custom_field.possible_values_options(projects) options += custom_field.possible_values_options(projects)
select_tag(field_name, options_for_select(options), tag_options.merge(:multiple => custom_field.multiple?)) select_tag(field_name, options_for_select(options),
:id => field_id, :multiple => custom_field.multiple?)
else else
text_field_tag(field_name, '', tag_options) text_field_tag(field_name, '', :id => field_id)
end end
end end
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+10 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -18,6 +18,15 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module GroupsHelper module GroupsHelper
# Options for the new membership projects combo-box
def options_for_membership_project_select(user, projects)
options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
options << project_tree_options_for_select(projects) do |p|
{:disabled => (user.projects.include?(p))}
end
options
end
def group_settings_tabs def group_settings_tabs
tabs = [{:name => 'general', :partial => 'groups/general', :label => :label_general}, tabs = [{:name => 'general', :partial => 'groups/general', :label => :label_general},
{:name => 'users', :partial => 'groups/users', :label => :label_user_plural}, {:name => 'users', :partial => 'groups/users', :label => :label_user_plural},
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+10 -66
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -65,7 +65,7 @@ module IssuesHelper
s = '' s = ''
ancestors = issue.root? ? [] : issue.ancestors.visible.all ancestors = issue.root? ? [] : issue.ancestors.visible.all
ancestors.each do |ancestor| ancestors.each do |ancestor|
s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id))) s << '<div>' + content_tag('p', link_to_issue(ancestor))
end end
s << '<div>' s << '<div>'
subject = h(issue.subject) subject = h(issue.subject)
@@ -80,71 +80,18 @@ module IssuesHelper
def render_descendants_tree(issue) def render_descendants_tree(issue)
s = '<form><table class="list issues">' s = '<form><table class="list issues">'
issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level| issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
css = "issue issue-#{child.id} hascontextmenu"
css << " idnt idnt-#{level}" if level > 0
s << content_tag('tr', s << content_tag('tr',
content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') + content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
content_tag('td', link_to_issue(child, :truncate => 60, :project => (issue.project_id != child.project_id)), :class => 'subject') + content_tag('td', link_to_issue(child, :truncate => 60), :class => 'subject') +
content_tag('td', h(child.status)) + content_tag('td', h(child.status)) +
content_tag('td', link_to_user(child.assigned_to)) + content_tag('td', link_to_user(child.assigned_to)) +
content_tag('td', progress_bar(child.done_ratio, :width => '80px')), content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
:class => css) :class => "issue issue-#{child.id} hascontextmenu #{level > 0 ? "idnt idnt-#{level}" : nil}")
end end
s << '</table></form>' s << '</table></form>'
s.html_safe s.html_safe
end end
# Returns a link for adding a new subtask to the given issue
def link_to_new_subtask(issue)
attrs = {
:tracker_id => issue.tracker,
:parent_issue_id => issue
}
link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs))
end
class IssueFieldsRows
include ActionView::Helpers::TagHelper
def initialize
@left = []
@right = []
end
def left(*args)
args.any? ? @left << cells(*args) : @left
end
def right(*args)
args.any? ? @right << cells(*args) : @right
end
def size
@left.size > @right.size ? @left.size : @right.size
end
def to_html
html = ''.html_safe
blank = content_tag('th', '') + content_tag('td', '')
size.times do |i|
left = @left[i] || blank
right = @right[i] || blank
html << content_tag('tr', left + right)
end
html
end
def cells(label, text, options={})
content_tag('th', "#{label}:", options) + content_tag('td', text, options)
end
end
def issue_fields_rows
r = IssueFieldsRows.new
yield r
r.to_html
end
def render_custom_fields_rows(issue) def render_custom_fields_rows(issue)
return if issue.custom_field_values.empty? return if issue.custom_field_values.empty?
ordered_values = [] ordered_values = []
@@ -301,7 +248,7 @@ module IssuesHelper
unless no_html unless no_html
label = content_tag('strong', label) label = content_tag('strong', label)
old_value = content_tag("i", h(old_value)) if detail.old_value old_value = content_tag("i", h(old_value)) if detail.old_value
old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank? old_value = content_tag("strike", old_value) if detail.old_value and detail.value.blank?
if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key) if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
# Link to the attachment if it has not been removed # Link to the attachment if it has not been removed
value = link_to_attachment(atta, :download => true, :only_path => options[:only_path]) value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
@@ -371,16 +318,12 @@ module IssuesHelper
def issues_to_csv(issues, project, query, options={}) def issues_to_csv(issues, project, query, options={})
decimal_separator = l(:general_csv_decimal_separator) decimal_separator = l(:general_csv_decimal_separator)
encoding = l(:general_csv_encoding) encoding = l(:general_csv_encoding)
columns = (options[:columns] == 'all' ? query.available_inline_columns : query.inline_columns) columns = (options[:columns] == 'all' ? query.available_columns : query.columns)
if options[:description]
if description = query.available_columns.detect {|q| q.name == :description}
columns << description
end
end
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv| export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
# csv header fields # csv header fields
csv << [ "#" ] + columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) } csv << [ "#" ] + columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) } +
(options[:description] ? [Redmine::CodesetUtil.from_utf8(l(:field_description), encoding)] : [])
# csv lines # csv lines
issues.each do |issue| issues.each do |issue|
@@ -402,7 +345,8 @@ module IssuesHelper
end end
s.to_s s.to_s
end end
csv << [ issue.id.to_s ] + col_values.collect {|c| Redmine::CodesetUtil.from_utf8(c.to_s, encoding) } csv << [ issue.id.to_s ] + col_values.collect {|c| Redmine::CodesetUtil.from_utf8(c.to_s, encoding) } +
(options[:description] ? [Redmine::CodesetUtil.from_utf8(issue.description, encoding)] : [])
end end
end end
export export
+6 -8
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -23,13 +23,11 @@ module JournalsHelper
editable = User.current.logged? && (User.current.allowed_to?(:edit_issue_notes, issue.project) || (journal.user == User.current && User.current.allowed_to?(:edit_own_issue_notes, issue.project))) editable = User.current.logged? && (User.current.allowed_to?(:edit_issue_notes, issue.project) || (journal.user == User.current && User.current.allowed_to?(:edit_own_issue_notes, issue.project)))
links = [] links = []
if !journal.notes.blank? if !journal.notes.blank?
links << link_to(image_tag('comment.png'), links << link_to_remote(image_tag('comment.png'),
{:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal}, { :url => {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal} },
:remote => true, :title => l(:button_quote)) if options[:reply_links]
:method => 'post',
:title => l(:button_quote)) if options[:reply_links]
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes", links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
{ :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' }, { :controller => 'journals', :action => 'edit', :id => journal },
:title => l(:button_edit)) if editable :title => l(:button_edit)) if editable
end end
content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty? content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
@@ -40,7 +38,7 @@ module JournalsHelper
end end
def link_to_in_place_notes_editor(text, field_id, url, options={}) def link_to_in_place_notes_editor(text, field_id, url, options={})
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;" onclick = "new Ajax.Request('#{url_for(url)}', {asynchronous:true, evalScripts:true, method:'get'}); return false;"
link_to text, '#', options.merge(:onclick => onclick) link_to text, '#', options.merge(:onclick => onclick)
end end
end end
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+34 -7
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -51,15 +51,38 @@ module ProjectsHelper
content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id') content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
end end
# Renders the projects index # Renders a tree of projects as a nested set of unordered lists
# The given collection may be a subset of the whole project tree
# (eg. some intermediate nodes are private and can not be seen)
def render_project_hierarchy(projects) def render_project_hierarchy(projects)
render_project_nested_lists(projects) do |project| s = ''
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") if projects.any?
if project.description.present? ancestors = []
s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description') original_project = @project
projects.each do |project|
# set the project environment to please macros.
@project = project
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n"
else
ancestors.pop
s << "</li>"
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
ancestors.pop
s << "</ul></li>\n"
end
end
classes = (ancestors.empty? ? 'root' : 'child')
s << "<li class='#{classes}'><div class='#{classes}'>" +
link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank?
s << "</div>\n"
ancestors << project
end end
s s << ("</li></ul>\n" * ancestors.size)
@project = original_project
end end
s.html_safe
end end
# Returns a set of options for a select field, grouped by project. # Returns a set of options for a select field, grouped by project.
@@ -68,6 +91,10 @@ module ProjectsHelper
versions.each do |version| versions.each do |version|
grouped[version.project.name] << [version.name, version.id] grouped[version.project.name] << [version.name, version.id]
end end
# Add in the selected
if selected && !versions.include?(selected)
grouped[selected.project.name] << [selected.name, selected.id]
end
if grouped.keys.size > 1 if grouped.keys.size > 1
grouped_options_for_select(grouped, selected && selected.id) grouped_options_for_select(grouped, selected && selected.id)
+8 -50
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -18,44 +18,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module QueriesHelper module QueriesHelper
def filters_options_for_select(query)
options_for_select(filters_options(query))
end
def filters_options(query) def operators_for_select(filter_type)
options = [[]] Query.operators_by_filter_type[filter_type].collect {|o| [l(Query.operators[o]), o]}
sorted_options = query.available_filters.sort do |a, b|
ord = 0
if !(a[1][:order] == 20 && b[1][:order] == 20)
ord = a[1][:order] <=> b[1][:order]
else
cn = (CustomField::CUSTOM_FIELDS_NAMES.index(a[1][:field].class.name) <=>
CustomField::CUSTOM_FIELDS_NAMES.index(b[1][:field].class.name))
if cn != 0
ord = cn
else
f = (a[1][:field] <=> b[1][:field])
if f != 0
ord = f
else
# assigned_to or author
ord = (a[0] <=> b[0])
end
end
end
ord
end
options += sorted_options.map do |field, field_options|
[field_options[:name], field]
end
end
def available_block_columns_tags(query)
tags = ''.html_safe
query.available_block_columns.each do |column|
tags << content_tag('label', check_box_tag('c[]', column.name.to_s, query.has_column?(column)) + " #{column.caption}", :class => 'inline')
end
tags
end end
def column_header(column) def column_header(column)
@@ -67,7 +32,7 @@ module QueriesHelper
def column_content(column, issue) def column_content(column, issue)
value = column.value(issue) value = column.value(issue)
if value.is_a?(Array) if value.is_a?(Array)
value.collect {|v| column_value(column, issue, v)}.compact.join(', ').html_safe value.collect {|v| column_value(column, issue, v)}.compact.sort.join(', ').html_safe
else else
column_value(column, issue, value) column_value(column, issue, value)
end end
@@ -78,8 +43,6 @@ module QueriesHelper
when 'String' when 'String'
if column.name == :subject if column.name == :subject
link_to(h(value), :controller => 'issues', :action => 'show', :id => issue) link_to(h(value), :controller => 'issues', :action => 'show', :id => issue)
elsif column.name == :description
issue.description? ? content_tag('div', textilizable(issue, :description), :class => "wiki") : ''
else else
h(value) h(value)
end end
@@ -87,14 +50,14 @@ module QueriesHelper
format_time(value) format_time(value)
when 'Date' when 'Date'
format_date(value) format_date(value)
when 'Fixnum' when 'Fixnum', 'Float'
if column.name == :done_ratio if column.name == :done_ratio
progress_bar(value, :width => '80px') progress_bar(value, :width => '80px')
elsif column.name == :spent_hours
sprintf "%.2f", value
else else
value.to_s h(value.to_s)
end end
when 'Float'
sprintf "%.2f", value
when 'User' when 'User'
link_to_user value link_to_user value
when 'Project' when 'Project'
@@ -107,11 +70,6 @@ module QueriesHelper
l(:general_text_No) l(:general_text_No)
when 'Issue' when 'Issue'
link_to_issue(value, :subject => false) link_to_issue(value, :subject => false)
when 'IssueRelation'
other = value.other_issue(issue)
content_tag('span',
(l(value.label_for(issue)) + " " + link_to_issue(other, :subject => false, :tracker => false)).html_safe,
:class => value.css_classes_for(issue))
else else
h(value) h(value)
end end
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+34 -13
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -17,6 +17,9 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'iconv'
require 'redmine/codeset_util'
module RepositoriesHelper module RepositoriesHelper
def format_revision(revision) def format_revision(revision)
if revision.respond_to? :format_identifier if revision.respond_to? :format_identifier
@@ -43,17 +46,17 @@ module RepositoriesHelper
end end
def render_changeset_changes def render_changeset_changes
changes = @changeset.filechanges.find(:all, :limit => 1000, :order => 'path').collect do |change| changes = @changeset.changes.find(:all, :limit => 1000, :order => 'path').collect do |change|
case change.action case change.action
when 'A' when 'A'
# Detects moved/copied files # Detects moved/copied files
if !change.from_path.blank? if !change.from_path.blank?
change.action = change.action =
@changeset.filechanges.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C' @changeset.changes.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C'
end end
change change
when 'D' when 'D'
@changeset.filechanges.detect {|c| c.from_path == change.path} ? nil : change @changeset.changes.detect {|c| c.from_path == change.path} ? nil : change
else else
change change
end end
@@ -138,7 +141,12 @@ module RepositoriesHelper
select_tag('repository_scm', select_tag('repository_scm',
options_for_select(scm_options, repository.class.name.demodulize), options_for_select(scm_options, repository.class.name.demodulize),
:disabled => (repository && !repository.new_record?), :disabled => (repository && !repository.new_record?),
:data => {:remote => true, :method => 'get'}) :onchange => remote_function(
:url => new_project_repository_path(@project),
:method => :get,
:update => 'content',
:with => "Form.serialize(this.form)")
)
end end
def with_leading_slash(path) def with_leading_slash(path)
@@ -151,7 +159,7 @@ module RepositoriesHelper
def subversion_field_tags(form, repository) def subversion_field_tags(form, repository)
content_tag('p', form.text_field(:url, :size => 60, :required => true, content_tag('p', form.text_field(:url, :size => 60, :required => true,
:disabled => !repository.safe_attribute?('url')) + :disabled => (repository && !repository.root_url.blank?)) +
'<br />'.html_safe + '<br />'.html_safe +
'(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') + '(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') +
content_tag('p', form.text_field(:login, :size => 30)) + content_tag('p', form.text_field(:login, :size => 30)) +
@@ -166,7 +174,7 @@ module RepositoriesHelper
content_tag('p', form.text_field( content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository), :url, :label => l(:field_path_to_repository),
:size => 60, :required => true, :size => 60, :required => true,
:disabled => !repository.safe_attribute?('url'))) + :disabled => (repository && !repository.new_record?))) +
content_tag('p', form.select( content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS, :log_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_commit_logs_encoding), :required => true)) :label => l(:field_commit_logs_encoding), :required => true))
@@ -176,7 +184,7 @@ module RepositoriesHelper
content_tag('p', form.text_field( content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository), :url, :label => l(:field_path_to_repository),
:size => 60, :required => true, :size => 60, :required => true,
:disabled => !repository.safe_attribute?('url') :disabled => (repository && !repository.root_url.blank?)
) + ) +
'<br />'.html_safe + l(:text_mercurial_repository_note)) + '<br />'.html_safe + l(:text_mercurial_repository_note)) +
content_tag('p', form.select( content_tag('p', form.select(
@@ -190,7 +198,7 @@ module RepositoriesHelper
content_tag('p', form.text_field( content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository), :url, :label => l(:field_path_to_repository),
:size => 60, :required => true, :size => 60, :required => true,
:disabled => !repository.safe_attribute?('url') :disabled => (repository && !repository.root_url.blank?)
) + ) +
'<br />'.html_safe + '<br />'.html_safe +
l(:text_git_repository_note)) + l(:text_git_repository_note)) +
@@ -210,12 +218,12 @@ module RepositoriesHelper
:root_url, :root_url,
:label => l(:field_cvsroot), :label => l(:field_cvsroot),
:size => 60, :required => true, :size => 60, :required => true,
:disabled => !repository.safe_attribute?('root_url'))) + :disabled => !repository.new_record?)) +
content_tag('p', form.text_field( content_tag('p', form.text_field(
:url, :url,
:label => l(:field_cvs_module), :label => l(:field_cvs_module),
:size => 30, :required => true, :size => 30, :required => true,
:disabled => !repository.safe_attribute?('url'))) + :disabled => !repository.new_record?)) +
content_tag('p', form.select( content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS, :log_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_commit_logs_encoding), :required => true)) + :label => l(:field_commit_logs_encoding), :required => true)) +
@@ -230,7 +238,7 @@ module RepositoriesHelper
content_tag('p', form.text_field( content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository), :url, :label => l(:field_path_to_repository),
:size => 60, :required => true, :size => 60, :required => true,
:disabled => !repository.safe_attribute?('url'))) + :disabled => (repository && !repository.new_record?))) +
content_tag('p', form.select( content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS, :log_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_commit_logs_encoding), :required => true)) :label => l(:field_commit_logs_encoding), :required => true))
@@ -240,7 +248,7 @@ module RepositoriesHelper
content_tag('p', form.text_field( content_tag('p', form.text_field(
:url, :label => l(:field_root_directory), :url, :label => l(:field_root_directory),
:size => 60, :required => true, :size => 60, :required => true,
:disabled => !repository.safe_attribute?('url'))) + :disabled => (repository && !repository.root_url.blank?))) +
content_tag('p', form.select( content_tag('p', form.select(
:path_encoding, [nil] + Setting::ENCODINGS, :path_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_scm_path_encoding) :label => l(:field_scm_path_encoding)
@@ -250,13 +258,16 @@ module RepositoriesHelper
def index_commits(commits, heads) def index_commits(commits, heads)
return nil if commits.nil? or commits.first.parents.nil? return nil if commits.nil? or commits.first.parents.nil?
refs_map = {} refs_map = {}
heads.each do |head| heads.each do |head|
refs_map[head.scmid] ||= [] refs_map[head.scmid] ||= []
refs_map[head.scmid] << head refs_map[head.scmid] << head
end end
commits_by_scmid = {} commits_by_scmid = {}
commits.reverse.each_with_index do |commit, commit_index| commits.reverse.each_with_index do |commit, commit_index|
commits_by_scmid[commit.scmid] = { commits_by_scmid[commit.scmid] = {
:parent_scmids => commit.parents.collect { |parent| parent.scmid }, :parent_scmids => commit.parents.collect { |parent| parent.scmid },
:rdmid => commit_index, :rdmid => commit_index,
@@ -265,28 +276,38 @@ module RepositoriesHelper
:href => block_given? ? yield(commit.scmid) : commit.scmid :href => block_given? ? yield(commit.scmid) : commit.scmid
} }
end end
heads.sort! { |head1, head2| head1.to_s <=> head2.to_s } heads.sort! { |head1, head2| head1.to_s <=> head2.to_s }
space = nil space = nil
heads.each do |head| heads.each do |head|
if commits_by_scmid.include? head.scmid if commits_by_scmid.include? head.scmid
space = index_head((space || -1) + 1, head, commits_by_scmid) space = index_head((space || -1) + 1, head, commits_by_scmid)
end end
end end
# when no head matched anything use first commit # when no head matched anything use first commit
space ||= index_head(0, commits.first, commits_by_scmid) space ||= index_head(0, commits.first, commits_by_scmid)
return commits_by_scmid, space return commits_by_scmid, space
end end
def index_head(space, commit, commits_by_scmid) def index_head(space, commit, commits_by_scmid)
stack = [[space, commits_by_scmid[commit.scmid]]] stack = [[space, commits_by_scmid[commit.scmid]]]
max_space = space max_space = space
until stack.empty? until stack.empty?
space, commit = stack.pop space, commit = stack.pop
commit[:space] = space if commit[:space].nil? commit[:space] = space if commit[:space].nil?
space -= 1 space -= 1
commit[:parent_scmids].each_with_index do |parent_scmid, parent_index| commit[:parent_scmids].each_with_index do |parent_scmid, parent_index|
parent_commit = commits_by_scmid[parent_scmid] parent_commit = commits_by_scmid[parent_scmid]
if parent_commit and parent_commit[:space].nil? if parent_commit and parent_commit[:space].nil?
stack.unshift [space += 1, parent_commit] stack.unshift [space += 1, parent_commit]
end end
end end
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+7 -20
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -44,7 +44,7 @@ module SettingsHelper
setting_values = Setting.send(setting) setting_values = Setting.send(setting)
setting_values = [] unless setting_values.is_a?(Array) setting_values = [] unless setting_values.is_a?(Array)
content_tag("label", l(options[:label] || "setting_#{setting}")) + setting_label(setting, options).html_safe +
hidden_field_tag("settings[#{setting}][]", '').html_safe + hidden_field_tag("settings[#{setting}][]", '').html_safe +
choices.collect do |choice| choices.collect do |choice|
text, value = (choice.is_a?(Array) ? choice : [choice, choice]) text, value = (choice.is_a?(Array) ? choice : [choice, choice])
@@ -53,10 +53,9 @@ module SettingsHelper
check_box_tag( check_box_tag(
"settings[#{setting}][]", "settings[#{setting}][]",
value, value,
Setting.send(setting).include?(value), Setting.send(setting).include?(value)
:id => nil
) + text.to_s, ) + text.to_s,
:class => (options[:inline] ? 'inline' : 'block') :class => 'block'
) )
end.join.html_safe end.join.html_safe
end end
@@ -73,13 +72,13 @@ module SettingsHelper
def setting_check_box(setting, options={}) def setting_check_box(setting, options={})
setting_label(setting, options).html_safe + setting_label(setting, options).html_safe +
hidden_field_tag("settings[#{setting}]", 0, :id => nil).html_safe + hidden_field_tag("settings[#{setting}]", 0).html_safe +
check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe
end end
def setting_label(setting, options={}) def setting_label(setting, options={})
label = options.delete(:label) label = options.delete(:label)
label != false ? label_tag("settings_#{setting}", l(label || "setting_#{setting}")).html_safe : '' label != false ? content_tag("label", l(label || "setting_#{setting}")).html_safe : ''
end end
# Renders a notification field for a Redmine::Notifiable option # Renders a notification field for a Redmine::Notifiable option
@@ -87,20 +86,8 @@ module SettingsHelper
return content_tag(:label, return content_tag(:label,
check_box_tag('settings[notified_events][]', check_box_tag('settings[notified_events][]',
notifiable.name, notifiable.name,
Setting.notified_events.include?(notifiable.name), :id => nil).html_safe + Setting.notified_events.include?(notifiable.name)).html_safe +
l_or_humanize(notifiable.name, :prefix => 'label_').html_safe, l_or_humanize(notifiable.name, :prefix => 'label_').html_safe,
:class => notifiable.parent.present? ? "parent" : '').html_safe :class => notifiable.parent.present? ? "parent" : '').html_safe
end end
def cross_project_subtasks_options
options = [
[:label_disabled, ''],
[:label_cross_project_system, 'system'],
[:label_cross_project_tree, 'tree'],
[:label_cross_project_hierarchy, 'hierarchy'],
[:label_cross_project_descendants, 'descendants']
]
options.map {|label, value| [l(label), value.to_s]}
end
end end
-8
View File
@@ -89,10 +89,6 @@ module SortHelper
sql.blank? ? nil : sql sql.blank? ? nil : sql
end end
def to_a
@criteria.dup
end
def add!(key, asc) def add!(key, asc)
@criteria.delete_if {|k,o| k == key} @criteria.delete_if {|k,o| k == key}
@criteria = [[key, asc]] + @criteria @criteria = [[key, asc]] + @criteria
@@ -186,10 +182,6 @@ module SortHelper
@sort_criteria.to_sql @sort_criteria.to_sql
end end
def sort_criteria
@sort_criteria
end
# Returns a link which sorts by the named column. # Returns a link which sorts by the named column.
# #
# - column is the name of an attribute in the sorted record collection. # - column is the name of an attribute in the sorted record collection.
+1 -2
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -77,7 +77,6 @@ module TimelogHelper
[l(:label_yesterday), 'yesterday'], [l(:label_yesterday), 'yesterday'],
[l(:label_this_week), 'current_week'], [l(:label_this_week), 'current_week'],
[l(:label_last_week), 'last_week'], [l(:label_last_week), 'last_week'],
[l(:label_last_n_weeks, 2), 'last_2_weeks'],
[l(:label_last_n_days, 7), '7_days'], [l(:label_last_n_days, 7), '7_days'],
[l(:label_this_month), 'current_month'], [l(:label_this_month), 'current_month'],
[l(:label_last_month), 'last_month'], [l(:label_last_month), 'last_month'],
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+10 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -26,6 +26,15 @@ module UsersHelper
["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s) ["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s)
end end
# Options for the new membership projects combo-box
def options_for_membership_project_select(user, projects)
options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---")
options << project_tree_options_for_select(projects) do |p|
{:disabled => (user.projects.include?(p))}
end
options
end
def user_mail_notification_options(user) def user_mail_notification_options(user)
user.valid_notification_options.collect {|o| [l(o.last), o.first]} user.valid_notification_options.collect {|o| [l(o.last), o.first]}
end end
+4 -13
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -19,18 +19,10 @@
module VersionsHelper module VersionsHelper
def version_anchor(version) STATUS_BY_CRITERIAS = %w(category tracker status priority author assigned_to)
if @project == version.project
anchor version.name
else
anchor "#{version.project.try(:identifier)}-#{version.name}"
end
end
STATUS_BY_CRITERIAS = %w(tracker status priority author assigned_to category)
def render_issue_status_by(version, criteria) def render_issue_status_by(version, criteria)
criteria = 'tracker' unless STATUS_BY_CRITERIAS.include?(criteria) criteria = 'category' unless STATUS_BY_CRITERIAS.include?(criteria)
h = Hash.new {|k,v| k[v] = [0, 0]} h = Hash.new {|k,v| k[v] = [0, 0]}
begin begin
@@ -44,8 +36,7 @@ module VersionsHelper
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
# When grouping by an association, Rails throws this exception if there's no result (bug) # When grouping by an association, Rails throws this exception if there's no result (bug)
end end
# Sort with nil keys in last position counts = h.keys.compact.sort.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}}
counts = h.keys.sort {|a,b| a.nil? ? 1 : (b.nil? ? -1 : a <=> b)}.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}}
max = counts.collect {|c| c[:total]}.max max = counts.collect {|c| c[:total]}.max
render :partial => 'issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max} render :partial => 'issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max}
+15 -16
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -30,8 +30,10 @@ module WatchersHelper
:action => (watched ? 'unwatch' : 'watch'), :action => (watched ? 'unwatch' : 'watch'),
:object_type => object.class.to_s.underscore, :object_type => object.class.to_s.underscore,
:object_id => object.id} :object_id => object.id}
link_to((watched ? l(:button_unwatch) : l(:button_watch)), url, link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)),
:remote => true, :method => 'post', :class => (watched ? 'icon icon-fav' : 'icon icon-fav-off')) {:url => url},
:href => url_for(url),
:class => (watched ? 'icon icon-fav' : 'icon icon-fav-off'))
end end
@@ -43,33 +45,30 @@ module WatchersHelper
# Returns a comma separated list of users watching the given object # Returns a comma separated list of users watching the given object
def watchers_list(object) def watchers_list(object)
remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project) remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)
content = ''.html_safe
lis = object.watcher_users.collect do |user| lis = object.watcher_users.collect do |user|
s = ''.html_safe s = avatar(user, :size => "16").to_s + link_to_user(user, :class => 'user').to_s
s << avatar(user, :size => "16").to_s
s << link_to_user(user, :class => 'user')
if remove_allowed if remove_allowed
url = {:controller => 'watchers', url = {:controller => 'watchers',
:action => 'destroy', :action => 'destroy',
:object_type => object.class.to_s.underscore, :object_type => object.class.to_s.underscore,
:object_id => object.id, :object_id => object.id,
:user_id => user} :user_id => user}
s << ' ' s += ' ' + link_to_remote(image_tag('delete.png'),
s << link_to(image_tag('delete.png'), url, {:url => url},
:remote => true, :method => 'post', :style => "vertical-align: middle", :class => "delete") :href => url_for(url),
:style => "vertical-align: middle",
:class => "delete")
end end
content << content_tag('li', s) content_tag :li, s.html_safe
end end
content.present? ? content_tag('ul', content) : content (lis.empty? ? "" : "<ul>#{ lis.join("\n") }</ul>").html_safe
end end
def watchers_checkboxes(object, users, checked=nil) def watchers_checkboxes(object, users, checked=nil)
users.map do |user| users.map do |user|
c = checked.nil? ? object.watched_by?(user) : checked c = checked.nil? ? object.watched_by?(user) : checked
tag = check_box_tag 'issue[watcher_user_ids][]', user.id, c, :id => nil tag = check_box_tag 'issue[watcher_user_ids][]', user.id, c, :id => nil
content_tag 'label', "#{tag} #{h(user)}".html_safe, content_tag 'label', "#{tag} #{h(user)}", :id => "issue_watcher_user_ids_#{user.id}", :class => "floating"
:id => "issue_watcher_user_ids_#{user.id}", end.join
:class => "floating"
end.join.html_safe
end end
end end
+1 -1
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+5 -5
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -21,14 +21,14 @@ module WikiHelper
def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0) def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
pages = pages.group_by(&:parent) unless pages.is_a?(Hash) pages = pages.group_by(&:parent) unless pages.is_a?(Hash)
s = ''.html_safe s = ''
if pages.has_key?(parent) if pages.has_key?(parent)
pages[parent].each do |page| pages[parent].each do |page|
attrs = "value='#{page.id}'" attrs = "value='#{page.id}'"
attrs << " selected='selected'" if selected == page attrs << " selected='selected'" if selected == page
indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : '' indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : nil
s << content_tag('option', (indent + h(page.pretty_title)).html_safe, :value => page.id.to_s, :selected => selected == page) + s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" +
wiki_page_options_for_select(pages, selected, page, level + 1) wiki_page_options_for_select(pages, selected, page, level + 1)
end end
end end
@@ -37,7 +37,7 @@ module WikiHelper
def wiki_page_breadcrumb(page) def wiki_page_breadcrumb(page)
breadcrumb(page.ancestors.reverse.collect {|parent| breadcrumb(page.ancestors.reverse.collect {|parent|
link_to(h(parent.pretty_title), {:controller => 'wiki', :action => 'show', :id => parent.title, :project_id => parent.project, :version => nil}) link_to(h(parent.pretty_title), {:controller => 'wiki', :action => 'show', :id => parent.title, :project_id => parent.project})
}) })
end end
end end
+1 -12
View File
@@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -18,15 +18,4 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module WorkflowsHelper module WorkflowsHelper
def field_required?(field)
field.is_a?(CustomField) ? field.is_required? : %w(project_id tracker_id subject priority_id is_private).include?(field)
end
def field_permission_tag(permissions, status, field)
name = field.is_a?(CustomField) ? field.id.to_s : field
options = [["", ""], [l(:label_readonly), "readonly"]]
options << [l(:label_required), "required"] unless field_required?(field)
select_tag("permissions[#{name}][#{status.id}]", options_for_select(options, permissions[status.id][name]))
end
end end
+17 -54
View File
@@ -24,7 +24,7 @@ class Attachment < ActiveRecord::Base
validates_presence_of :filename, :author validates_presence_of :filename, :author
validates_length_of :filename, :maximum => 255 validates_length_of :filename, :maximum => 255
validates_length_of :disk_filename, :maximum => 255 validates_length_of :disk_filename, :maximum => 255
validates_length_of :description, :maximum => 255 validates_length_of :description, :maximum => 255, :allow_blank => true
validate :validate_max_file_size validate :validate_max_file_size
acts_as_event :title => :filename, acts_as_event :title => :filename,
@@ -45,14 +45,20 @@ class Attachment < ActiveRecord::Base
"LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id"} "LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id"}
cattr_accessor :storage_path cattr_accessor :storage_path
@@storage_path = Redmine::Configuration['attachments_storage_path'] || File.join(Rails.root, "files") @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files"
cattr_accessor :thumbnails_storage_path
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location before_save :files_to_final_location
after_destroy :delete_from_disk after_destroy :delete_from_disk
def container_with_blank_type_check
if container_type.blank?
nil
else
container_without_blank_type_check
end
end
alias_method_chain :container, :blank_type_check unless method_defined?(:container_without_blank_type_check)
# Returns an unsaved copy of the attachment # Returns an unsaved copy of the attachment
def copy(attributes=nil) def copy(attributes=nil)
copy = self.class.new copy = self.class.new
@@ -127,22 +133,14 @@ class Attachment < ActiveRecord::Base
# Deletes the file from the file system if it's not referenced by other attachments # Deletes the file from the file system if it's not referenced by other attachments
def delete_from_disk def delete_from_disk
if Attachment.where("disk_filename = ? AND id <> ?", disk_filename, id).empty? if Attachment.first(:conditions => ["disk_filename = ? AND id <> ?", disk_filename, id]).nil?
delete_from_disk! delete_from_disk!
end end
end end
# Returns file's location on disk # Returns file's location on disk
def diskfile def diskfile
File.join(self.class.storage_path, disk_filename.to_s) "#{@@storage_path}/#{self.disk_filename}"
end
def title
title = filename.to_s
if description.present?
title << " (#{description})"
end
title
end end
def increment_download def increment_download
@@ -162,43 +160,7 @@ class Attachment < ActiveRecord::Base
end end
def image? def image?
!!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png)$/i) self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png)$/i
end
def thumbnailable?
image?
end
# Returns the full path the attachment thumbnail, or nil
# if the thumbnail cannot be generated.
def thumbnail(options={})
if thumbnailable? && readable?
size = options[:size].to_i
if size > 0
# Limit the number of thumbnails per image
size = (size / 50) * 50
# Maximum thumbnail size
size = 800 if size > 800
else
size = Setting.thumbnails_size.to_i
end
size = 100 unless size > 0
target = File.join(self.class.thumbnails_storage_path, "#{id}_#{digest}_#{size}.thumb")
begin
Redmine::Thumbnail.generate(self.diskfile, target, size)
rescue => e
logger.error "An error occured while generating thumbnail for #{disk_filename} to #{target}\nException was: #{e.message}" if logger
return nil
end
end
end
# Deletes all thumbnails
def self.clear_thumbnails
Dir.glob(File.join(thumbnails_storage_path, "*.thumb")).each do |file|
File.delete file
end
end end
def is_text? def is_text?
@@ -223,7 +185,7 @@ class Attachment < ActiveRecord::Base
def self.find_by_token(token) def self.find_by_token(token)
if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/ if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/
attachment_id, attachment_digest = $1, $2 attachment_id, attachment_digest = $1, $2
attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first attachment = Attachment.first(:conditions => {:id => attachment_id, :digest => attachment_digest})
if attachment && attachment.container.nil? if attachment && attachment.container.nil?
attachment attachment
end end
@@ -248,7 +210,8 @@ class Attachment < ActiveRecord::Base
end end
def self.prune(age=1.day) def self.prune(age=1.day)
Attachment.where("created_on < ? AND (container_type IS NULL OR container_type = '')", Time.now - age).destroy_all attachments = Attachment.all(:conditions => ["created_on < ? AND (container_type IS NULL OR container_type = '')", Time.now - age])
attachments.each(&:destroy)
end end
private private
+2 -3
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -18,7 +18,6 @@
# Generic exception for when the AuthSource can not be reached # Generic exception for when the AuthSource can not be reached
# (eg. can not connect to the LDAP) # (eg. can not connect to the LDAP)
class AuthSourceException < Exception; end class AuthSourceException < Exception; end
class AuthSourceTimeoutException < AuthSourceException; end
class AuthSource < ActiveRecord::Base class AuthSource < ActiveRecord::Base
include Redmine::SubclassFactory include Redmine::SubclassFactory
@@ -59,7 +58,7 @@ class AuthSource < ActiveRecord::Base
# Try to authenticate a user not yet registered against available sources # Try to authenticate a user not yet registered against available sources
def self.authenticate(login, password) def self.authenticate(login, password)
AuthSource.where(:onthefly_register => true).all.each do |source| AuthSource.find(:all, :conditions => ["onthefly_register=?", true]).each do |source|
begin begin
logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug? logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug?
attrs = source.authenticate(login, password) attrs = source.authenticate(login, password)
+18 -26
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -18,7 +18,6 @@
require 'iconv' require 'iconv'
require 'net/ldap' require 'net/ldap'
require 'net/ldap/dn' require 'net/ldap/dn'
require 'timeout'
class AuthSourceLdap < AuthSource class AuthSourceLdap < AuthSource
validates_presence_of :host, :port, :attr_login validates_presence_of :host, :port, :attr_login
@@ -26,11 +25,18 @@ class AuthSourceLdap < AuthSource
validates_length_of :account, :account_password, :base_dn, :filter, :maximum => 255, :allow_blank => true validates_length_of :account, :account_password, :base_dn, :filter, :maximum => 255, :allow_blank => true
validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30, :allow_nil => true validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30, :allow_nil => true
validates_numericality_of :port, :only_integer => true validates_numericality_of :port, :only_integer => true
validates_numericality_of :timeout, :only_integer => true, :allow_blank => true
validate :validate_filter validate :validate_filter
before_validation :strip_ldap_attributes before_validation :strip_ldap_attributes
def self.human_attribute_name(attribute_key_name, *args)
attr_name = attribute_key_name.to_s
if attr_name == "filter"
attr_name = "ldap_filter"
end
super(attr_name, *args)
end
def initialize(attributes=nil, *args) def initialize(attributes=nil, *args)
super super
self.port = 389 if self.port == 0 self.port = 389 if self.port == 0
@@ -38,26 +44,22 @@ class AuthSourceLdap < AuthSource
def authenticate(login, password) def authenticate(login, password)
return nil if login.blank? || password.blank? return nil if login.blank? || password.blank?
attrs = get_user_dn(login, password)
with_timeout do if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password)
attrs = get_user_dn(login, password) logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password) return attrs.except(:dn)
logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
return attrs.except(:dn)
end
end end
rescue Net::LDAP::LdapError => e rescue Net::LDAP::LdapError => e
raise AuthSourceException.new(e.message) raise AuthSourceException.new(e.message)
end end
# test the connection to the LDAP # test the connection to the LDAP
def test_connection def test_connection
with_timeout do ldap_con = initialize_ldap_con(self.account, self.account_password)
ldap_con = initialize_ldap_con(self.account, self.account_password) ldap_con.open { }
ldap_con.open { } rescue Net::LDAP::LdapError => e
end raise "LdapError: " + e.message
rescue Net::LDAP::LdapError => e
raise AuthSourceException.new(e.message)
end end
def auth_method_name def auth_method_name
@@ -66,16 +68,6 @@ class AuthSourceLdap < AuthSource
private private
def with_timeout(&block)
timeout = self.timeout
timeout = 20 unless timeout && timeout > 0
Timeout.timeout(timeout) do
return yield
end
rescue Timeout::Error => e
raise AuthSourceTimeoutException.new(e.message)
end
def ldap_filter def ldap_filter
if filter.present? if filter.present?
Net::LDAP::Filter.construct(filter) Net::LDAP::Filter.construct(filter)
+4 -37
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -21,37 +21,26 @@ class Board < ActiveRecord::Base
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC" has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC" has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
acts_as_tree :dependent => :nullify acts_as_list :scope => :project_id
acts_as_list :scope => '(project_id = #{project_id} AND parent_id #{parent_id ? "= #{parent_id}" : "IS NULL"})'
acts_as_watchable acts_as_watchable
validates_presence_of :name, :description validates_presence_of :name, :description
validates_length_of :name, :maximum => 30 validates_length_of :name, :maximum => 30
validates_length_of :description, :maximum => 255 validates_length_of :description, :maximum => 255
validate :validate_board
scope :visible, lambda {|*args| { :include => :project, named_scope :visible, lambda {|*args| { :include => :project,
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } } :conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
safe_attributes 'name', 'description', 'parent_id', 'move_to' safe_attributes 'name', 'description', 'move_to'
def visible?(user=User.current) def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_messages, project) !user.nil? && user.allowed_to?(:view_messages, project)
end end
def reload(*args)
@valid_parents = nil
super
end
def to_s def to_s
name name
end end
def valid_parents
@valid_parents ||= project.boards - self_and_descendants
end
def reset_counters! def reset_counters!
self.class.reset_counters!(id) self.class.reset_counters!(id)
end end
@@ -64,26 +53,4 @@ class Board < ActiveRecord::Base
" last_message_id = (SELECT MAX(id) FROM #{Message.table_name} WHERE board_id=#{board_id})", " last_message_id = (SELECT MAX(id) FROM #{Message.table_name} WHERE board_id=#{board_id})",
["id = ?", board_id]) ["id = ?", board_id])
end end
def self.board_tree(boards, parent_id=nil, level=0)
tree = []
boards.select {|board| board.parent_id == parent_id}.sort_by(&:position).each do |board|
tree << [board, level]
tree += board_tree(boards, board.id, level+1)
end
if block_given?
tree.each do |board, level|
yield board, level
end
end
tree
end
protected
def validate_board
if parent_id && parent_id_changed?
errors.add(:parent_id, :invalid) unless valid_parents.include?(parent)
end
end
end end
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+11 -6
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -20,7 +20,7 @@ require 'iconv'
class Changeset < ActiveRecord::Base class Changeset < ActiveRecord::Base
belongs_to :repository belongs_to :repository
belongs_to :user belongs_to :user
has_many :filechanges, :class_name => 'Change', :dependent => :delete_all has_many :changes, :dependent => :delete_all
has_and_belongs_to_many :issues has_and_belongs_to_many :issues
has_and_belongs_to_many :parents, has_and_belongs_to_many :parents,
:class_name => "Changeset", :class_name => "Changeset",
@@ -49,8 +49,7 @@ class Changeset < ActiveRecord::Base
validates_uniqueness_of :revision, :scope => :repository_id validates_uniqueness_of :revision, :scope => :repository_id
validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true
scope :visible, named_scope :visible, lambda {|*args| { :include => {:repository => :project},
lambda {|*args| { :include => {:repository => :project},
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args) } } :conditions => Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args) } }
after_create :scan_for_issues after_create :scan_for_issues
@@ -176,12 +175,18 @@ class Changeset < ActiveRecord::Base
# Returns the previous changeset # Returns the previous changeset
def previous def previous
@previous ||= Changeset.where(["id < ? AND repository_id = ?", id, repository_id]).order('id DESC').first @previous ||= Changeset.find(:first,
:conditions => ['id < ? AND repository_id = ?',
self.id, self.repository_id],
:order => 'id DESC')
end end
# Returns the next changeset # Returns the next changeset
def next def next
@next ||= Changeset.where(["id > ? AND repository_id = ?", id, repository_id]).order('id ASC').first @next ||= Changeset.find(:first,
:conditions => ['id > ? AND repository_id = ?',
self.id, self.repository_id],
:order => 'id ASC')
end end
# Creates a new Change from it's common parameters # Creates a new Change from it's common parameters
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
class CommentObserver < ActiveRecord::Observer class CommentObserver < ActiveRecord::Observer
def after_create(comment) def after_create(comment)
if comment.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added') if comment.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added')
Mailer.news_comment_added(comment).deliver Mailer.deliver_news_comment_added(comment)
end end
end end
end end
+19 -114
View File
@@ -30,32 +30,9 @@ class CustomField < ActiveRecord::Base
validate :validate_custom_field validate :validate_custom_field
before_validation :set_searchable before_validation :set_searchable
CUSTOM_FIELDS_TABS = [ def initialize(attributes=nil, *args)
{:name => 'IssueCustomField', :partial => 'custom_fields/index', super
:label => :label_issue_plural}, self.possible_values ||= []
{:name => 'TimeEntryCustomField', :partial => 'custom_fields/index',
:label => :label_spent_time},
{:name => 'ProjectCustomField', :partial => 'custom_fields/index',
:label => :label_project_plural},
{:name => 'VersionCustomField', :partial => 'custom_fields/index',
:label => :label_version_plural},
{:name => 'UserCustomField', :partial => 'custom_fields/index',
:label => :label_user_plural},
{:name => 'GroupCustomField', :partial => 'custom_fields/index',
:label => :label_group_plural},
{:name => 'TimeEntryActivityCustomField', :partial => 'custom_fields/index',
:label => TimeEntryActivity::OptionName},
{:name => 'IssuePriorityCustomField', :partial => 'custom_fields/index',
:label => IssuePriority::OptionName},
{:name => 'DocumentCategoryCustomField', :partial => 'custom_fields/index',
:label => DocumentCategory::OptionName}
]
CUSTOM_FIELDS_NAMES = CUSTOM_FIELDS_TABS.collect{|v| v[:name]}
def field_format=(arg)
# cannot change format of a saved custom field
super if new_record?
end end
def set_searchable def set_searchable
@@ -103,7 +80,7 @@ class CustomField < ActiveRecord::Base
when 'bool' when 'bool'
[[l(:general_text_Yes), '1'], [l(:general_text_No), '0']] [[l(:general_text_Yes), '1'], [l(:general_text_No), '0']]
else else
possible_values || [] read_possible_values_utf8_encoded || []
end end
end end
@@ -114,20 +91,14 @@ class CustomField < ActiveRecord::Base
when 'bool' when 'bool'
['1', '0'] ['1', '0']
else else
values = super() read_possible_values_utf8_encoded
if values.is_a?(Array)
values.each do |value|
value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
end
end
values || []
end end
end end
# Makes possible_values accept a multiline string # Makes possible_values accept a multiline string
def possible_values=(arg) def possible_values=(arg)
if arg.is_a?(Array) if arg.is_a?(Array)
super(arg.compact.collect(&:strip).select {|v| !v.blank?}) write_attribute(:possible_values, arg.compact.collect(&:strip).select {|v| !v.blank?})
else else
self.possible_values = arg.to_s.split(/[\n\r]+/) self.possible_values = arg.to_s.split(/[\n\r]+/)
end end
@@ -154,32 +125,16 @@ class CustomField < ActiveRecord::Base
casted casted
end end
def value_from_keyword(keyword, customized)
possible_values_options = possible_values_options(customized)
if possible_values_options.present?
keyword = keyword.to_s.downcase
if v = possible_values_options.detect {|text, id| text.downcase == keyword}
if v.is_a?(Array)
v.last
else
v
end
end
else
keyword
end
end
# Returns a ORDER BY clause that can used to sort customized # Returns a ORDER BY clause that can used to sort customized
# objects by their value of the custom field. # objects by their value of the custom field.
# Returns nil if the custom field can not be used for sorting. # Returns false, if the custom field can not be used for sorting.
def order_statement def order_statement
return nil if multiple? return nil if multiple?
case field_format case field_format
when 'string', 'text', 'list', 'date', 'bool' when 'string', 'text', 'list', 'date', 'bool'
# COALESCE is here to make sure that blank and NULL values are sorted equally # COALESCE is here to make sure that blank and NULL values are sorted equally
"COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" + "COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" +
" WHERE cv_sort.customized_type='#{self.class.customized_class.base_class.name}'" + " WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
" AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" + " AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
" AND cv_sort.custom_field_id=#{id} LIMIT 1), '')" " AND cv_sort.custom_field_id=#{id} LIMIT 1), '')"
when 'int', 'float' when 'int', 'float'
@@ -187,74 +142,18 @@ class CustomField < ActiveRecord::Base
# Postgresql will raise an error if a value can not be casted! # Postgresql will raise an error if a value can not be casted!
# CustomValue validations should ensure that it doesn't occur # CustomValue validations should ensure that it doesn't occur
"(SELECT CAST(cv_sort.value AS decimal(60,3)) FROM #{CustomValue.table_name} cv_sort" + "(SELECT CAST(cv_sort.value AS decimal(60,3)) FROM #{CustomValue.table_name} cv_sort" +
" WHERE cv_sort.customized_type='#{self.class.customized_class.base_class.name}'" + " WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
" AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" + " AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
" AND cv_sort.custom_field_id=#{id} AND cv_sort.value <> '' AND cv_sort.value IS NOT NULL LIMIT 1)" " AND cv_sort.custom_field_id=#{id} AND cv_sort.value <> '' AND cv_sort.value IS NOT NULL LIMIT 1)"
when 'user', 'version'
value_class.fields_for_order_statement(value_join_alias)
else else
nil nil
end end
end end
# Returns a GROUP BY clause that can used to group by custom value
# Returns nil if the custom field can not be used for grouping.
def group_statement
return nil if multiple?
case field_format
when 'list', 'date', 'bool', 'int'
order_statement
when 'user', 'version'
"COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" +
" WHERE cv_sort.customized_type='#{self.class.customized_class.base_class.name}'" +
" AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
" AND cv_sort.custom_field_id=#{id} LIMIT 1), '')"
else
nil
end
end
def join_for_order_statement
case field_format
when 'user', 'version'
"LEFT OUTER JOIN #{CustomValue.table_name} #{join_alias}" +
" ON #{join_alias}.customized_type = '#{self.class.customized_class.base_class.name}'" +
" AND #{join_alias}.customized_id = #{self.class.customized_class.table_name}.id" +
" AND #{join_alias}.custom_field_id = #{id}" +
" AND #{join_alias}.value <> ''" +
" AND #{join_alias}.id = (SELECT max(#{join_alias}_2.id) FROM #{CustomValue.table_name} #{join_alias}_2" +
" WHERE #{join_alias}_2.customized_type = #{join_alias}.customized_type" +
" AND #{join_alias}_2.customized_id = #{join_alias}.customized_id" +
" AND #{join_alias}_2.custom_field_id = #{join_alias}.custom_field_id)" +
" LEFT OUTER JOIN #{value_class.table_name} #{value_join_alias}" +
" ON CAST(#{join_alias}.value as decimal(60,0)) = #{value_join_alias}.id"
else
nil
end
end
def join_alias
"cf_#{id}"
end
def value_join_alias
join_alias + "_" + field_format
end
def <=>(field) def <=>(field)
position <=> field.position position <=> field.position
end end
# Returns the class that values represent
def value_class
case field_format
when 'user', 'version'
field_format.classify.constantize
else
nil
end
end
def self.customized_class def self.customized_class
self.name =~ /^(.+)CustomField$/ self.name =~ /^(.+)CustomField$/
begin; $1.constantize; rescue nil; end begin; $1.constantize; rescue nil; end
@@ -295,10 +194,6 @@ class CustomField < ActiveRecord::Base
validate_field_value(value).empty? validate_field_value(value).empty?
end end
def format_in?(*args)
args.include?(field_format)
end
protected protected
# Returns the error message for the given value regarding its format # Returns the error message for the given value regarding its format
@@ -323,4 +218,14 @@ class CustomField < ActiveRecord::Base
end end
errs errs
end end
def read_possible_values_utf8_encoded
values = read_attribute(:possible_values)
if values.is_a?(Array)
values.each do |value|
value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
end
end
values
end
end end
+6 -4
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # RedMine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -30,7 +30,7 @@ class Document < ActiveRecord::Base
validates_presence_of :project, :title, :category validates_presence_of :project, :title, :category
validates_length_of :title, :maximum => 60 validates_length_of :title, :maximum => 60
scope :visible, lambda {|*args| { :include => :project, named_scope :visible, lambda {|*args| { :include => :project,
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_documents, *args) } } :conditions => Project.allowed_to_condition(args.shift || User.current, :view_documents, *args) } }
safe_attributes 'category_id', 'title', 'description' safe_attributes 'category_id', 'title', 'description'
@@ -42,7 +42,9 @@ class Document < ActiveRecord::Base
def initialize(attributes=nil, *args) def initialize(attributes=nil, *args)
super super
if new_record? if new_record?
self.category ||= DocumentCategory.default # Rails3 use this instead
# self.category ||= DocumentCategory.default
self.category_id = DocumentCategory.default.id if self.category_id == 0
end end
end end
+4 -2
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -34,7 +34,9 @@ class DocumentCategory < Enumeration
def self.default def self.default
d = super d = super
d = first if d.nil? if d.nil?
d = find(:first)
end
d d
end end
end end
+1 -1
View File
@@ -1,5 +1,5 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License

Some files were not shown because too many files have changed in this diff Show More