Merge pull request #5 from ulferts/feature/merge_dev_into_apply_table_styling

Feature/merge dev into apply table styling
pull/3343/head
HDinger 9 years ago
commit ca5cf383d4
  1. 6
      .gitignore
  2. 102
      Gemfile
  3. 353
      Gemfile.lock
  4. 16
      Guardfile
  5. 2
      README.md
  6. 2
      Rakefile
  7. 9
      app/assets/javascripts/admin_users.js
  8. 1
      app/assets/javascripts/application.js.erb
  9. 2
      app/assets/javascripts/members_select_boxes.js
  10. 16
      app/assets/javascripts/tooltips.js
  11. 2
      app/assets/javascripts/work_packages.js.erb
  12. 1
      app/assets/stylesheets/content/_notifications.sass
  13. 12
      app/assets/stylesheets/content/_tooltips.lsg
  14. 47
      app/assets/stylesheets/content/_tooltips.sass
  15. 21
      app/assets/stylesheets/content/_work_packages.sass
  16. 2
      app/assets/stylesheets/layout/_top_menu.sass
  17. 1
      app/assets/stylesheets/styleguide.js
  18. 7
      app/controllers/account_controller.rb
  19. 8
      app/controllers/activities_controller.rb
  20. 7
      app/controllers/admin_controller.rb
  21. 22
      app/controllers/api/experimental/concerns/column_data.rb
  22. 16
      app/controllers/api/experimental/queries_controller.rb
  23. 2
      app/controllers/api/experimental/users_controller.rb
  24. 2
      app/controllers/api/experimental/versions_controller.rb
  25. 5
      app/controllers/api/experimental/work_packages_controller.rb
  26. 4
      app/controllers/api/v2/authentication_controller.rb
  27. 8
      app/controllers/api/v2/concerns/multiple_projects.rb
  28. 14
      app/controllers/api/v2/custom_fields_controller.rb
  29. 4
      app/controllers/api/v2/pagination/types_controller.rb
  30. 2
      app/controllers/api/v2/planning_element_journals_controller.rb
  31. 2
      app/controllers/api/v2/planning_element_priorities_controller.rb
  32. 2
      app/controllers/api/v2/planning_element_type_colors_controller.rb
  33. 6
      app/controllers/api/v2/planning_element_types_controller.rb
  34. 26
      app/controllers/api/v2/planning_elements_controller.rb
  35. 2
      app/controllers/api/v2/project_associations_controller.rb
  36. 2
      app/controllers/api/v2/project_types_controller.rb
  37. 17
      app/controllers/api/v2/projects_controller.rb
  38. 4
      app/controllers/api/v2/reported_project_statuses_controller.rb
  39. 38
      app/controllers/api/v2/reportings_controller.rb
  40. 2
      app/controllers/api/v2/statuses_controller.rb
  41. 2
      app/controllers/api/v2/timelines_controller.rb
  42. 2
      app/controllers/api/v2/users_controller.rb
  43. 2
      app/controllers/api/v2/versions_controller.rb
  44. 6
      app/controllers/api/v2/workflows_controller.rb
  45. 75
      app/controllers/application_controller.rb
  46. 4
      app/controllers/attachments_controller.rb
  47. 2
      app/controllers/auth_sources_controller.rb
  48. 1
      app/controllers/authentication_controller.rb
  49. 12
      app/controllers/boards_controller.rb
  50. 6
      app/controllers/categories_controller.rb
  51. 2
      app/controllers/concerns/omniauth_login.rb
  52. 9
      app/controllers/copy_projects_controller.rb
  53. 4
      app/controllers/custom_fields_controller.rb
  54. 4
      app/controllers/enumerations_controller.rb
  55. 58
      app/controllers/groups_controller.rb
  56. 22
      app/controllers/journals_controller.rb
  57. 32
      app/controllers/members_controller.rb
  58. 2
      app/controllers/messages_controller.rb
  59. 10
      app/controllers/my_controller.rb
  60. 9
      app/controllers/news_controller.rb
  61. 5
      app/controllers/planning_element_journals_controller.rb
  62. 1
      app/controllers/planning_element_type_colors_controller.rb
  63. 1
      app/controllers/project_associations_controller.rb
  64. 1
      app/controllers/project_types_controller.rb
  65. 71
      app/controllers/projects_controller.rb
  66. 7
      app/controllers/reported_project_statuses_controller.rb
  67. 29
      app/controllers/reportings_controller.rb
  68. 28
      app/controllers/repositories_controller.rb
  69. 10
      app/controllers/roles_controller.rb
  70. 2
      app/controllers/search_controller.rb
  71. 8
      app/controllers/settings_controller.rb
  72. 26
      app/controllers/sys_controller.rb
  73. 10
      app/controllers/time_entries/reports_controller.rb
  74. 3
      app/controllers/timelines_controller.rb
  75. 82
      app/controllers/timelog_controller.rb
  76. 24
      app/controllers/types_controller.rb
  77. 56
      app/controllers/users_controller.rb
  78. 26
      app/controllers/versions_controller.rb
  79. 8
      app/controllers/watchers_controller.rb
  80. 2
      app/controllers/welcome_controller.rb
  81. 18
      app/controllers/wiki_controller.rb
  82. 16
      app/controllers/wiki_menu_items_controller.rb
  83. 12
      app/controllers/work_package_relations_controller.rb
  84. 16
      app/controllers/work_packages/auto_completes_controller.rb
  85. 22
      app/controllers/work_packages/bulk_controller.rb
  86. 2
      app/controllers/work_packages/moves_controller.rb
  87. 4
      app/controllers/work_packages/reports_controller.rb
  88. 22
      app/controllers/work_packages_controller.rb
  89. 22
      app/controllers/workflows_controller.rb
  90. 4
      app/decorators/api/experimental/work_package_decorator.rb
  91. 53
      app/helpers/application_helper.rb
  92. 8
      app/helpers/avatar_helper.rb
  93. 4
      app/helpers/breadcrumb_helper.rb
  94. 72
      app/helpers/custom_fields_helper.rb
  95. 29
      app/helpers/issues_helper.rb
  96. 7
      app/helpers/journals_helper.rb
  97. 2
      app/helpers/my_helper.rb
  98. 4
      app/helpers/pagination_helper.rb
  99. 56
      app/helpers/password_helper.rb
  100. 4
      app/helpers/projects_helper.rb
  101. Some files were not shown because too many files have changed in this diff Show More

6
.gitignore vendored

@ -26,13 +26,13 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
# See http://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config
# Ignore bundler config.
/.bundle
# Ignore all logfiles and tempfiles.

@ -28,14 +28,18 @@
source 'https://rubygems.org'
gem "rails", "~> 3.2.22"
gem "coderay", "~> 1.1.0"
gem "rubytree", "~> 0.8.3"
gem "rdoc", ">= 2.4.2"
gem 'globalize', "~> 3.1.0"
gem 'rails', '4.0.13'
gem 'protected_attributes'
gem 'actionpack-action_caching'
gem 'activerecord-session_store'
gem 'rails-observers'
gem 'coderay', '~> 1.1.0'
gem 'rubytree', '~> 0.8.3'
gem 'rdoc', '>= 2.4.2'
gem 'globalize', '~> 4.0.3'
gem 'omniauth'
gem 'request_store', "~> 1.1.0"
gem 'request_store', '~> 1.1.0'
gem 'gravatar_image_tag', '~> 1.2.0'
gem 'warden', '~> 1.2'
@ -43,15 +47,17 @@ gem 'warden-basic_auth', '~> 0.2.1'
# TODO: adds #auto_link which was deprecated in rails 3.1
gem 'rails_autolink', '~> 1.1.6'
gem "will_paginate", '~> 3.0'
gem "acts_as_list", "~> 0.3.0"
gem 'will_paginate', '~> 3.0'
gem 'acts_as_list', '~> 0.3.0'
gem 'acts_as_countable', git: "https://github.com/finnlabs/acts_as_countable.git", ref: '2471265'
gem 'awesome_nested_set'
gem 'friendly_id', '~> 5.1.0'
gem 'awesome_nested_set', github: 'finnlabs/awesome_nested_set', branch: 'v2.1.6-rails4'
gem 'color-tools', '~> 1.3.0', :require => 'color'
gem 'color-tools', '~> 1.3.0', require: 'color'
gem "ruby-progressbar"
gem 'ruby-progressbar'
# to generate html-diffs (e.g. for wiki comparison)
gem 'htmldiff'
@ -60,7 +66,7 @@ gem 'htmldiff'
# used for statistics on svn repositories
gem 'svg-graph'
gem "date_validator", '~> 0.7.1'
gem 'date_validator', '~> 0.7.1'
gem 'ruby-duration', '~> 3.2.0'
# We rely on this specific version, which is the latest as of now (end of 2013),
@ -71,25 +77,19 @@ gem 'rabl', '0.9.3'
gem 'multi_json', '~> 1.11.0'
gem 'oj', '~> 2.11.4'
# will need to be removed once we are on rails4 as it will be part of the rails4 core
gem 'strong_parameters'
# we need the old Version to be compatible with pgsql 8.4
# see: http://stackoverflow.com/questions/14862144/rake-jobswork-gives-pgerror-error-select-for-update-share-is-not-allowed-in
# or: https://github.com/collectiveidea/delayed_job/issues/323
gem 'delayed_job_active_record', '0.3.3'
gem 'delayed_job_active_record', '~> 4.0.2'
gem 'daemons'
# include custom rack-protection for now until rkh/rack-protection is fixed and released
# (see https://community.openproject.org/work_packages/3029)
gem 'rack-protection', :git => "https://github.com/finnlabs/rack-protection.git", :ref => '5a7d1bd'
gem 'rack-protection', git: 'https://github.com/finnlabs/rack-protection.git', ref: '5a7d1bd'
# Rack::Attack is a rack middleware to protect your web app from bad clients.
# It allows whitelisting, blacklisting, throttling, and tracking based on arbitrary properties of the request.
# https://github.com/kickstarter/rack-attack
gem 'rack-attack'
gem 'syck', :platforms => [:mri, :mingw, :x64_mingw], :require => false
gem 'syck', platforms: [:mri, :mingw, :x64_mingw], require: false
gem 'gon', '~> 4.0'
@ -104,20 +104,18 @@ group :production do
gem 'dalli', '~> 2.7.2'
end
gem 'sprockets', git: 'https://github.com/tessi/sprockets.git', branch: '2_2_2_backport2'
gem 'sprockets-rails', git: 'https://github.com/finnlabs/sprockets-rails.git', branch: 'backport'
gem 'sprockets', '~> 2.12.3'
gem 'non-stupid-digest-assets'
gem 'sass-rails', git: 'https://github.com/guilleiguaran/sass-rails.git', branch: 'backport'
gem 'sass-rails', '~> 5.0.3'
gem 'sass', '~> 3.4.12'
gem 'autoprefixer-rails'
gem 'execjs', '~> 2.4.0'
gem 'bourbon', '~> 4.2.0'
gem 'uglifier', '>= 1.0.3', require: false
gem "prototype-rails"
gem 'prototype-rails'
# remove once we no longer use the deprecated "link_to_remote", "remote_form_for" and alike methods
# replace those with :remote => true
gem 'prototype_legacy_helper', '0.0.0', :git => 'https://github.com/rails/prototype_legacy_helper.git'
gem 'prototype_legacy_helper', '0.0.0', git: 'https://github.com/rails/prototype_legacy_helper.git'
# small wrapper around the command line
gem 'cocaine'
@ -130,35 +128,28 @@ gem 'unicorn'
# Gems we don't depend directly on, but specify here to make sure we don't use a vulnerable
# version. Please add a link to a security advisory when adding a Gem here.
gem 'rack', '~>1.4.7'
gem 'i18n', '~> 0.6.8'
# see https://groups.google.com/forum/#!topic/ruby-security-ann/pLrh6DUw998
gem 'rack', '~> 1.5.4' # CVE-2015-3225
gem 'nokogiri', '~> 1.6.6'
gem 'carrierwave', '~> 0.10.0'
gem 'fog', '~> 1.23.0', require: "fog/aws/storage"
gem 'fog', '~> 1.23.0', require: 'fog/aws/storage'
group :test do
gem 'rack-test', '~> 0.6.2'
gem 'shoulda-context', '~> 1.2'
gem 'object-daddy', '~> 1.1.0'
gem "launchy", "~> 2.3.0"
gem "factory_girl_rails", "~> 4.5"
gem 'cucumber-rails', "~> 1.4.2", :require => false
gem 'launchy', '~> 2.3.0'
gem 'factory_girl_rails', '~> 4.5'
gem 'cucumber-rails', '~> 1.4.2', require: false
gem 'rack_session_access'
# restrict because in version 1.3 a lot of tests using acts as journalized
# fail stating: "Column 'user_id' cannot be null". I don't understand the
# connection with database cleaner here but setting it to 1.2 fixes the
# issue.
gem 'database_cleaner', '~> 1.2.0'
gem 'database_cleaner', '~> 1.4.1'
gem 'rspec', '~> 3.3.0'
# also add to development group, so "spec" rake task gets loaded
gem 'rspec-rails', '~> 3.3.0', group: :development
gem 'rspec-activemodel-mocks'
gem 'rspec-example_disabler', git: "https://github.com/finnlabs/rspec-example_disabler.git"
gem 'rspec-example_disabler', git: 'https://github.com/finnlabs/rspec-example_disabler.git'
gem 'rspec-legacy_formatters'
gem 'capybara', '~> 2.4.4'
gem 'capybara-screenshot', '~> 1.0.4'
@ -167,24 +158,23 @@ group :test do
gem 'selenium-webdriver', '~> 2.46.2'
gem 'timecop', '~> 0.7.1'
gem 'rb-readline', "~> 0.5.1" # ruby on CI needs this
gem 'rb-readline', '~> 0.5.1' # ruby on CI needs this
# why in Gemfile? see: https://github.com/guard/guard-test
gem 'ruby-prof'
gem 'simplecov', '0.8.0.pre'
gem "shoulda-matchers", '~> 2.8', require: nil
gem "json_spec"
gem "activerecord-tableless", "~> 1.0"
gem 'shoulda-matchers', '~> 2.8', require: nil
gem 'json_spec'
gem 'activerecord-tableless', '~> 1.0'
gem 'codecov', require: nil
gem 'equivalent-xml', '~> 0.5.1'
end
group :ldap do
gem "net-ldap", '~> 0.8.0'
gem 'net-ldap', '~> 0.8.0'
end
group :development do
gem 'letter_opener', '~> 1.3.0'
gem 'rails-dev-tweaks', '~> 0.6.1'
gem 'thin'
gem 'faker'
gem 'quiet_assets'
@ -195,7 +185,7 @@ group :development, :test do
gem 'pry-rails'
gem 'pry-stack_explorer'
gem 'pry-rescue'
gem 'pry-byebug', :platforms => [:mri]
gem 'pry-byebug', platforms: [:mri]
gem 'pry-doc'
end
@ -212,32 +202,32 @@ gem 'reform', '~> 1.2.6', require: false
platforms :mri, :mingw, :x64_mingw do
group :mysql2 do
gem "mysql2", "~> 0.3.11"
gem 'mysql2', '~> 0.3.11'
end
group :postgres do
gem 'pg', "~> 0.17.1"
gem 'pg', '~> 0.17.1'
end
end
platforms :jruby do
gem "jruby-openssl"
gem 'jruby-openssl'
group :mysql do
gem "activerecord-jdbcmysql-adapter"
gem 'activerecord-jdbcmysql-adapter'
end
group :postgres do
gem "activerecord-jdbcpostgresql-adapter"
gem 'activerecord-jdbcpostgresql-adapter'
end
end
group :opf_plugins do
gem 'openproject-translations', git:'https://github.com/opf/openproject-translations.git', branch: 'dev'
gem 'openproject-translations', git:'https://github.com/opf/openproject-translations.git', branch: 'feature/rails4'
end
# Load Gemfile.local, Gemfile.plugins and plugins' Gemfiles
Dir.glob File.expand_path("../{Gemfile.local,Gemfile.plugins,lib/plugins/*/Gemfile}", __FILE__) do |file|
Dir.glob File.expand_path('../{Gemfile.local,Gemfile.plugins,lib/plugins/*/Gemfile}', __FILE__) do |file|
next unless File.readable?(file)
eval_gemfile(file)
end

@ -1,3 +1,11 @@
GIT
remote: git://github.com/finnlabs/awesome_nested_set.git
revision: 7bd473e845e2f17f5287e8b7534bd88d4bbbf7d6
branch: v2.1.6-rails4
specs:
awesome_nested_set (2.1.6)
activerecord (>= 3.0.0)
GIT
remote: git://github.com/goodwill/capybara-select2.git
revision: c0826f33707b85fd39a838c6909ee12d0bff64a1
@ -27,35 +35,15 @@ GIT
specs:
rspec-example_disabler (0.0.1)
GIT
remote: https://github.com/finnlabs/sprockets-rails.git
revision: e069c097056e28e3cd4adc4ee8bb2a895c71bfc1
branch: backport
specs:
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (= 2.2.2.backport2)
GIT
remote: https://github.com/guilleiguaran/sass-rails.git
revision: 0393d9e1a6e4a776e61f16fb75f97971b9f4abd2
branch: backport
specs:
sass-rails (4.0.1)
railties (>= 3.2.0, < 5.0)
sass (>= 3.2.0)
sprockets-rails (~> 2.0.0.backport1)
GIT
remote: https://github.com/opf/openproject-translations.git
revision: 2d32beb3c1704a45a4b9c2d674a5a73b07486018
branch: dev
revision: ebe6d82d98d156ff171103eded22d116a5feb0a5
branch: feature/rails4
specs:
openproject-translations (5.0.0.pre.alpha)
openproject-translations (4.3.0)
crowdin-api (~> 0.2.4)
mixlib-shellout (~> 2.1.0)
rails (~> 3.2.14)
rails (~> 4.0.13)
rubyzip
GIT
@ -64,64 +52,54 @@ GIT
specs:
prototype_legacy_helper (0.0.0)
GIT
remote: https://github.com/tessi/sprockets.git
revision: 1e56fd0a92a9fda93dab4550ab3cf82138d097ac
branch: 2_2_2_backport2
specs:
sprockets (2.2.2.backport2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.22)
actionpack (= 3.2.22)
mail (~> 2.5.4)
actionpack (3.2.22)
activemodel (= 3.2.22)
activesupport (= 3.2.22)
builder (~> 3.0.0)
actionmailer (4.0.13)
actionpack (= 4.0.13)
mail (~> 2.5, >= 2.5.4)
actionpack (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.22)
activesupport (= 3.2.22)
builder (~> 3.0.0)
activerecord (3.2.22)
activemodel (= 3.2.22)
activesupport (= 3.2.22)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activerecord-tableless (1.3.3)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionpack-action_caching (1.1.1)
actionpack (>= 4.0.0, < 5.0)
activemodel (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
activerecord (4.0.13)
activemodel (= 4.0.13)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.13)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.4)
activerecord-session_store (0.1.1)
actionpack (>= 4.0.0, < 5)
activerecord (>= 4.0.0, < 5)
railties (>= 4.0.0, < 5)
activerecord-tableless (1.3.4)
activerecord (>= 2.3.0)
activeresource (3.2.22)
activemodel (= 3.2.22)
activesupport (= 3.2.22)
activesupport (3.2.22)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
activesupport (4.0.13)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
acts_as_list (0.3.0)
activerecord (>= 3.0)
addressable (2.3.4)
addressable (2.3.8)
airbrake (4.1.0)
builder
multi_json
arel (3.0.3)
arel (4.0.2)
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
autoprefixer-rails (5.1.5)
autoprefixer-rails (5.1.11)
execjs
json
awesome_nested_set (2.1.6)
activerecord (>= 3.0.0)
awesome_print (1.6.1)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
@ -129,10 +107,10 @@ GEM
thread_safe (~> 0.3, >= 0.3.1)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bourbon (4.2.0)
bourbon (4.2.3)
sass (~> 3.4)
thor
builder (3.0.4)
builder (3.1.4)
byebug (2.7.0)
columnize (~> 0.3)
debugger-linecache (~> 1.2)
@ -144,9 +122,8 @@ GEM
xpath (~> 2.0)
capybara-ng (0.2.1)
awesome_print (>= 1.2.0)
capybara-screenshot (1.0.5)
capybara-screenshot (1.0.9)
capybara (>= 1.0, < 3)
colored
launchy
carrierwave (0.10.0)
activemodel (>= 3.2.0)
@ -157,9 +134,9 @@ GEM
ffi (~> 1.0, >= 1.0.11)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.4)
cocaine (0.5.7)
climate_control (>= 0.0.3, < 1.0)
codecov (0.0.6)
codecov (0.0.8)
json
simplecov
url
@ -167,53 +144,52 @@ GEM
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
color-tools (1.3.0)
colored (1.2)
columnize (0.8.9)
columnize (0.9.0)
crowdin-api (0.2.8)
rest-client (~> 1.6.8)
cucumber (1.3.18)
cucumber (1.3.19)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.1)
multi_test (>= 0.1.2)
cucumber-rails (1.4.2)
capybara (>= 1.1.2, < 3)
cucumber (>= 1.3.8, < 2)
mime-types (>= 1.16, < 3)
nokogiri (~> 1.5)
rails (>= 3, < 5)
daemons (1.1.9)
dalli (2.7.2)
database_cleaner (1.2.0)
daemons (1.2.2)
dalli (2.7.4)
database_cleaner (1.4.1)
date_validator (0.7.1)
activemodel
debug_inspector (0.0.2)
debugger-linecache (1.2.0)
delayed_job (3.0.5)
activesupport (~> 3.0)
delayed_job_active_record (0.3.3)
activerecord (>= 2.1.0, < 4)
delayed_job (~> 3.0)
delayed_job (4.0.6)
activesupport (>= 3.0, < 5.0)
delayed_job_active_record (4.0.3)
activerecord (>= 3.0, < 5.0)
delayed_job (>= 3.0, < 4.1)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.2.5)
disposable (0.0.9)
representable (~> 2.0)
uber
equalizer (0.0.9)
equalizer (0.0.11)
equivalent-xml (0.5.1)
nokogiri (>= 1.4.3)
erubis (2.7.0)
eventmachine (1.0.7)
excon (0.42.1)
excon (0.45.3)
execjs (2.4.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
faker (1.2.0)
faker (1.4.3)
i18n (~> 0.5)
ffi (1.9.10)
fog (1.23.0)
@ -227,25 +203,28 @@ GEM
fog-core (~> 1.22)
fog-json
inflecto (~> 0.0.2)
fog-core (1.25.0)
fog-core (1.30.0)
builder
excon (~> 0.38)
excon (~> 0.45)
formatador (~> 0.2)
mime-types
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
fog-json (1.0.0)
fog-json (1.0.1)
fog-core (~> 1.0)
multi_json (~> 1.0)
fog-softlayer (0.3.25)
fog-softlayer (0.4.6)
fog-core
fog-json
formatador (0.2.5)
friendly_id (5.1.0)
activerecord (>= 4.0.0)
gherkin (2.12.2)
multi_json (~> 1.3)
globalize (3.1.0)
activemodel (>= 3.1.0, < 4.0.0)
activerecord (>= 3.1.0, < 4.0.0)
gon (4.0.0)
globalize (4.0.3)
activemodel (>= 4.0.0, < 5)
activerecord (>= 4.0.0, < 5)
gon (4.1.1)
actionpack (>= 2.3.0)
json
grape (0.10.1)
@ -259,36 +238,35 @@ GEM
rack-mount
virtus (>= 1.0.0)
gravatar_image_tag (1.2.0)
hashie (2.1.1)
hashie (3.4.1)
hike (1.2.3)
htmldiff (0.0.1)
i18n (0.6.11)
i18n (0.7.0)
ice_nine (0.11.1)
inflecto (0.0.2)
interception (0.3)
interception (0.5)
ipaddress (0.8.0)
iso8601 (0.8.2)
journey (1.0.4)
iso8601 (0.8.6)
json (1.8.2)
json_spec (1.1.4)
multi_json (~> 1.0)
rspec (>= 2.0, < 4.0)
kgio (2.9.2)
kgio (2.9.3)
launchy (2.3.0)
addressable (~> 2.3)
letter_opener (1.3.0)
launchy (~> 2.2)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mail (2.6.3)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (1.25.1)
mini_portile (0.6.2)
minitest (4.7.5)
mixlib-shellout (2.1.0)
multi_json (1.11.0)
multi_test (0.1.1)
multi_json (1.11.2)
multi_test (0.1.2)
multi_xml (0.5.5)
mysql2 (0.3.17)
mysql2 (0.3.18)
net-ldap (0.8.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
@ -297,17 +275,18 @@ GEM
mini_portile (~> 0.6.0)
non-stupid-digest-assets (1.0.4)
object-daddy (1.1.1)
oj (2.11.4)
omniauth (1.2.1)
hashie (>= 1.2, < 3)
oj (2.11.5)
omniauth (1.2.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
parser (2.2.2.5)
ast (>= 1.1, < 3.0)
pg (0.17.1)
polyglot (0.3.5)
powerpack (0.1.1)
prototype-rails (3.2.1)
rails (~> 3.2)
protected_attributes (1.0.9)
activemodel (>= 4.0.1, < 5.0)
prototype-rails (4.0.1)
rails (~> 4.0)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
@ -315,62 +294,55 @@ GEM
pry-byebug (1.3.2)
byebug (~> 2.7)
pry (~> 0.9.12)
pry-doc (0.4.6)
pry (>= 0.9)
yard (>= 0.8)
pry-rails (0.3.2)
pry-doc (0.6.0)
pry (~> 0.9)
yard (~> 0.8)
pry-rails (0.3.4)
pry (>= 0.9.10)
pry-rescue (1.1.1)
interception (>= 0.3)
pry-rescue (1.4.2)
interception (>= 0.5)
pry
pry-stack_explorer (0.4.9.1)
pry-stack_explorer (0.4.9.2)
binding_of_caller (>= 0.7)
pry (>= 0.9.11)
quiet_assets (1.0.2)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rabl (0.9.3)
activesupport (>= 2.3.14)
rack (1.4.7)
rack (1.5.5)
rack-accept (0.4.5)
rack (>= 0.4)
rack-attack (4.2.0)
rack
rack-cache (1.2)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.4)
rack
rack-test (0.6.3)
rack (>= 1.0)
rack_session_access (0.1.1)
builder (>= 2.0.0)
rack (>= 1.0.0)
rails (3.2.22)
actionmailer (= 3.2.22)
actionpack (= 3.2.22)
activerecord (= 3.2.22)
activeresource (= 3.2.22)
activesupport (= 3.2.22)
bundler (~> 1.0)
railties (= 3.2.22)
rails-dev-tweaks (0.6.1)
actionpack (~> 3.1)
railties (~> 3.1)
rails (4.0.13)
actionmailer (= 4.0.13)
actionpack (= 4.0.13)
activerecord (= 4.0.13)
activesupport (= 4.0.13)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.13)
sprockets-rails (~> 2.0)
rails-observers (0.1.2)
activemodel (~> 4.0)
rails_autolink (1.1.6)
rails (> 3.1)
railties (3.2.22)
actionpack (= 3.2.22)
activesupport (= 3.2.22)
rack-ssl (~> 1.3.2)
railties (4.0.13)
actionpack (= 4.0.13)
activesupport (= 4.0.13)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
raindrops (0.13.0)
rake (10.4.2)
rb-readline (0.5.1)
rdoc (3.12.2)
rb-readline (0.5.2)
rdoc (4.2.0)
json (~> 1.4)
reform (1.2.6)
activemodel
@ -420,17 +392,23 @@ GEM
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-duration (3.2.0)
ruby-duration (3.2.1)
activesupport (>= 3.0.0)
i18n
iso8601
ruby-prof (0.13.0)
ruby-progressbar (1.7.1)
ruby-prof (0.15.8)
ruby-progressbar (1.7.5)
rubytree (0.8.3)
json (>= 1.7.5)
structured_warnings (>= 0.1.3)
rubyzip (1.1.6)
sass (3.4.12)
rubyzip (1.1.7)
sass (3.4.13)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
selenium-webdriver (2.46.2)
childprocess (~> 0.5)
multi_json (~> 1.0)
@ -443,36 +421,35 @@ GEM
multi_json
simplecov-html (~> 0.7.1)
simplecov-html (0.7.1)
slop (3.5.0)
strong_parameters (0.2.1)
actionpack (~> 3.0)
activemodel (~> 3.0)
railties (~> 3.0)
structured_warnings (0.1.4)
slop (3.6.0)
sprockets (2.12.4)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.3.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
structured_warnings (0.2.0)
svg-graph (1.0.5)
syck (1.0.1)
thin (1.5.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
syck (1.0.5)
thin (1.6.3)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0)
rack (~> 1.0)
thor (0.19.1)
thread_safe (0.3.4)
thread_safe (0.3.5)
tilt (1.4.1)
timecop (0.7.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.43)
timecop (0.7.3)
tzinfo (0.3.44)
uber (0.0.13)
uglifier (2.1.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
unicorn (4.8.3)
unicorn (4.9.0)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
url (0.3.2)
virtus (1.0.4)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
@ -482,23 +459,25 @@ GEM
warden-basic_auth (0.2.1)
warden (~> 1.2)
websocket (1.2.2)
will_paginate (3.0.5)
will_paginate (3.0.7)
xpath (2.0.0)
nokogiri (~> 1.3)
yard (0.8.7.2)
yard (0.8.7.6)
PLATFORMS
ruby
DEPENDENCIES
actionpack-action_caching
activerecord-jdbcmysql-adapter
activerecord-jdbcpostgresql-adapter
activerecord-session_store
activerecord-tableless (~> 1.0)
acts_as_countable!
acts_as_list (~> 0.3.0)
airbrake (~> 4.1.0)
autoprefixer-rails
awesome_nested_set
awesome_nested_set!
bourbon (~> 4.2.0)
capybara (~> 2.4.4)
capybara-ng (~> 0.2.1)
@ -512,20 +491,20 @@ DEPENDENCIES
cucumber-rails (~> 1.4.2)
daemons
dalli (~> 2.7.2)
database_cleaner (~> 1.2.0)
database_cleaner (~> 1.4.1)
date_validator (~> 0.7.1)
delayed_job_active_record (= 0.3.3)
delayed_job_active_record (~> 4.0.2)
equivalent-xml (~> 0.5.1)
execjs (~> 2.4.0)
factory_girl_rails (~> 4.5)
faker
fog (~> 1.23.0)
globalize (~> 3.1.0)
friendly_id (~> 5.1.0)
globalize (~> 4.0.3)
gon (~> 4.0)
grape (~> 0.10.1)
gravatar_image_tag (~> 1.2.0)
htmldiff
i18n (~> 0.6.8)
jruby-openssl
json_spec
launchy (~> 2.3.0)
@ -540,6 +519,7 @@ DEPENDENCIES
omniauth
openproject-translations!
pg (~> 0.17.1)
protected_attributes
prototype-rails
prototype_legacy_helper (= 0.0.0)!
pry-byebug
@ -549,13 +529,13 @@ DEPENDENCIES
pry-stack_explorer
quiet_assets
rabl (= 0.9.3)
rack (~> 1.4.7)
rack (~> 1.5.4)
rack-attack
rack-protection!
rack-test (~> 0.6.2)
rack_session_access
rails (~> 3.2.22)
rails-dev-tweaks (~> 0.6.1)
rails (= 4.0.13)
rails-observers
rails_autolink (~> 1.1.6)
rb-readline (~> 0.5.1)
rdoc (>= 2.4.2)
@ -573,19 +553,16 @@ DEPENDENCIES
ruby-progressbar
rubytree (~> 0.8.3)
sass (~> 3.4.12)
sass-rails!
sass-rails (~> 5.0.3)
selenium-webdriver (~> 2.46.2)
shoulda-context (~> 1.2)
shoulda-matchers (~> 2.8)
simplecov (= 0.8.0.pre)
sprockets!
sprockets-rails!
strong_parameters
sprockets (~> 2.12.3)
svg-graph
syck
thin
timecop (~> 0.7.1)
uglifier (>= 1.0.3)
unicorn
warden (~> 1.2)
warden-basic_auth (~> 0.2.1)

@ -43,15 +43,15 @@
guard :rspec do # , :cli => "--drb" do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
watch('spec/spec_helper.rb') { 'spec' }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
watch('config/routes.rb') { 'spec/routing' }
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
@ -67,14 +67,14 @@ end
# watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
# end
guard :test, :all_on_start => false, :all_after_pass => false do # , :drb => true do
guard :test, all_on_start: false, all_after_pass: false do # , :drb => true do
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
watch(%r{^test/.+_test\.rb$})
watch('test/test_helper.rb') { "test" }
watch('test/test_helper.rb') { 'test' }
# Rails example
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
watch(%r{^app/views/.+\.rb$}) { "test/integration" }
watch('app/controllers/application_controller.rb') { ["test/functional", "test/integration"] }
watch(%r{^app/views/.+\.rb$}) { 'test/integration' }
watch('app/controllers/application_controller.rb') { ['test/functional', 'test/integration'] }
end

@ -1,5 +1,5 @@
# OpenProject
[<img src="https://travis-ci.org/opf/openproject.svg?branch=dev" alt="Build Status" />](https://travis-ci.org/opf/openproject)
[<img src="https://travis-ci.org/opf/openproject.svg?branch=feature/rails4" alt="Build Status" />](https://travis-ci.org/opf/openproject)
[<img src="https://gemnasium.com/opf/openproject.png" alt="Dependency Status" />](https://gemnasium.com/opf/openproject)
[![Code Climate](https://codeclimate.com/github/opf/openproject/badges/gpa.svg)](https://codeclimate.com/github/opf/openproject)
[![codecov.io](http://codecov.io/github/opf/openproject/coverage.svg?branch=dev)](http://codecov.io/github/opf/openproject?branch=dev)

@ -35,4 +35,4 @@ require File.expand_path('../config/application', __FILE__)
OpenProject::Application.load_tasks
Rake::Task[:default].clear
task :default => 'test:suite:run'
task default: 'test:suite:run'

@ -43,10 +43,15 @@
// Hide password fields when non-internal authentication source is selected
function on_auth_source_change() {
var passwordFields = jQuery('#password_fields'),
passwordInputs = passwordFields.find('#user_password, #user_password_confirmation');
if (this.value === '') {
jQuery('#password_fields').show();
passwordFields.show();
passwordInputs.removeAttr('disabled');
} else {
jQuery('#password_fields').hide();
passwordFields.hide();
passwordInputs.prop('disabled', 'disabled');
}
}

@ -62,6 +62,7 @@
//= require date-range
//= require search
//= require colors
//= require tooltips
//source: http://stackoverflow.com/questions/8120065/jquery-and-prototype-dont-work-together-with-array-prototype-reverse
if (typeof []._reverse == 'undefined') {

@ -83,7 +83,7 @@ jQuery(document).ready(function($) {
q: term, //search term
page_limit: 10, // page size
page: page, // current page number
id: fakeInput.attr("data-projectId") // current project id
project_id: fakeInput.attr("data-projectId") // current project id
};
},
results: function (data, page) {

@ -0,0 +1,16 @@
jQuery(function($) {
var tooltipTriggers = $('.advanced-tooltip-trigger');
tooltipTriggers.each(function (index, el) {
var tooltip = $("#" + $(el).attr('aria-describedby'));
$(el).bind('mouseover focus', function () {
var top = $(this).offset().top - $(window).scrollTop();
// Adjust top for small elements
var POINTER_HEIGHT = 16.5;
var middle = $(this).outerHeight() / 2;
if (middle < POINTER_HEIGHT) top -= POINTER_HEIGHT - middle;
tooltip.css({'opacity': 1, 'visibility': 'visible', 'top': top});
}).bind('mouseout focusout', function () {
tooltip.css({'opacity': 0, 'visibility': 'hidden'});
});
});
});

@ -101,7 +101,7 @@ var WorkPackage = WorkPackage || {};
// remove blank lines generated by redmine format_text
text = text.replace(/^\s*$[\n\r]{1,}/gm, '');
var quotedText = "<%= ::I18n.t(:text_user_wrote, :value => "{{{user}}}", :locale => Setting.default_language.to_s.gsub(%r{(.+)\-(.+)$}) { "#{$1}-#{$2.upcase}" }) %>\n> ";
var quotedText = "<%= ::I18n.t(:text_user_wrote, :value => "{{{user}}}", :locale => Setting.default_language.to_s.gsub(%r{(.+)\-(.+)$}) { "#{$1}-#{$2.upcase}" }.presence || 'en') %>\n> ";
quotedText = quotedText.replace("{{{user}}}", user);
quotedText += text.replace(/(\r?\n|\r\n?)/g, "\n> ") + "\n\n";

@ -97,6 +97,7 @@ $nm-upload-box-padding: rem-calc(15) rem-calc(25)
.notification-box
@extend %notification
z-index: 21
+notification-layout($x: left, $y: top, $size: auto, $offset: rem-calc(0))
+notification-style($background: $nm-color-background, $color: $nm-font-color, $padding: $nm-padding-box, $radius: $nm-border-radius)
.notification-icon

@ -107,6 +107,18 @@ These can contain simple texts but are not suitable for HTML within the Tooltip.
Note that the tabindex has to be set manually on the `<span>` and not the containing element. `tabindex="0"` makes the item tabbable at all.
### HTML tooltips
```
<span class="advanced-tooltip-trigger" aria-describedby="advanced-tooltip-sample">
<i class="icon icon-help1"></i>
</span>
<div class="advanced-tooltip-content" id="advanced-tooltip-sample">
<p>The content of an HTML tooltip.</p>
<img src="http://openproject.sourceforge.net/images/openproject-logo.png" alt="OpenProject">
</div>
```
### Inline text
```

@ -35,6 +35,7 @@ $tooltip--border: none
$tooltip--height: 22px
$tooltip--font-color: $body-font-color
$tooltip--arrow-size: 6px
$advanced-tooltip--border: 1px solid #a7cbe1
%tooltip--top-bottom
&:before, &:after
@ -182,3 +183,49 @@ table
padding: 4px
font-size: 0.8em
color: #505050
// tooltips with html support
.advanced-tooltip-content
visibility: hidden
opacity: 0
transition: visibility 0s linear 0.2s, opacity 0.2s linear
position: fixed
border: $advanced-tooltip--border
border-radius: 3px
background: $tooltip--background-color
padding: 15px
font-style: italic
font-size: small
line-height: 18px
width: 305px
display: inline-block
margin-left: 14px
z-index: 99
*
font-size: small
ul
margin: 1em
padding-left: 1.2em
&:after
content: ''
display: block
position: absolute
top: 9px
left: -14px
width: 0
height: 0
border-color: transparent #e3f5ff transparent transparent
border-style: solid
border-width: 7px
&:before
content: ''
display: block
position: absolute
top: 8px
left: -16px
width: 0
height: 0
border-color: transparent #a7cbe1 transparent transparent
border-style: solid
border-width: 8px

@ -40,6 +40,27 @@
font-size: 1.125rem
font-weight: bold
div[class*='work-packages--details--']
width: 100%
.inplace-edit--read-value
.dynamic-attribute
width: 100%
span
overflow: hidden
text-overflow: ellipsis
display: block
p
overflow: inherit
text-overflow: inherit
a
overflow: inherit
text-overflow: inherit
display: inherit
.work-packages--details--subject
@include grid-content
@include grid-size(expand)

@ -44,7 +44,7 @@
height: $header-height
width: 100%
padding: 0
z-index: 21
z-index: 22
position: relative
border-bottom: $header-border-bottom-width solid $header-border-bottom-color

@ -27,3 +27,4 @@
//++
//= require ../javascripts/bundles/openproject-global
//= require ../javascripts/tooltips

@ -67,11 +67,12 @@ class AccountController < ApplicationController
return redirect_to(home_url) unless allow_lost_password_recovery?
if params[:token]
@token = Token.find_by_action_and_value('recovery', params[:token].to_s)
@token = Token.find_by(action: 'recovery', value: params[:token].to_s)
redirect_to(home_url) && return unless @token and !@token.expired?
@user = @token.user
if request.post?
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
@user.password = params[:new_password]
@user.password_confirmation = params[:new_password_confirmation]
@user.force_password_change = false
if @user.save
@token.destroy
@ -153,7 +154,7 @@ class AccountController < ApplicationController
# Token based account activation
def activate
return redirect_to(home_url) unless Setting.self_registration? && params[:token]
token = Token.find_by_action_and_value('register', params[:token].to_s)
token = Token.find_by(action: 'register', value: params[:token].to_s)
redirect_to(home_url) && return unless token and !token.expired?
user = token.user
redirect_to(home_url) && return unless user.registered?

@ -55,11 +55,11 @@ class ActivitiesController < ApplicationController
if events.empty? || stale?(etag: [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
respond_to do |format|
format.html {
format.html do
@events_by_day = events.group_by { |e| e.event_datetime.to_date }
render layout: false if request.xhr?
}
format.atom {
end
format.atom do
title = l(:label_activity)
if @author
title = @author.name
@ -67,7 +67,7 @@ class ActivitiesController < ApplicationController
title = l("label_#{@activity.scope.first.singularize}_plural")
end
render_feed(events, title: "#{@project || Setting.app_title}: #{title}")
}
end
end
end

@ -51,8 +51,7 @@ class AdminController < ApplicationController
c << ['LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?', name, name]
end
@projects = Project.find :all, order: 'lft',
conditions: c.conditions
@projects = Project.order('lft').where(c.conditions)
render action: 'projects', layout: false if request.xhr?
end
@ -76,8 +75,8 @@ class AdminController < ApplicationController
end
def force_user_language
available_languages = Setting.find_by_name('available_languages').value
User.find(:all, conditions: ['language not in (?)', available_languages]).each do |u|
available_languages = Setting.find_by(name: 'available_languages').value
User.where(['language not in (?)', available_languages]).each do |u|
u.language = Setting.default_language
u.save
end

@ -109,10 +109,10 @@ module Api::Experimental::Concerns::ColumnData
existing_cf_ids = existing_custom_field_ids(custom_field_ids)
valid_cf_column_names = columns.select do |name|
valid_cf_column_names = columns.select { |name|
id = custom_field_id_in(name)
existing_cf_ids.include?(id)
end
}
# keep order of provided columns
columns & (valid_column_names + valid_cf_column_names)
@ -171,9 +171,9 @@ module Api::Experimental::Concerns::ColumnData
work_packages.map { |wp| yield wp }
.uniq
.inject({}) do |group_sums, current_group|
work_packages_in_current_group = work_packages.select do |wp|
work_packages_in_current_group = work_packages.select { |wp|
(yield wp) == current_group
end
}
group_sums.merge current_group => column_sum(column_name, work_packages_in_current_group)
end
@ -194,13 +194,13 @@ module Api::Experimental::Concerns::ColumnData
def fetch_columns_data(column_names, work_packages)
column_names, custom_field_column_ids = separate_columns_by_custom_fields(column_names)
columns = column_names.map do |column_name|
columns = column_names.map { |column_name|
fetch_non_custom_field_column_data(column_name, work_packages)
end
}
columns += custom_field_column_ids.map do |cf_id|
columns += custom_field_column_ids.map { |cf_id|
fetch_custom_field_column_data(cf_id, work_packages)
end
}
columns
end
@ -214,9 +214,9 @@ module Api::Experimental::Concerns::ColumnData
end
def fetch_custom_field_column_data(custom_field_id, work_packages, display = true)
custom_field_data = work_packages.map do |wp|
custom_field_data = work_packages.map { |wp|
wp.custom_values_display_data(custom_field_id)
end
}
if display
custom_field_data.flatten
@ -257,8 +257,6 @@ module Api::Experimental::Concerns::ColumnData
if groups
groups[0]
else
nil
end
end

@ -28,8 +28,6 @@
module Api::Experimental
class QueriesController < ApplicationController
unloadable
include ApiController
include Api::Experimental::Concerns::GrapeRouting
include Api::Experimental::Concerns::ColumnData
@ -161,19 +159,5 @@ module Api::Experimental
deny_access unless allowed
end
def visible_queries
unless @visible_queries
# User can see public queries and his own queries
visible = ARCondition.new(['is_public = ? OR user_id = ?', true, (User.current.logged? ? User.current.id : 0)])
# Project specific queries and global queries
visible << (@project.nil? ? ['project_id IS NULL'] : ['project_id = ?', @project.id])
@visible_queries = Query.find(:all,
select: 'id, name, is_public',
order: 'name ASC',
conditions: visible.conditions)
end
@visible_queries
end
end
end

@ -49,7 +49,7 @@ module Api
private
def visible_users
visible_project_ids = Project.visible.all.map(&:id)
visible_project_ids = Project.visible.pluck(:id)
desired_classes = if Setting.work_package_group_assignment?
['User', 'Group']
else

@ -36,7 +36,7 @@ module Api
def index
@versions = if @project
@project.shared_versions.all
@project.shared_versions
else
Version.visible.systemwide
end

@ -29,8 +29,6 @@
module Api
module Experimental
class WorkPackagesController < ApplicationController
unloadable
DEFAULT_SORT_ORDER = ['parent', 'desc']
include ApiController
@ -106,7 +104,6 @@ module Api
.page(page_param)
.per_page(per_page_param)
.changed_since(@since)
.all
set_work_packages_meta_data(@query, results, work_packages)
work_packages
@ -140,7 +137,7 @@ module Api
# Note: Do not apply pagination. Used to obtain total query meta data.
results = query.results include: includes_for_columns(column_names)
results.work_packages.all
results.work_packages
end
def set_work_packages_meta_data(query, results, work_packages)

@ -29,11 +29,9 @@
module Api
module V2
class AuthenticationController < AuthenticationController
class AuthenticationController < ::AuthenticationController
include ::Api::V2::ApiController
unloadable
AuthorizationData = Struct.new(:authorized, :authenticated_user_id)
skip_before_filter :require_login, :check_if_login_required
before_filter :api_allows_login, :require_login

@ -29,8 +29,8 @@
module Api::V2::Concerns::MultipleProjects
def load_multiple_projects(ids, identifiers)
@projects = []
@projects |= Project.all(conditions: { id: ids }) unless ids.empty?
@projects |= Project.all(conditions: { identifier: identifiers }) unless identifiers.empty?
@projects |= Project.where(id: ids) unless ids.empty?
@projects |= Project.where(identifier: identifiers) unless identifiers.empty?
end
def projects_contain_certain_ids_and_identifiers(ids, identifiers)
@ -42,10 +42,10 @@ module Api::V2::Concerns::MultipleProjects
# authorize
# Ignoring projects, where user has no view_work_packages permission.
permission = params[:controller].sub api_version, ''
@projects = @projects.select do |project|
@projects = @projects.select { |project|
User.current.allowed_to?({ controller: permission,
action: params[:action] },
project)
end
}
end
end

@ -36,14 +36,12 @@ module Api
def index
wp_fields = WorkPackageCustomField.visible_by_user(User.current)
.find(:all,
include: [:translations, :projects, :types],
order: :id)
.includes(:translations, :projects, :types)
.order(:id)
.uniq
other_fields = CustomField.find :all,
include: :translations,
conditions: "type != 'WorkPackageCustomField'",
order: [:type, :id]
other_fields = CustomField.includes(:translations)
.where("type != 'WorkPackageCustomField'")
.order(:type, :id)
@custom_fields = wp_fields + other_fields
@ -53,7 +51,7 @@ module Api
end
def show
@custom_field = CustomField.find params[:id], include: :translations
@custom_field = CustomField.includes(:translations).find params[:id]
respond_to do |format|
format.api

@ -30,6 +30,6 @@
class Api::V2::Pagination::TypesController < ApplicationController
extend Pagination::Controller
paginate_model Type
action_for Type, :index
paginate_model ::Type
action_for ::Type, :index
end

@ -29,7 +29,7 @@
module Api
module V2
class PlanningElementJournalsController < PlanningElementJournalsController
class PlanningElementJournalsController < ::PlanningElementJournalsController
include ::Api::V2::ApiController
def index

@ -37,8 +37,6 @@ module Api
include ::Api::V2::ApiController
unloadable
accept_key_auth :index
def index

@ -29,7 +29,7 @@
module Api
module V2
class PlanningElementTypeColorsController < PlanningElementTypeColorsController
class PlanningElementTypeColorsController < ::PlanningElementTypeColorsController
include ::Api::V2::ApiController
def index

@ -40,7 +40,7 @@ module Api
accept_key_auth :index, :show
def index
@types = (@project.nil?) ? Type.all : @project.types
@types = (@project.nil?) ? ::Type.all : @project.types
respond_to do |format|
format.api
@ -49,9 +49,9 @@ module Api
def show
@type = if @project.nil?
Type.find_by_id(params[:id])
::Type.find_by(id: params[:id])
else
@project.types.find_by_id(params[:id])
@project.types.find_by(id: params[:id])
end
if @type

@ -30,7 +30,6 @@
module Api
module V2
class PlanningElementsController < ApplicationController
unloadable
helper :timelines, :planning_elements
include ::Api::V2::ApiController
@ -84,8 +83,9 @@ module Api
end
def show
@planning_element = @project.work_packages.find params[:id],
include: [{ custom_values: [{ custom_field: :translations }] }]
@planning_element = @project.work_packages
.includes([{ custom_values: [{ custom_field: :translations }] }])
.find(params[:id])
respond_to do |format|
format.api
@ -124,8 +124,8 @@ module Api
def load_multiple_projects(ids, identifiers)
@projects = []
@projects |= Project.all(conditions: { id: ids }) unless ids.empty?
@projects |= Project.all(conditions: { identifier: identifiers }) unless identifiers.empty?
@projects |= Project.where(id: ids) unless ids.empty?
@projects |= Project.where(identifier: identifiers) unless identifiers.empty?
end
def find_single_project
@ -164,7 +164,7 @@ module Api
# WTF. Why do we completely skip rewiring in this case and always provide parent_ids?
# This is totally inconistent.
identifiers = params[:ids].split(/,/).map(&:strip)
@planning_elements = WorkPackage.visible(User.current).find_all_by_id(identifiers)
@planning_elements = WorkPackage.visible(User.current).where(id: identifiers)
elsif params[:project_id] !~ /,/
find_single_project
else
@ -238,7 +238,7 @@ module Api
def timeline_to_project(timeline_id)
if timeline_id
project = Timeline.find_by_id(params[:timeline]).project
project = Timeline.find_by(id: params[:timeline]).project
user_has_access = User.current.allowed_to?({ controller: 'planning_elements',
action: 'index' },
project)
@ -252,6 +252,7 @@ module Api
work_packages = WorkPackage.for_projects(projects)
.changed_since(@since)
.includes(:status, :project, :type, :custom_values)
.references(:projects)
wp_ids = parse_work_package_ids
work_packages = work_packages.where(id: wp_ids) if wp_ids
@ -292,12 +293,12 @@ module Api
def render_errors(errors)
options = { status: :bad_request, layout: false }
options.merge!(case params[:format]
when 'xml'; { xml: errors }
when 'json'; { json: { 'errors' => errors } }
else
raise "Unknown format #{params[:format]} in #render_validation_errors"
when 'xml'; { xml: errors }
when 'json'; { json: { 'errors' => errors } }
else
raise "Unknown format #{params[:format]} in #render_validation_errors"
end
)
)
render options
end
@ -316,7 +317,6 @@ module Api
filtered_ids = @planning_elements.map(&:id)
@planning_elements.each do |pe|
# re-wire the parent of this pe to the first ancestor found in the filtered set
# re-wiring is only needed, when there is actually a parent, and the parent has been filtered out
if pe.parent_id && !filtered_ids.include?(pe.parent_id)

@ -29,7 +29,7 @@
module Api
module V2
class ProjectAssociationsController < ProjectAssociationsController
class ProjectAssociationsController < ::ProjectAssociationsController
include ::Api::V2::ApiController
respond_to :api

@ -29,7 +29,7 @@
module Api
module V2
class ProjectTypesController < ProjectTypesController
class ProjectTypesController < ::ProjectTypesController
include ::Api::V2::ApiController
def index

@ -29,7 +29,7 @@
module Api
module V2
class ProjectsController < ProjectsController
class ProjectsController < ::ProjectsController
include ::Api::V2::ApiController
before_filter :find_project, except: [:index, :level_list]
@ -41,20 +41,18 @@ module Api
end
def index
options = { order: 'lft' }
@projects = @base.visible
.includes(:types)
.order('lft')
if params[:ids]
ids, identifiers = params[:ids].split(/,/).map(&:strip).partition { |s| s =~ /\A\d*\z/ }
ids = ids.map(&:to_i).sort
identifiers = identifiers.sort
options[:conditions] = ['id IN (?) OR identifier IN (?)', ids, identifiers]
@projects = @projects.where(['id IN (?) OR identifier IN (?)', ids, identifiers])
end
@projects = @base.visible
.includes(:types)
.all(options)
@projects_by_id = Hash[@projects.map { |p| [p.id, p] }]
build_associations unless @projects.empty?
@ -89,8 +87,8 @@ module Api
protected
def find_project
@project = Project.find params[:id],
include: [{ custom_values: [{ custom_field: :translations }] }]
@project = Project.includes([{ custom_values: [{ custom_field: :translations }] }])
.find params[:id]
end
def build_associations
@ -106,7 +104,6 @@ module Api
@associations_by_id[a.project_b_id] ||= []
@associations_by_id[a.project_b_id] << a
end
end

@ -29,11 +29,11 @@
module Api
module V2
class ReportedProjectStatusesController < ReportedProjectStatusesController
class ReportedProjectStatusesController < ::ReportedProjectStatusesController
include ::Api::V2::ApiController
def index
@reported_project_statuses = @base.all
@reported_project_statuses = @base
respond_to do |format|
format.api
end

@ -29,7 +29,7 @@
module Api
module V2
class ReportingsController < ReportingsController
class ReportingsController < ::ReportingsController
include ::Api::V2::ApiController
def self.accept_key_auth_actions
@ -39,10 +39,10 @@ module Api
def available_projects
available_projects = @project.reporting_to_project_candidates
respond_to do |format|
format.api {
format.api do
@elements = Project.project_level_list(Project.visible)
@disabled = Project.visible - available_projects
}
end
end
end
@ -98,7 +98,7 @@ module Api
condition += ' AND ' unless condition.empty?
project_parents = params[:project_parents].split(/,/).map(&:to_i)
nested_set_selection = Project.find(project_parents).map { |p| p.lft..p.rgt }.inject([]) { |r, e| e.each { |i| r << i }; r }
nested_set_selection = Project.find(project_parents).map { |p| p.lft..p.rgt }.inject([]) { |r, e| e.each do |i| r << i end; r }
temp_condition += "#{Project.quoted_table_name}.lft IN (?)"
condition_params << nested_set_selection
@ -120,17 +120,13 @@ module Api
case params[:only]
when 'via_source'
@reportings = @project.reportings_via_source.find(:all,
include: :project,
conditions: conditions
)
@reportings = @project.reportings_via_source.includes(:project)
.where(conditions).references(:projects)
when 'via_target'
@reportings = @project.reportings_via_target.find(:all,
include: :project,
conditions: conditions
)
@reportings = @project.reportings_via_target.includes(:project)
.where(conditions).references(:projects)
else
@reportings = @project.reportings.all
@reportings = @project.reportings
end
# get all reportings for which projects have ancestors.
@ -151,20 +147,16 @@ module Api
case params[:only]
when 'via_source'
@ancestor_reportings = @project.reportings_via_source.find(:all,
include: :project,
conditions: conditions
)
@ancestor_reportings = @project.reportings_via_source
.includes(:project).where(conditions).references(:projects)
when 'via_target'
@ancestor_reportings = @project.reportings_via_target.find(:all,
include: :project,
conditions: conditions
)
@ancestor_reportings = @project.reportings_via_target
.includes(:project).where(conditions).references(:projects)
else
@ancestor_reportings = @project.reportings.all
@ancestor_reportings = @project.reportings
end
@reportings = (@reportings + @ancestor_reportings).uniq
@reportings = (@reportings.to_a + @ancestor_reportings.to_a).uniq
respond_to do |format|
format.api do

@ -38,8 +38,6 @@ module Api
include ::Api::V2::ApiController
rescue_from ActiveRecord::RecordNotFound, with: lambda { render_404 }
unloadable
before_filter :resolve_project
accept_key_auth :index, :show

@ -29,7 +29,7 @@
module Api
module V2
class TimelinesController < TimelinesController
class TimelinesController < ::TimelinesController
include ::Api::V2::ApiController
end
end

@ -29,7 +29,7 @@
module Api
module V2
class UsersController < UsersController
class UsersController < ::UsersController
include ::Api::V2::ApiController
skip_filter :require_admin, only: :index

@ -93,7 +93,7 @@ module Api
if params[:project_id] && params[:ids]
identifiers = params[:ids].split(/,/).map(&:strip).map(&:to_i)
version_scope = ::Version.find_all_by_id(identifiers)
version_scope = ::Version.where(id: identifiers)
.map(&:id)
end

@ -29,7 +29,7 @@
module Api
module V2
class WorkflowsController < WorkflowsController
class WorkflowsController < ::WorkflowsController
include ::Api::V2::ApiController
Workflow = Struct.new(:type_id, :old_status_id, :transitions)
@ -89,9 +89,9 @@ module Api
end
def scope(transition)
if transition.author
if ActiveRecord::ConnectionAdapters::Column.value_to_boolean(transition.author)
:author
elsif transition.assignee
elsif ActiveRecord::ConnectionAdapters::Column.value_to_boolean(transition.assignee)
:assignee
else
:role

@ -30,19 +30,6 @@
require 'uri'
require 'cgi'
# There is a circular dependency chain between User, Principal, and Project
# If anybody triggers the loading of User first, Rails fails to autoload
# the three. Defining class User depends on the resolution of the Principal constant.
# Triggering autoload of the User class does not immediately define the User constant
# while Principal and Project dont inherit from something undefined.
# This means they will be defined as constants right after their autoloading
# was triggered. When Rails discovers it has to load the undefined class User
# during the load circle while noticing it has already tried to load it (the
# first load of user), it will complain about user being an undefined constant.
# Requiring this dependency here ensures Principal is loaded first in development
# on each request.
require_dependency 'principal'
class ApplicationController < ActionController::Base
class_attribute :_model_object
class_attribute :_model_scope
@ -105,6 +92,11 @@ class ApplicationController < ActionController::Base
render_error status: 422, message: 'Invalid form authenticity token.' unless api_request?
end
rescue_from ActionController::ParameterMissing do |exception|
render text: "Required parameter missing: #{exception.param}",
status: :bad_request
end
before_filter :user_setup,
:check_if_login_required,
:log_requesting_user,
@ -160,7 +152,7 @@ class ApplicationController < ActionController::Base
def find_current_user
if session[:user_id]
# existing session
(User.active.find(session[:user_id], include: [:memberships]) rescue nil)
User.active.includes(:memberships).find_by(id: session[:user_id])
elsif cookies[OpenProject::Configuration['autologin_cookie_name']] && Setting.autologin?
# auto-login feature starts a new session
user = User.try_to_autologin(cookies[OpenProject::Configuration['autologin_cookie_name']])
@ -222,25 +214,8 @@ class ApplicationController < ActionController::Base
I18n.fallbacks.defaults = fallbacks
end
##
# Sets the language for the current request.
# The language is determined with the following priority:
#
# 1. The language as configured by the user.
# 2. The first language defined in the Accept-Language header sent by the browser.
# 3. OpenProject's default language defined in the settings.
def set_localization
lang = nil
lang = find_language(User.current.language) if User.current.logged?
if lang.nil? && request.env['HTTP_ACCEPT_LANGUAGE']
accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first
unless accept_lang.blank?
accept_lang = accept_lang.downcase
lang = find_language(accept_lang) || find_language(accept_lang.split('-').first)
end
end
lang ||= Setting.default_language
set_language_if_valid(lang)
SetLocalizationService.new(User.current, request.env['HTTP_ACCEPT_LANGUAGE']).call
end
def require_login
@ -256,7 +231,7 @@ class ApplicationController < ActionController::Base
project_id: params[:project_id])
end
respond_to do |format|
format.any(:html, :atom) { redirect_to signin_path(back_url: url) }
format.any(:html, :atom) do redirect_to signin_path(back_url: url) end
auth_header = OpenProject::Authentication::WWWAuthenticate.response_header(
request_headers: request.headers)
@ -412,7 +387,7 @@ class ApplicationController < ActionController::Base
# Filter for bulk work package operations
def find_work_packages
@work_packages = WorkPackage.includes(:project)
.find_all_by_id(params[:work_package_id] || params[:ids])
.where(id: params[:work_package_id] || params[:ids])
fail ActiveRecord::RecordNotFound if @work_packages.empty?
@projects = @work_packages.map(&:project).compact.uniq
@project = @projects.first if @projects.size == 1
@ -561,7 +536,9 @@ class ApplicationController < ActionController::Base
format.html do
render template: 'common/error', layout: use_layout, status: @status
end
format.any(:atom, :xml, :js, :json, :pdf, :csv) { head @status }
format.any(:atom, :xml, :js, :json, :pdf, :csv) do
head @status
end
end
end
@ -574,7 +551,7 @@ class ApplicationController < ActionController::Base
def render_feed(items, options = {})
@items = items || []
@items.sort! { |x, y| y.event_datetime <=> x.event_datetime }
@items.sort! do |x, y| y.event_datetime <=> x.event_datetime end
@items = @items.slice(0, Setting.feeds_limit.to_i)
@title = options[:title] || Setting.app_title
render template: 'common/feed', layout: false, content_type: 'application/atom+xml'
@ -589,28 +566,6 @@ class ApplicationController < ActionController::Base
self.class.accept_key_auth_actions || []
end
# qvalues http header parser
# code taken from webrick
def parse_qvalues(value)
tmp = []
if value
parts = value.split(/,\s*/)
parts.each do |part|
match = /\A([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?\z/.match(part)
if match
val = match[1]
q = (match[2] || 1).to_f
tmp.push([val, q])
end
end
tmp = tmp.sort_by { |_val, q| -q }
tmp.map! { |val, _q| val }
end
return tmp
rescue
nil
end
# Returns a string that can be used as filename value in Content-Disposition header
def filename_for_content_disposition(name)
request.env['HTTP_USER_AGENT'] =~ %r{(MSIE|Trident)} ? ERB::Util.url_encode(name) : name
@ -651,9 +606,9 @@ class ApplicationController < ActionController::Base
# Converts the errors on an ActiveRecord object into a common JSON format
def object_errors_to_json(object)
object.errors.map do |attribute, error|
object.errors.map { |attribute, error|
{ attribute => error }
end.to_json
}.to_json
end
# Renders API response on validation failure

@ -62,8 +62,8 @@ class AttachmentsController < ApplicationController
@attachment.container.attachments.delete(@attachment)
respond_to do |format|
format.html { redirect_to url_for(destroy_response_url(@attachment.container)) }
format.js {}
format.html do redirect_to url_for(destroy_response_url(@attachment.container)) end
format.js
end
end

@ -84,7 +84,7 @@ class AuthSourcesController < ApplicationController
def destroy
@auth_source = AuthSource.find(params[:id])
unless @auth_source.users.find(:first)
unless @auth_source.users.first
@auth_source.destroy
flash[:notice] = l(:notice_successful_delete)
end

@ -28,7 +28,6 @@
#++
class AuthenticationController < ApplicationController
unloadable
helper :timelines
before_filter :disable_api

@ -57,7 +57,7 @@ class BoardsController < ApplicationController
'updated_on' => "#{Message.table_name}.updated_on"
respond_to do |format|
format.html {
format.html do
set_topics
gon.rabl 'app/views/messages/index.rabl'
@ -71,21 +71,21 @@ class BoardsController < ApplicationController
@message = Message.new
render action: 'show', layout: !request.xhr?
}
format.json {
end
format.json do
set_topics
gon.rabl 'app/views/messages/index.rabl'
render template: 'messages/index'
}
format.atom {
end
format.atom do
@messages = @board.messages.order(["#{Message.table_name}.sticked_on ASC", sort_clause].compact.join(', '))
.includes(:author, :board)
.limit(Setting.feeds_limit.to_i)
render_feed(@messages, title: "#{@project}: #{@board}")
}
end
end
end

@ -55,7 +55,9 @@ class CategoriesController < ApplicationController
end
else
respond_to do |format|
format.html { render action: :new }
format.html do
render action: :new
end
format.js do
render(:update) { |page| page.alert(@category.errors.full_messages.join('\n')) }
end
@ -85,7 +87,7 @@ class CategoriesController < ApplicationController
redirect_to controller: '/projects', action: 'settings', id: @project, tab: 'categories'
return
elsif params[:todo]
reassign_to = @project.categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
reassign_to = @project.categories.find_by(id: params[:reassign_to_id]) if params[:todo] == 'reassign'
@category.destroy(reassign_to)
redirect_to controller: '/projects', action: 'settings', id: @project, tab: 'categories'
return

@ -43,7 +43,7 @@ module Concerns::OmniauthLogin
# Set back url to page the omniauth login link was clicked on
params[:back_url] = request.env['omniauth.origin']
user = User.find_or_initialize_by_identity_url identity_url_from_omniauth(auth_hash)
user = User.find_or_initialize_by identity_url: identity_url_from_omniauth(auth_hash)
decision = OpenProject::OmniAuth::Authorization.authorized? auth_hash
if decision.approve?

@ -75,10 +75,9 @@ class CopyProjectsController < ApplicationController
private
def prepare_for_copy_project
@issue_custom_fields = WorkPackageCustomField.find(:all, order: "#{CustomField.table_name}.position")
@types = Type.all
@root_projects = Project.find(:all,
conditions: "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
order: 'name')
@issue_custom_fields = WorkPackageCustomField.order("#{CustomField.table_name}.position")
@types = ::Type.all
@root_projects = Project.where("parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}")
.order('name')
end
end

@ -36,7 +36,7 @@ class CustomFieldsController < ApplicationController
before_filter :blank_translation_attributes_as_nil, only: [:create, :update]
def index
@custom_fields_by_type = CustomField.find(:all).group_by { |f| f.class.name }
@custom_fields_by_type = CustomField.all.group_by { |f| f.class.name }
@tab = params[:tab] || 'WorkPackageCustomField'
end
@ -109,6 +109,6 @@ class CustomFieldsController < ApplicationController
end
def find_types
@types = Type.find(:all, order: 'position')
@types = ::Type.order('position')
end
end

@ -82,13 +82,13 @@ class EnumerationsController < ApplicationController
redirect_to action: 'index'
return
elsif params[:reassign_to_id]
if reassign_to = @enumeration.class.find_by_id(params[:reassign_to_id])
if reassign_to = @enumeration.class.find_by(id: params[:reassign_to_id])
@enumeration.destroy(reassign_to)
redirect_to action: 'index'
return
end
end
@enumerations = @enumeration.class.find(:all) - [@enumeration]
@enumerations = @enumeration.class.all - [@enumeration]
end
protected

@ -38,11 +38,11 @@ class GroupsController < ApplicationController
# GET /groups
# GET /groups.xml
def index
@groups = Group.order('lastname ASC').all
@groups = Group.order('lastname ASC')
respond_to do |format|
format.html # index.html.erb
format.xml { render xml: @groups }
format.xml do render xml: @groups end
end
end
@ -51,7 +51,7 @@ class GroupsController < ApplicationController
def show
respond_to do |format|
format.html # show.html.erb
format.xml { render xml: @group }
format.xml do render xml: @group end
end
end
@ -62,13 +62,13 @@ class GroupsController < ApplicationController
respond_to do |format|
format.html # new.html.erb
format.xml { render xml: @group }
format.xml do render xml: @group end
end
end
# GET /groups/1/edit
def edit
@group = Group.find(params[:id], include: [:users, :memberships])
@group = Group.includes(:users, :memberships).find(params[:id])
end
# POST /groups
@ -79,11 +79,11 @@ class GroupsController < ApplicationController
respond_to do |format|
if @group.save
flash[:notice] = l(:notice_successful_create)
format.html { redirect_to(groups_path) }
format.xml { render xml: @group, status: :created, location: @group }
format.html do redirect_to(groups_path) end
format.xml do render xml: @group, status: :created, location: @group end
else
format.html { render action: 'new' }
format.xml { render xml: @group.errors, status: :unprocessable_entity }
format.html do render action: 'new' end
format.xml do render xml: @group.errors, status: :unprocessable_entity end
end
end
end
@ -91,16 +91,16 @@ class GroupsController < ApplicationController
# PUT /groups/1
# PUT /groups/1.xml
def update
@group = Group.find(params[:id], include: :users)
@group = Group.includes(:users).find(params[:id])
respond_to do |format|
if @group.update_attributes(permitted_params.group)
flash[:notice] = l(:notice_successful_update)
format.html { redirect_to(groups_path) }
format.xml { head :ok }
format.html do redirect_to(groups_path) end
format.xml do head :ok end
else
format.html { render action: 'edit' }
format.xml { render xml: @group.errors, status: :unprocessable_entity }
format.html do render action: 'edit' end
format.xml do render xml: @group.errors, status: :unprocessable_entity end
end
end
end
@ -111,32 +111,32 @@ class GroupsController < ApplicationController
@group.destroy
respond_to do |format|
format.html { redirect_to(groups_url) }
format.xml { head :ok }
format.html do redirect_to(groups_url) end
format.xml do head :ok end
end
end
def add_users
@group = Group.find(params[:id], include: :users)
@users = User.find_all_by_id(params[:user_ids], include: :memberships)
@group = Group.includes(:users).find(params[:id])
@users = User.includes(:memberships).where(id: params[:user_ids])
@group.users << @users
respond_to do |format|
format.html { redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'users' }
format.js { render action: 'change_members' }
format.html do redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'users' end
format.js do render action: 'change_members' end
end
end
def remove_user
@group = Group.find(params[:id], include: :users)
@group.users.delete(User.find(params[:user_id], include: :memberships))
@group = Group.includes(:users).find(params[:id])
@group.users.delete(User.includes(:memberships).find(params[:user_id]))
respond_to do |format|
format.html { redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'users' }
format.js { render action: 'change_members' }
format.html do redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'users' end
format.js do render action: 'change_members' end
end
end
def autocomplete_for_user
@users = User.active.not_in_group(@group).like(params[:q]).all(limit: 100)
@users = User.active.not_in_group(@group).like(params[:q]).limit(100)
render layout: false
end
@ -146,8 +146,8 @@ class GroupsController < ApplicationController
@membership.save
respond_to do |format|
format.html { redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'memberships' }
format.js { render action: 'change_memberships' }
format.html do redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'memberships' end
format.js do render action: 'change_memberships' end
end
end
@ -157,8 +157,8 @@ class GroupsController < ApplicationController
membership_params = permitted_params.group_membership
Member.find(membership_params[:membership_id]).destroy
respond_to do |format|
format.html { redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'memberships' }
format.js { render action: 'destroy_memberships' }
format.html do redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'memberships' end
format.js do render action: 'destroy_memberships' end
end
end

@ -66,10 +66,10 @@ class JournalsController < ApplicationController
def edit
(render_403; return false) unless @journal.editable_by?(User.current)
respond_to do |format|
format.html {
format.html do
# TODO: implement non-JS journal update
render nothing: true
}
end
format.js
end
end
@ -79,11 +79,13 @@ class JournalsController < ApplicationController
@journal.destroy if @journal.details.empty? && @journal.notes.blank?
call_hook(:controller_journals_edit_post, journal: @journal, params: params)
respond_to do |format|
format.html {
format.html do
redirect_to controller: "/#{@journal.journable.class.name.pluralize.downcase}",
action: 'show', id: @journal.journable_id
}
format.js { render action: 'update' }
end
format.js do
render action: 'update'
end
end
end
@ -98,8 +100,10 @@ class JournalsController < ApplicationController
@diff = Redmine::Helpers::Diff.new(to, from)
@journable = journal.journable
respond_to do |format|
format.html {}
format.js { render partial: 'diff', locals: { diff: @diff } }
format.html
format.js do
render partial: 'diff', locals: { diff: @diff }
end
end
else
render_404
@ -110,10 +114,10 @@ class JournalsController < ApplicationController
@journal.notes = params[:notes]
respond_to do |format|
format.any(:html, :js) {
format.any(:html, :js) do
render locals: { journal: @journal },
layout: false
}
end
end
end

@ -30,7 +30,8 @@
class MembersController < ApplicationController
model_object Member
before_filter :find_model_object_and_project, except: [:autocomplete_for_member, :paginate_users]
before_filter :find_project, only: [:autocomplete_for_member, :paginate_users]
before_filter :find_project, only: [:paginate_users]
before_filter :find_project_by_project_id, only: [:autocomplete_for_member]
before_filter :authorize
include Pagination::Controller
@ -53,12 +54,13 @@ class MembersController < ApplicationController
if members.present? && members.all?(&:valid?)
flash.now.notice = l(:notice_successful_create)
format.html { redirect_to settings_project_path(@project, tab: 'members') }
format.html do redirect_to settings_project_path(@project, tab: 'members') end
format.js do
@pagination_url_options = { controller: 'projects', action: 'settings', id: @project }
render(:update) do |page|
page.replace_html 'tab-content-members', partial: 'projects/settings/members'
page.replace_html 'tab-content-members', partial: 'projects/settings/members',
locals: { members: members }
page.insert_html :top, 'tab-content-members', render_flash_messages
page << MembersController.tab_scripts
@ -86,7 +88,7 @@ class MembersController < ApplicationController
end
respond_to do |format|
format.html { redirect_to controller: '/projects', action: 'settings', tab: 'members', id: @project, page: params[:page] }
format.html do redirect_to controller: '/projects', action: 'settings', tab: 'members', id: @project, page: params[:page] end
format.js do
@pagination_url_options = { controller: 'projects', action: 'settings', id: @project }
@ -99,7 +101,7 @@ class MembersController < ApplicationController
end
page.insert_html :top, 'tab-content-members', render_flash_messages
page << MembersController.tab_scripts
page.visual_effect(:highlight, "member-#{@member.id}") unless Member.find_by_id(@member.id).nil?
page.visual_effect(:highlight, "member-#{@member.id}") unless Member.find_by(id: @member.id).nil?
end
end
end
@ -111,7 +113,7 @@ class MembersController < ApplicationController
flash.now.notice = l(:notice_successful_delete)
end
respond_to do |format|
format.html { redirect_to controller: '/projects', action: 'settings', tab: 'members', id: @project }
format.html do redirect_to controller: '/projects', action: 'settings', tab: 'members', id: @project end
format.js do
@pagination_url_options = { controller: 'projects', action: 'settings', id: @project }
render(:update) do |page|
@ -140,7 +142,7 @@ class MembersController < ApplicationController
respond_to do |format|
format.json
format.html {
format.html do
if request.xhr?
partial = 'members/autocomplete_for_member'
else
@ -150,7 +152,7 @@ class MembersController < ApplicationController
locals: { project: @project,
principals: @principals,
roles: Role.find_all_givable }
}
end
end
end
@ -162,17 +164,17 @@ class MembersController < ApplicationController
def new_members_from_params
user_ids = possibly_seperated_ids_for_entity(params[:member], :user)
roles = Role.find_all_by_id(possibly_seperated_ids_for_entity(params[:member], :role))
roles = Role.where(id: possibly_seperated_ids_for_entity(params[:member], :role))
new_member = lambda do |user_id|
new_member = lambda { |user_id|
Member.new(permitted_params.member).tap do |member|
member.user_id = user_id if user_id
end
end
}
members = user_ids.map do |user_id|
members = user_ids.map { |user_id|
new_member.call(user_id)
end
}
# most likely wrong user input, use a dummy member for error handling
if !members.present? && roles.present?
members << new_member.call(nil)
@ -181,13 +183,13 @@ class MembersController < ApplicationController
end
def each_comma_seperated(array, &block)
array.map do |e|
array.map { |e|
if e.to_s.match /\d(,\d)*/
block.call(e)
else
e
end
end.flatten
}.flatten
end
def transform_array_of_comma_seperated_ids(array)

@ -47,7 +47,7 @@ class MessagesController < ApplicationController
page = params[:page]
# Find the page of the requested reply
if params[:r] && page.nil?
offset = @topic.children.count(conditions: ["#{Message.table_name}.id < ?", params[:r].to_i])
offset = @topic.children.where(["#{Message.table_name}.id < ?", params[:r].to_i]).count
page = 1 + offset / REPLIES_PER_PAGE
end

@ -67,7 +67,7 @@ class MyController < ApplicationController
def account
@user = User.current
@pref = @user.pref
if request.put?
if request.patch?
@user.attributes = permitted_params.user
@user.pref.attributes = params[:pref]
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
@ -167,7 +167,7 @@ class MyController < ApplicationController
@user = User.current
layout = get_current_layout
# remove if already present in a group
%w(top left right).each { |f| (layout[f] ||= []).delete block }
%w(top left right).each do |f| (layout[f] ||= []).delete block end
# add it on top
layout['top'].unshift block
@user.pref[:my_page_layout] = layout
@ -182,7 +182,7 @@ class MyController < ApplicationController
@user = User.current
# remove block in all groups
layout = get_current_layout
%w(top left right).each { |f| (layout[f] ||= []).delete block }
%w(top left right).each do |f| (layout[f] ||= []).delete block end
@user.pref[:my_page_layout] = layout
@user.pref.save
render nothing: true
@ -199,9 +199,9 @@ class MyController < ApplicationController
if group_items and group_items.is_a? Array
layout = get_current_layout
# remove group blocks if they are presents in other groups
%w(top left right).each {|f|
%w(top left right).each do |f|
layout[f] = (layout[f] || []) - group_items
}
end
layout[group] = group_items
@user.pref[:my_page_layout] = layout
@user.pref.save

@ -50,8 +50,13 @@ class NewsController < ApplicationController
.per_page(per_page_param)
respond_to do |format|
format.html { render layout: !request.xhr? }
format.atom { render_feed(@newss, title: (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
format.html do
render layout: !request.xhr?
end
format.atom do
render_feed(@newss,
title: (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}")
end
end
end

@ -28,7 +28,6 @@
#++
class PlanningElementJournalsController < ApplicationController
unloadable
helper :timelines
include ExtendedHTTP
@ -43,7 +42,9 @@ class PlanningElementJournalsController < ApplicationController
def index
@journals = @planning_element.journals
respond_to do |format|
format.html { render_404 }
format.html do
render_404
end
end
end

@ -28,7 +28,6 @@
#++
class PlanningElementTypeColorsController < ApplicationController
unloadable
helper :timelines
before_filter :disable_api

@ -28,7 +28,6 @@
#++
class ProjectAssociationsController < ApplicationController
unloadable
helper :timelines
before_filter :disable_api

@ -28,7 +28,6 @@
#++
class ProjectTypesController < ApplicationController
unloadable
helper :timelines
before_filter :disable_api

@ -60,28 +60,29 @@ class ProjectsController < ApplicationController
# Lists visible projects
def index
respond_to do |format|
format.html {
@projects = Project.visible.find(:all, order: 'lft')
}
format.atom {
projects = Project.visible.find(:all, order: 'created_on DESC',
limit: Setting.feeds_limit.to_i)
format.html do
@projects = Project.visible.order('lft')
end
format.atom do
projects = Project.visible
.order('created_on DESC')
.limit(Setting.feeds_limit.to_i)
render_feed(projects, title: "#{Setting.app_title}: #{l(:label_project_latest)}")
}
end
end
end
def new
@issue_custom_fields = WorkPackageCustomField.find(:all, order: "#{CustomField.table_name}.position")
@types = Type.all
@issue_custom_fields = WorkPackageCustomField.order("#{CustomField.table_name}.position")
@types = ::Type.all
@project = Project.new
@project.parent = Project.find(params[:parent_id]) if params[:parent_id]
@project.safe_attributes = params[:project]
end
def create
@issue_custom_fields = WorkPackageCustomField.find(:all, order: "#{CustomField.table_name}.position")
@types = Type.all
@issue_custom_fields = WorkPackageCustomField.order("#{CustomField.table_name}.position")
@types = ::Type.all
@project = Project.new
@project.safe_attributes = params[:project]
@ -89,14 +90,14 @@ class ProjectsController < ApplicationController
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
add_current_user_to_project_if_not_admin(@project)
respond_to do |format|
format.html {
format.html do
flash[:notice] = l(:notice_successful_create)
redirect_to controller: '/projects', action: 'settings', id: @project
}
end
end
else
respond_to do |format|
format.html { render action: 'new' }
format.html do render action: 'new' end
end
end
end
@ -104,18 +105,22 @@ class ProjectsController < ApplicationController
# Show @project
def show
@users_by_role = @project.users_by_role
@subprojects = @project.children.visible.all
@news = @project.news.find(:all, limit: 5, include: [:author, :project], order: "#{News.table_name}.created_on DESC")
@subprojects = @project.children.visible
@news = @project.news.limit(5).includes(:author, :project).order("#{News.table_name}.created_on DESC")
@types = @project.rolled_up_types
cond = @project.project_condition(Setting.display_subprojects_work_packages?)
@open_issues_by_type = WorkPackage.visible.count(group: :type,
include: [:project, :status, :type],
conditions: ["(#{cond}) AND #{Status.table_name}.is_closed=?", false])
@total_issues_by_type = WorkPackage.visible.count(group: :type,
include: [:project, :status, :type],
conditions: cond)
@open_issues_by_type = WorkPackage.visible.group(:type)
.includes(:project, :status, :type)
.where(["(#{cond}) AND #{Status.table_name}.is_closed=?", false])
.references(:projects, :statuses, :types)
.count
@total_issues_by_type = WorkPackage.visible.group(:type)
.includes(:project, :status, :type)
.where(cond)
.references(:projects, :statuses, :types)
.count
respond_to do |format|
format.html
@ -138,17 +143,17 @@ class ProjectsController < ApplicationController
@altered_project.set_allowed_parent!(params[:project]['parent_id'])
end
respond_to do |format|
format.html {
format.html do
flash[:notice] = l(:notice_successful_update)
redirect_to action: 'settings', id: @altered_project
}
end
end
else
respond_to do |format|
format.html {
format.html do
load_project_settings
render action: 'settings'
}
end
end
end
end
@ -157,7 +162,7 @@ class ProjectsController < ApplicationController
flash[:notice] = []
unless params.has_key? :project
params[:project] = { 'type_ids' => [Type.standard_type.id] }
params[:project] = { 'type_ids' => [::Type.standard_type.id] }
flash[:notice] << l(:notice_automatic_set_of_standard_type)
end
@ -200,7 +205,7 @@ class ProjectsController < ApplicationController
if params[:confirm]
@project_to_destroy.destroy
respond_to do |format|
format.html { redirect_to controller: '/admin', action: 'projects' }
format.html do redirect_to controller: '/admin', action: 'projects' end
end
else
flash[:error] = l(:notice_project_not_deleted)
@ -235,10 +240,10 @@ class ProjectsController < ApplicationController
end
def load_project_settings
@issue_custom_fields = WorkPackageCustomField.find(:all, order: "#{CustomField.table_name}.position")
@issue_custom_fields = WorkPackageCustomField.order("#{CustomField.table_name}.position")
@category ||= Category.new
@member ||= @project.members.new
@types = Type.all
@types = ::Type.all
@repository ||= @project.repository
@wiki ||= @project.wiki
end
@ -249,7 +254,7 @@ class ProjectsController < ApplicationController
def add_current_user_to_project_if_not_admin(project)
unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
r = Role.givable.find_by(id: Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new do |member|
member.user = User.current
member.role_ids = [r].map(&:id) # member.roles = [r] fails, this works
@ -277,7 +282,7 @@ class ProjectsController < ApplicationController
end
def types_used_by_work_packages
@types_used_by_work_packages ||= Type.find_all_by_id(WorkPackage.where(project_id: @project.id)
@types_used_by_work_packages ||= ::Type.where(id: WorkPackage.where(project_id: @project.id)
.select(:type_id)
.uniq)
end
@ -288,7 +293,7 @@ class ProjectsController < ApplicationController
return true if User.current.admin?
parent_id = params[:project] && params[:project][:parent_id]
if parent_id || @project.new_record?
parent = parent_id.blank? ? nil : Project.find_by_id(parent_id.to_i)
parent = parent_id.blank? ? nil : Project.find_by(id: parent_id.to_i)
unless @project.allowed_parents.include?(parent)
@project.errors.add :parent_id, :invalid
return false

@ -28,7 +28,6 @@
#++
class ReportedProjectStatusesController < ApplicationController
unloadable
helper :timelines
before_filter :disable_api
@ -36,16 +35,16 @@ class ReportedProjectStatusesController < ApplicationController
accept_key_auth :index, :show
def index
@reported_project_statuses = @base.all
@reported_project_statuses = @base
respond_to do |format|
format.html { render_404 }
format.html do render_404 end
end
end
def show
@reported_project_status = @base.find(params[:id])
respond_to do |format|
format.html { render_404 }
format.html do render_404 end
end
end

@ -28,7 +28,6 @@
#++
class ReportingsController < ApplicationController
unloadable
helper :timelines
before_filter :disable_api
@ -47,7 +46,7 @@ class ReportingsController < ApplicationController
def available_projects
available_projects = @project.reporting_to_project_candidates
respond_to do |format|
format.html { render_404 }
format.html do render_404 end
end
end
@ -103,7 +102,7 @@ class ReportingsController < ApplicationController
condition += ' AND ' unless condition.empty?
project_parents = params[:project_parents].split(/,/).map(&:to_i)
nested_set_selection = Project.find(project_parents).map { |p| p.lft..p.rgt }.inject([]) { |r, e| e.each { |i| r << i }; r }
nested_set_selection = Project.find(project_parents).map { |p| p.lft..p.rgt }.inject([]) { |r, e| e.each do |i| r << i end; r }
temp_condition += "#{Project.quoted_table_name}.lft IN (?)"
condition_params << nested_set_selection
@ -125,15 +124,9 @@ class ReportingsController < ApplicationController
case params[:only]
when 'via_source'
@reportings = @project.reportings_via_source.find(:all,
include: :project,
conditions: conditions
)
@reportings = @project.reportings_via_source.includes(:project).where(conditions)
when 'via_target'
@reportings = @project.reportings_via_target.find(:all,
include: :project,
conditions: conditions
)
@reportings = @project.reportings_via_target.includes(:project).where(conditions)
else
@reportings = @project.reportings.all
end
@ -156,24 +149,18 @@ class ReportingsController < ApplicationController
case params[:only]
when 'via_source'
@ancestor_reportings = @project.reportings_via_source.find(:all,
include: :project,
conditions: conditions
)
@ancestor_reportings = @project.reportings_via_source.includes(:project).where(conditions)
when 'via_target'
@ancestor_reportings = @project.reportings_via_target.find(:all,
include: :project,
conditions: conditions
)
@ancestor_reportings = @project.reportings_via_target.includes(:project).where(conditions)
else
@ancestor_reportings = @project.reportings.all
@ancestor_reportings = @project.reportings
end
@reportings = (@reportings + @ancestor_reportings).uniq
respond_to do |format|
format.html do
@reportings = @project.reportings_via_source.all.select(&:visible?)
@reportings = @project.reportings_via_source.select(&:visible?)
end
end
end

@ -92,7 +92,7 @@ class RepositoriesController < ApplicationController
@committers = @repository.committers
@users = @project.users
additional_user_ids = @committers.map(&:last).map(&:to_i) - @users.map(&:id)
@users += User.find_all_by_id(additional_user_ids) unless additional_user_ids.empty?
@users += User.where(id: additional_user_ids) unless additional_user_ids.empty?
@users.compact!
@users.sort!
if request.post? && params[:committers].is_a?(Hash)
@ -151,8 +151,8 @@ class RepositoriesController < ApplicationController
.per_page(per_page_param)
respond_to do |format|
format.html { render layout: false if request.xhr? }
format.atom { render_feed(@changesets, title: "#{@project.name}: #{l(:label_revision_plural)}") }
format.html do render layout: false if request.xhr? end
format.atom do render_feed(@changesets, title: "#{@project.name}: #{l(:label_revision_plural)}") end
end
end
@ -220,7 +220,7 @@ class RepositoriesController < ApplicationController
respond_to do |format|
format.html
format.js { render layout: false }
format.js do render layout: false end
end
rescue ChangesetNotFound
show_error_not_found
@ -338,14 +338,18 @@ class RepositoriesController < ApplicationController
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
commits_by_day = Changeset.where(['repository_id = ? AND commit_date BETWEEN ? AND ?', repository.id, @date_from, @date_to]).group(:commit_date).size
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 do |c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last end
changes_by_day = Change.includes(:changeset).where(["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]).group(:commit_date).size
changes_by_day = Change.includes(:changeset)
.where(["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
.references(:changesets)
.group(:commit_date)
.size
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 do |c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last end
fields = []
12.times { |m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1) }
12.times do |m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1) end
graph = SVG::Graph::Bar.new(
height: 300,
@ -374,9 +378,13 @@ class RepositoriesController < ApplicationController
def graph_commits_per_author(repository)
commits_by_author = Changeset.where(['repository_id = ?', repository.id]).group(:committer).size
commits_by_author.to_a.sort! { |x, y| x.last <=> y.last }
commits_by_author.to_a.sort! do |x, y| x.last <=> y.last end
changes_by_author = Change.includes(:changeset).where(["#{Changeset.table_name}.repository_id = ?", repository.id]).group(:committer).size
changes_by_author = Change.includes(:changeset)
.where(["#{Changeset.table_name}.repository_id = ?", repository.id])
.references(:changesets)
.group(:committer)
.size
h = changes_by_author.inject({}) { |o, i| o[i.first] = i.last; o }
fields = commits_by_author.map(&:first)

@ -47,21 +47,21 @@ class RolesController < ApplicationController
@role = Role.new(permitted_params.role? || { permissions: Role.non_member.permissions })
@permissions = @role.setable_permissions
@roles = Role.find :all, order: 'builtin, position'
@roles = Role.order('builtin, position')
end
def create
@role = Role.new(permitted_params.role? || { permissions: Role.non_member.permissions })
if @role.save
# 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.workflows.copy(copy_from)
end
flash[:notice] = l(:notice_successful_create)
redirect_to action: 'index'
else
@permissions = @role.setable_permissions
@roles = Role.find :all, order: 'builtin, position'
@roles = Role.order('builtin, position')
render action: 'new'
end
@ -94,12 +94,12 @@ class RolesController < ApplicationController
end
def report
@roles = Role.order('builtin, position').all
@roles = Role.order('builtin, position')
@permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
end
def bulk_update
@roles = Role.order('builtin, position').all
@roles = Role.order('builtin, position')
@roles.each do |role|
role.permissions = params[:permissions][role.id.to_s]

@ -54,7 +54,7 @@ class SearchController < ApplicationController
# quick jump to an work_package
scan_work_package_reference @question do |id|
return redirect_to work_package_path(id: id) if WorkPackage.visible.find_by_id(id.to_i)
return redirect_to work_package_path(id: id) if WorkPackage.visible.find_by(id: id.to_i)
end
@object_types = Redmine::Search.available_search_types.dup

@ -45,8 +45,12 @@ class SettingsController < ApplicationController
end
settings.each do |name, value|
# remove blank values in array settings
value.delete_if(&:blank?) if value.is_a?(Array)
if value.is_a?(Array)
# remove blank values in array settings
value.delete_if(&:blank?)
else
value = value.strip
end
Setting[name] = value
end

@ -36,10 +36,17 @@ class SysController < ActionController::Base
before_filter :find_repository_with_storage, only: [:update_required_storage]
def projects
p = Project.active.has_module(:repository).find(:all, include: :repository, order: 'identifier')
p = Project.active.has_module(:repository)
.includes(:repository)
.references(:repositories)
.order('identifier')
respond_to do |format|
format.json { render json: p.to_json(include: :repository) }
format.any(:html, :xml) { render xml: p.to_xml(include: :repository), content_type: Mime::XML }
format.json do
render json: p.to_json(include: :repository)
end
format.any(:html, :xml) do
render xml: p.to_xml(include: :repository), content_type: Mime::XML
end
end
end
@ -68,9 +75,10 @@ class SysController < ActionController::Base
def fetch_changesets
projects = []
if params[:id]
projects << Project.active.has_module(:repository).find_by_identifier!(params[:id])
projects << Project.active.has_module(:repository).find_by!(identifier: params[:id])
else
projects = Project.active.has_module(:repository).find(:all, include: :repository)
projects = Project.active.has_module(:repository)
.includes(:repository).references(:repositories)
end
projects.each do |project|
if project.repository
@ -83,7 +91,7 @@ class SysController < ActionController::Base
end
def repo_auth
@project = Project.find_by_identifier(params[:repository])
@project = Project.find_by(identifier: params[:repository])
if (%w(GET PROPFIND REPORT OPTIONS).include?(params[:method]) &&
@authenticated_user.allowed_to?(:browse_repository, @project)) ||
@ -155,13 +163,13 @@ class SysController < ActionController::Base
end
user = nil
user_id = Rails.cache.fetch(OpenProject::RepositoryAuthentication::CACHE_PREFIX + Digest::SHA1.hexdigest("#{username}#{password}"),
expires_in: OpenProject::RepositoryAuthentication::CACHE_EXPIRES_AFTER) do
expires_in: OpenProject::RepositoryAuthentication::CACHE_EXPIRES_AFTER) {
user = user_login(username, password)
user ? user.id.to_s : '-1'
end
}
return nil if user_id.blank? or user_id == '-1'
user || User.find_by_id(user_id.to_i)
user || User.find_by(id: user_id.to_i)
end
end

@ -109,7 +109,7 @@ class TimeEntries::ReportsController < ApplicationController
end
respond_to do |format|
format.html { render layout: !request.xhr? }
format.html do render layout: !request.xhr? end
format.csv { send_data(report_to_csv(@criterias, @periods, @hours), type: 'text/csv; header=present', filename: 'timelog.csv') }
end
end
@ -130,8 +130,8 @@ class TimeEntries::ReportsController < ApplicationController
klass: User,
label: Member.model_name.human },
'type' => { sql: "#{WorkPackage.table_name}.type_id",
klass: Type,
label: Type.model_name.human },
klass: ::Type,
label: ::Type.model_name.human },
'activity' => { sql: "#{TimeEntry.table_name}.activity_id",
klass: TimeEntryActivity,
label: :label_activity },
@ -149,14 +149,14 @@ class TimeEntries::ReportsController < ApplicationController
end if @project
# Add list and boolean time entry custom fields
TimeEntryCustomField.find(:all).select { |cf| %w(list bool).include? cf.field_format }.each do |cf|
TimeEntryCustomField.all.select { |cf| %w(list bool).include? cf.field_format }.each do |cf|
@available_criterias["cf_#{cf.id}"] = { sql: "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id)",
format: cf.field_format,
label: cf.name }
end
# Add list and boolean time entry activity custom fields
TimeEntryActivityCustomField.find(:all).select { |cf| %w(list bool).include? cf.field_format }.each do |cf|
TimeEntryActivityCustomField.all.select { |cf| %w(list bool).include? cf.field_format }.each do |cf|
@available_criterias["cf_#{cf.id}"] = { sql: "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Enumeration' AND c.customized_id = #{TimeEntry.table_name}.activity_id)",
format: cf.field_format,
label: cf.name }

@ -28,7 +28,6 @@
#++
class TimelinesController < ApplicationController
unloadable
helper :timelines
before_filter :disable_api
@ -45,7 +44,7 @@ class TimelinesController < ApplicationController
end
def show
@visible_timelines = @project.timelines.all
@visible_timelines = @project.timelines
@timeline = @project.timelines.find(params[:id])
end

@ -66,11 +66,17 @@ class TimelogController < ApplicationController
cond << ['spent_on BETWEEN ? AND ?', @from, @to]
respond_to do |format|
format.html {
format.html do
# Paginate results
@entry_count = TimeEntry.visible.count(include: [:project, :work_package], conditions: cond.conditions)
@entry_count = TimeEntry.visible
.includes(:project, :work_package)
.where(cond.conditions)
.count
@total_hours = TimeEntry.visible
.includes(:project, :work_package)
.where(cond.conditions)
.sum(:hours).to_f
@total_hours = TimeEntry.visible.sum(:hours, include: [:project, :work_package], conditions: cond.conditions).to_f
set_entries(cond)
gon.rabl 'app/views/timelog/index.rabl'
@ -82,40 +88,42 @@ class TimelogController < ApplicationController
gon.settings = client_preferences
render layout: !request.xhr?
}
format.json {
end
format.json do
set_entries(cond)
gon.rabl 'app/views/timelog/index.rabl'
}
format.atom {
entries = TimeEntry.visible.find(:all,
include: [:project, :activity, :user, { work_package: :type }],
conditions: cond.conditions,
order: "#{TimeEntry.table_name}.created_on DESC",
limit: Setting.feeds_limit.to_i)
end
format.atom do
entries = TimeEntry.visible
.includes(:project, :activity, :user, work_package: :type)
.where(cond.conditions)
.order("#{TimeEntry.table_name}.created_on DESC")
.limit(Setting.feeds_limit.to_i)
render_feed(entries, title: l(:label_spent_time))
}
format.csv {
end
format.csv do
# Export all entries
@entries = TimeEntry.visible.find(:all,
include: [:project, :activity, :user, { work_package: [:type, :assigned_to, :priority] }],
conditions: cond.conditions,
order: sort_clause)
@entries = TimeEntry.visible
.includes(:project, :activity, :user, work_package: [:type, :assigned_to, :priority])
.where(cond.conditions)
.order(sort_clause)
charset = "charset=#{l(:general_csv_encoding).downcase}"
send_data(
entries_to_csv(@entries),
type: "text/csv; #{charset}; header=present",
filename: 'timelog.csv')
}
end
end
end
def show
respond_to do |format|
# TODO: Implement html response
format.html { render nothing: true, status: 406 }
format.html do render nothing: true, status: 406 end
end
end
@ -136,14 +144,16 @@ class TimelogController < ApplicationController
if @time_entry.save
respond_to do |format|
format.html {
format.html do
flash[:notice] = l(:notice_successful_update)
redirect_back_or_default action: 'index', project_id: @time_entry.project
}
end
end
else
respond_to do |format|
format.html { render action: 'edit' }
format.html do
render action: 'edit'
end
end
end
end
@ -161,14 +171,16 @@ class TimelogController < ApplicationController
if @time_entry.save
respond_to do |format|
format.html {
format.html do
flash[:notice] = l(:notice_successful_update)
redirect_back_or_default action: 'index', project_id: @time_entry.project
}
end
end
else
respond_to do |format|
format.html { render action: 'edit' }
format.html do
render action: 'edit'
end
end
end
end
@ -176,19 +188,23 @@ class TimelogController < ApplicationController
def destroy
if @time_entry.destroy && @time_entry.destroyed?
respond_to do |format|
format.html {
format.html do
flash[:notice] = l(:notice_successful_delete)
redirect_to :back
}
format.json { render json: { text: l(:notice_successful_delete) } }
end
format.json do
render json: { text: l(:notice_successful_delete) }
end
end
else
respond_to do |format|
format.html {
format.html do
flash[:error] = l(:notice_unable_delete_time_entry)
redirect_to :back
}
format.json { render json: { isError: true, text: l(:notice_unable_delete_time_entry) } }
end
format.json do
render json: { isError: true, text: l(:notice_unable_delete_time_entry) }
end
end
end
rescue ::ActionController::RedirectBackError
@ -247,7 +263,7 @@ class TimelogController < ApplicationController
work_package_id = params[:time_entry][:work_package_id]
end
WorkPackage.find_by_id work_package_id
WorkPackage.find_by id: work_package_id
end
def default_breadcrumb

@ -35,7 +35,7 @@ class TypesController < ApplicationController
before_filter :require_admin
def index
@types = Type.page(params[:page]).per_page(per_page_param)
@types = ::Type.page(params[:page]).per_page(per_page_param)
end
def type
@ -43,34 +43,34 @@ class TypesController < ApplicationController
end
def new
@type = Type.new(params[:type])
@types = Type.find(:all, order: 'position')
@projects = Project.find(:all)
@type = ::Type.new(params[:type])
@types = ::Type.order('position')
@projects = Project.all
end
def create
@type = Type.new(permitted_params.type)
@type = ::Type.new(permitted_params.type)
if @type.save
# workflow copy
if !params[:copy_workflow_from].blank? && (copy_from = Type.find_by_id(params[:copy_workflow_from]))
if !params[:copy_workflow_from].blank? && (copy_from = ::Type.find_by(id: params[:copy_workflow_from]))
@type.workflows.copy(copy_from)
end
flash[:notice] = l(:notice_successful_create)
redirect_to action: 'index'
else
@types = Type.find(:all, order: 'position')
@projects = Project.find(:all)
@types = ::Type.order('position')
@projects = Project.all
render action: 'new'
end
end
def edit
@projects = Project.all
@type = Type.find(params[:id])
@type = ::Type.find(params[:id])
end
def update
@type = Type.find(params[:id])
@type = ::Type.find(params[:id])
# forbid renaming if it is a standard type
params[:type].delete :name if @type.is_standard?
@ -84,7 +84,7 @@ class TypesController < ApplicationController
end
def move
@type = Type.find(params[:id])
@type = ::Type.find(params[:id])
if @type.update_attributes(permitted_params.type_move)
flash[:notice] = l(:notice_successful_update)
@ -96,7 +96,7 @@ class TypesController < ApplicationController
end
def destroy
@type = Type.find(params[:id])
@type = ::Type.find(params[:id])
# types cannot be deleted when they have work packages
# or they are standard types
# put that into the model and do a `if @type.destroy`

@ -84,35 +84,35 @@ class UsersController < ApplicationController
.per_page(per_page_param)
respond_to do |format|
format.html {
format.html do
@groups = Group.all.sort
render layout: !request.xhr?
}
end
end
end
def show
# show projects based on current user visibility
@memberships = @user.memberships.all(conditions: Project.visible_by(User.current))
@memberships = @user.memberships.where(Project.visible_by(User.current))
events = Redmine::Activity::Fetcher.new(User.current, author: @user).events(nil, nil, limit: 10)
@events_by_day = events.group_by { |e| e.event_datetime.to_date }
unless User.current.admin?
if !(@user.active? || @user.registered?) || (@user != User.current && @memberships.empty? && events.empty?)
if !(@user.active? || @user.registered?) || (@user != User.current && @memberships.empty? && events.empty?)
render_404
return
end
end
respond_to do |format|
format.html { render layout: 'base' }
format.html do render layout: 'base' end
end
end
def new
@user = User.new(language: Setting.default_language, mail_notification: Setting.default_notification_option)
@auth_sources = AuthSource.find(:all)
@auth_sources = AuthSource.all
end
verify method: :post, only: :create, render: { nothing: true, status: :method_not_allowed }
@ -141,27 +141,27 @@ class UsersController < ApplicationController
UserMailer.account_information(@user, @user.password).deliver if params[:send_information]
respond_to do |format|
format.html {
format.html do
flash[:notice] = l(:notice_successful_create)
redirect_to(params[:continue] ?
new_user_path :
edit_user_path(@user)
)
}
)
end
end
else
@auth_sources = AuthSource.find(:all)
@auth_sources = AuthSource.all
# Clear password input
@user.password = @user.password_confirmation = nil
respond_to do |format|
format.html { render action: 'new' }
format.html do render action: 'new' end
end
end
end
def edit
@auth_sources = AuthSource.find(:all)
@auth_sources = AuthSource.all
@membership ||= Member.new
end
@ -192,19 +192,19 @@ class UsersController < ApplicationController
end
respond_to do |format|
format.html {
format.html do
flash[:notice] = l(:notice_successful_update)
redirect_to :back
}
end
end
else
@auth_sources = AuthSource.find(:all)
@auth_sources = AuthSource.all
@membership ||= Member.new
# Clear password input
@user.password = @user.password_confirmation = nil
respond_to do |format|
format.html { render action: :edit }
format.html do render action: :edit end
end
end
rescue ::ActionController::RedirectBackError
@ -246,21 +246,21 @@ class UsersController < ApplicationController
@membership.save if request.post?
respond_to do |format|
if @membership.valid?
format.html { redirect_to controller: '/users', action: 'edit', id: @user, tab: 'memberships' }
format.js {
format.html do redirect_to controller: '/users', action: 'edit', id: @user, tab: 'memberships' end
format.js do
render(:update) {|page|
page.replace_html 'tab-content-memberships', partial: 'users/memberships'
page.insert_html :top, 'tab-content-memberships', partial: 'members/common_notice', locals: { message: l(:notice_successful_update) }
page.visual_effect(:highlight, "member-#{@membership.id}")
}
}
end
else
format.js {
format.js do
render(:update) {|page|
page.replace_html 'tab-content-memberships', partial: 'users/memberships'
page.insert_html :top, 'tab-content-memberships', partial: 'members/member_errors', locals: { member: @membership }
}
}
end
end
end
end
@ -286,13 +286,13 @@ class UsersController < ApplicationController
@membership.destroy && @membership = nil
end
respond_to do |format|
format.html { redirect_to controller: '/users', action: 'edit', id: @user, tab: 'memberships' }
format.js {
format.html do redirect_to controller: '/users', action: 'edit', id: @user, tab: 'memberships' end
format.js do
render(:update) { |page|
page.replace_html 'tab-content-memberships', partial: 'users/memberships'
page.insert_html :top, 'tab-content-memberships', partial: 'members/common_notice', locals: { message: l(:notice_successful_delete) }
}
}
end
end
end
@ -319,10 +319,10 @@ class UsersController < ApplicationController
!User.current.admin?
respond_to do |format|
format.html { render_403 }
format.xml { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' }
format.js { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' }
format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' }
format.html do render_403 end
format.xml do head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' end
format.js do head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' end
format.json do head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' end
end
false

@ -38,7 +38,7 @@ class VersionsController < ApplicationController
include VersionsHelper
def index
@types = @project.types.find(:all, order: 'position')
@types = @project.types.order('position')
retrieve_selected_type_ids(@types, @types.select(&:is_in_roadmap?))
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_work_packages? : (params[:with_subprojects].to_i == 1)
project_ids = @with_subprojects ? @project.self_and_descendants.map(&:id) : [@project.id]
@ -51,10 +51,9 @@ class VersionsController < ApplicationController
@issues_by_version = {}
unless @selected_type_ids.empty?
@versions.each do |version|
issues = version.fixed_issues.visible.find(:all,
include: [:project, :status, :type, :priority],
conditions: { type_id: @selected_type_ids, project_id: project_ids },
order: "#{Project.table_name}.lft, #{Type.table_name}.position, #{WorkPackage.table_name}.id")
issues = version.fixed_issues.visible.includes(:project, :status, :type, :priority)
.where(type_id: @selected_type_ids, project_id: project_ids)
.order("#{Project.table_name}.lft, #{::Type.table_name}.position, #{WorkPackage.table_name}.id")
@issues_by_version[version] = issues
end
end
@ -62,9 +61,8 @@ class VersionsController < ApplicationController
end
def show
@issues = @version.fixed_issues.visible.find(:all,
include: [:status, :type, :priority],
order: "#{Type.table_name}.position, #{WorkPackage.table_name}.id")
@issues = @version.fixed_issues.visible.includes(:status, :type, :priority)
.order("#{::Type.table_name}.position, #{WorkPackage.table_name}.id")
end
def new
@ -98,7 +96,7 @@ class VersionsController < ApplicationController
end
else
respond_to do |format|
format.html { render action: 'new' }
format.html do render action: 'new' end
format.js do
render(:update) { |page| page.alert(@version.errors.full_messages.join('\n')) }
end
@ -111,7 +109,7 @@ class VersionsController < ApplicationController
end
def update
if request.put? && params[:version]
if request.patch? && params[:version]
attributes = params[:version].dup
attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
@version.safe_attributes = attributes
@ -120,7 +118,9 @@ class VersionsController < ApplicationController
redirect_back_or_default(settings_project_path(tab: 'versions', id: @project))
else
respond_to do |format|
format.html { render action: 'edit' }
format.html do
render action: 'edit'
end
end
end
end
@ -145,8 +145,8 @@ class VersionsController < ApplicationController
def status_by
respond_to do |format|
format.html { render action: 'show' }
format.js { render_status_by @version, params[:status_by] }
format.html do render action: 'show' end
format.js do render_status_by @version, params[:status_by] end
end
end

@ -52,7 +52,7 @@ class WatchersController < ApplicationController
@watcher.save if request.post?
respond_to do |format|
format.html { redirect_to :back }
format.html do redirect_to :back end
format.js do
render :update do |page|
page.replace_html 'watchers', partial: 'watchers/watchers', locals: { watched: @watched }
@ -69,7 +69,7 @@ class WatchersController < ApplicationController
def destroy
@watched.set_watcher(@watch.user, false)
respond_to do |format|
format.html { redirect_to :back }
format.html do redirect_to :back end
format.js do
render :update do |page|
page.replace_html 'watchers', partial: 'watchers/watchers', locals: { watched: @watched }
@ -92,7 +92,7 @@ class WatchersController < ApplicationController
def find_watched_by_id
return false unless params[:id].to_s =~ /\A\d+\z/
@watch = Watcher.find(params[:id], include: { watchable: [:project] })
@watch = Watcher.includes(watchable: [:project]).find(params[:id])
@watched = @watch.watchable
end
@ -104,7 +104,7 @@ class WatchersController < ApplicationController
@watched.set_watcher(user, watching)
respond_to do |format|
format.html { redirect_to :back }
format.html do redirect_to :back end
format.js do
if params[:replace].present?
if params[:replace].is_a? Array

@ -34,7 +34,7 @@ class WelcomeController < ApplicationController
end
def robots
@projects = Project.active.public
@projects = Project.active.public_projects
end
caches_action :robots
end

@ -83,7 +83,7 @@ class WikiController < ApplicationController
# List of pages, sorted alphabetically and by parent (hierarchy)
def index
@related_page = WikiPage.find_by_wiki_id_and_title(@wiki.id, params[:id])
@related_page = WikiPage.find_by(wiki_id: @wiki.id, title: params[:id])
load_pages_for_index
@pages_by_parent_id = @pages.group_by(&:parent_id)
@ -223,7 +223,7 @@ class WikiController < ApplicationController
@page.redirect_existing_links = true
# used to display the *original* title if some AR validation errors occur
@original_title = @page.pretty_title
if request.put? && @page.update_attributes(permitted_params.wiki_page_rename)
if request.patch? && @page.update_attributes(permitted_params.wiki_page_rename)
flash[:notice] = l(:notice_successful_update)
redirect_to_show
end
@ -231,7 +231,7 @@ class WikiController < ApplicationController
def edit_parent_page
return render_403 unless editable?
@parent_pages = @wiki.pages.all(include: :parent) - @page.self_and_descendants
@parent_pages = @wiki.pages.includes(:parent) - @page.self_and_descendants
end
def update_parent_page
@ -241,7 +241,7 @@ class WikiController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_to_show
else
@parent_pages = @wiki.pages.all(include: :parent) - @page.self_and_descendants
@parent_pages = @wiki.pages.includes(:parent) - @page.self_and_descendants
render 'edit_parent_page'
end
end
@ -291,7 +291,7 @@ class WikiController < ApplicationController
@page.descendants.each(&:destroy)
when 'reassign'
# Reassign children to another parent page
reassign_to = @wiki.pages.find_by_id(params[:reassign_to_id].to_i)
reassign_to = @wiki.pages.find_by(id: params[:reassign_to_id].to_i)
return unless reassign_to
@page.children.each do |child|
child.update_attribute(:parent, reassign_to)
@ -313,7 +313,7 @@ class WikiController < ApplicationController
# Export wiki to a single html file
def export
if User.current.allowed_to?(:export_wiki_pages, @project)
@pages = @wiki.pages.find :all, order: 'title'
@pages = @wiki.pages.order('title')
export = render_to_string action: 'export_multiple', layout: false
send_data(export, type: 'text/html', filename: 'wiki.html')
else
@ -330,8 +330,8 @@ class WikiController < ApplicationController
def list_attachments
respond_to do |format|
format.json { render 'common/list_attachments', locals: { attachments: @page.attachments } }
format.html {}
format.json do render 'common/list_attachments', locals: { attachments: @page.attachments } end
format.html
end
end
@ -395,7 +395,7 @@ class WikiController < ApplicationController
end
def load_pages_for_index
@pages = @wiki.pages.with_updated_on.all(order: 'title', include: { wiki: :project })
@pages = @wiki.pages.with_updated_on.order('title').includes(wiki: :project)
end
def default_breadcrumb

@ -81,20 +81,26 @@ class WikiMenuItemsController < ApplicationController
redirect_back_or_default(action: 'edit', id: @page)
else
respond_to do |format|
format.html { render action: 'edit', id: @page }
format.html do
render action: 'edit', id: @page
end
end
end
end
def select_main_menu_item
@page = WikiPage.find params[:id]
@possible_wiki_pages = @project.wiki.pages.all(include: :parent).reject { |page| page != @page && page.menu_item.present? && page.menu_item.is_main_item? }
@possible_wiki_pages = @project.wiki.pages.includes(:parent)
.reject { |page|
page != @page && page.menu_item.present? &&
page.menu_item.is_main_item?
}
end
def replace_main_menu_item
current_page = WikiPage.find params[:id]
if (current_menu_item = current_page.menu_item) && (page = WikiPage.find_by_id(params[:wiki_page][:id])) && current_menu_item != page.menu_item
if (current_menu_item = current_page.menu_item) && (page = WikiPage.find_by(id: params[:wiki_page][:id])) && current_menu_item != page.menu_item
create_main_menu_item_for_wiki_page(page, current_menu_item.options)
current_menu_item.destroy
end
@ -112,8 +118,8 @@ class WikiMenuItemsController < ApplicationController
@page_title = params[:id]
wiki_id = @project.wiki.id
@page = WikiPage.find_by_title_and_wiki_id(@page_title, wiki_id)
@wiki_menu_item = MenuItems::WikiMenuItem.find_or_initialize_by_navigatable_id_and_title(@page.wiki.id, @page_title)
@page = WikiPage.find_by(title: @page_title, wiki_id: wiki_id)
@wiki_menu_item = MenuItems::WikiMenuItem.find_or_initialize_by(navigatable_id: @page.wiki.id, title: @page_title)
possible_parent_menu_items = MenuItems::WikiMenuItem.main_items(wiki_id) - [@wiki_menu_item]
@parent_menu_item_options = possible_parent_menu_items.map { |item| [item.name, item.id] }

@ -32,7 +32,7 @@ class WorkPackageRelationsController < ApplicationController
def create
@relation = @work_package.new_relation.tap do |r|
r.to = WorkPackage.visible.find_by_id(params[:relation][:to_id].match(/\d+/).to_s)
r.to = WorkPackage.visible.find_by(id: params[:relation][:to_id].match(/\d+/).to_s)
r.relation_type = params[:relation][:relation_type]
r.delay = params[:relation][:delay]
end
@ -40,11 +40,11 @@ class WorkPackageRelationsController < ApplicationController
@relation.save
respond_to do |format|
format.html { redirect_to work_package_path(@work_package) }
format.js {
format.html do redirect_to work_package_path(@work_package) end
format.js do
render action: 'create', locals: { work_package: work_package,
relation: @relation }
}
end
end
end
@ -54,8 +54,8 @@ class WorkPackageRelationsController < ApplicationController
@relation.destroy
respond_to do |format|
format.html { redirect_to work_package_path(@work_package) }
format.js {}
format.html do redirect_to work_package_path(@work_package) end
format.js
end
end

@ -41,7 +41,7 @@ class WorkPackages::AutoCompletesController < ApplicationController
@work_packages = []
# query for exact ID matches first, to make an exact match the first result of autocompletion
if query_term =~ /\A\d+\z/
@work_packages |= scope.visible.find_all_by_id(query_term.to_i)
@work_packages |= scope.visible.where(id: query_term.to_i)
end
sql_query = ["LOWER(#{WorkPackage.table_name}.subject) LIKE :q OR
@ -55,14 +55,14 @@ class WorkPackages::AutoCompletesController < ApplicationController
respond_to do |format|
format.html do render layout: false end
format.any(:xml, :json) { render request.format.to_sym => wp_hashes_with_string }
format.any(:xml, :json) { render request.format.to_sym => wp_hashes_with_string(@work_packages) }
end
end
private
def wp_hashes_with_string
@work_packages.map do |work_package|
def wp_hashes_with_string(work_packages)
work_packages.map do |work_package|
wp_hash = Hash.new
work_package.attributes.each do |key, value| wp_hash[key] = Rack::Utils.escape_html(value) end
wp_hash['to_s'] = Rack::Utils.escape_html(work_package.to_s)
@ -73,9 +73,7 @@ class WorkPackages::AutoCompletesController < ApplicationController
def find_project
project_id = (params[:work_package] && params[:work_package][:project_id]) || params[:project_id]
return nil unless project_id
Project.find(project_id)
rescue ActiveRecord::RecordNotFound
nil
Project.find_by_id(project_id)
end
def determine_scope
@ -84,9 +82,9 @@ class WorkPackages::AutoCompletesController < ApplicationController
if params[:scope] == 'relatable'
return nil unless project
Setting.cross_project_work_package_relations? ? WorkPackage.scoped : project.work_packages
Setting.cross_project_work_package_relations? ? WorkPackage.all : project.work_packages
elsif params[:scope] == 'all' || project.nil?
WorkPackage.scoped
WorkPackage.all
else
project.work_packages
end

@ -40,8 +40,8 @@ class WorkPackages::BulkController < ApplicationController
def edit
@work_packages.sort!
@available_statuses = @projects.map { |p|Workflow.available_statuses(p) }.inject { |memo, w|memo & w }
@custom_fields = @projects.map(&:all_work_package_custom_fields).inject { |memo, c|memo & c }
@available_statuses = @projects.map { |p| Workflow.available_statuses(p) }.inject { |memo, w| memo & w }
@custom_fields = @projects.map(&:all_work_package_custom_fields).inject { |memo, c| memo & c }
@assignables = @projects.map(&:possible_assignees).inject { |memo, a| memo & a }
@responsibles = @projects.map(&:possible_responsibles).inject { |memo, a| memo & a }
@types = @projects.map(&:types).inject { |memo, t| memo & t }
@ -74,11 +74,13 @@ class WorkPackages::BulkController < ApplicationController
unless WorkPackage.cleanup_associated_before_destructing_if_required(@work_packages, current_user, params[:to_do])
respond_to do |format|
format.html {
format.html do
render locals: { work_packages: @work_packages,
associated: WorkPackage.associated_classes_to_address_before_destruction_of(@work_packages) }
}
format.json { render json: { error_message: 'Clean up of associated objects required' }, status: 420 }
end
format.json do
render json: { error_message: 'Clean up of associated objects required' }, status: 420
end
end
else
@ -86,8 +88,12 @@ class WorkPackages::BulkController < ApplicationController
destroy_work_packages(@work_packages)
respond_to do |format|
format.html { redirect_back_or_default(project_work_packages_path(@work_packages.first.project)) }
format.json { head :ok }
format.html do
redirect_back_or_default(project_work_packages_path(@work_packages.first.project))
end
format.json do
head :ok
end
end
end
end
@ -110,7 +116,7 @@ class WorkPackages::BulkController < ApplicationController
safe_params = permitted_params.update_work_package project: project
attributes = safe_params.reject { |_k, v| v.blank? }
attributes.keys.each { |k| attributes[k] = '' if attributes[k] == 'none' }
attributes.keys.each do |k| attributes[k] = '' if attributes[k] == 'none' end
attributes[:custom_field_values].reject! { |_k, v| v.blank? } if attributes[:custom_field_values]
attributes.delete :custom_field_values if not attributes.has_key?(:custom_field_values) or attributes[:custom_field_values].empty?
attributes

@ -40,7 +40,7 @@ class WorkPackages::MovesController < ApplicationController
def create
prepare_for_work_package_move
new_type = params[:new_type_id].blank? ? nil : @target_project.types.find_by_id(params[:new_type_id])
new_type = params[:new_type_id].blank? ? nil : @target_project.types.find_by(id: params[:new_type_id])
unsaved_work_package_ids = []
moved_work_packages = []
@work_packages.each do |work_package|

@ -50,9 +50,9 @@ class WorkPackages::ReportsController < ApplicationController
respond_to do |format|
if @report
format.html {}
format.html
else
format.html { redirect_to report_project_work_packages_path(@project) }
format.html do redirect_to report_project_work_packages_path(@project) end
end
end
end

@ -28,8 +28,6 @@
#++
class WorkPackagesController < ApplicationController
unloadable
DEFAULT_SORT_ORDER = ['parent', 'desc']
EXPORT_FORMATS = %w[atom rss xls csv pdf]
@ -107,12 +105,12 @@ class WorkPackagesController < ApplicationController
def new
respond_to do |format|
format.html {
format.html do
render locals: { work_package: work_package,
project: project,
priorities: priorities,
user: current_user }
}
end
end
end
@ -121,12 +119,12 @@ class WorkPackagesController < ApplicationController
work_package.update_by(current_user, safe_params)
respond_to do |format|
format.js {
format.js do
render locals: { work_package: work_package,
project: project,
priorities: priorities,
user: current_user }
}
end
end
end
@ -145,12 +143,12 @@ class WorkPackagesController < ApplicationController
redirect_to(work_package_path(work_package))
else
respond_to do |format|
format.html {
format.html do
render action: 'new', locals: { work_package: work_package,
project: project,
priorities: priorities,
user: current_user }
}
end
end
end
end
@ -275,8 +273,8 @@ class WorkPackagesController < ApplicationController
user: current_user }
respond_to do |format|
format.js { render partial: 'edit', locals: locals }
format.html { render action: 'edit', locals: locals }
format.js do render partial: 'edit', locals: locals end
format.html do render action: 'edit', locals: locals end
end
end
@ -292,7 +290,7 @@ class WorkPackagesController < ApplicationController
@existing_work_package ||= begin
wp = WorkPackage.includes(:project)
.find_by_id(params[:id])
.find_by(id: params[:id])
wp && wp.visible?(current_user) ?
wp :
@ -355,7 +353,6 @@ class WorkPackagesController < ApplicationController
@changesets ||= begin
changes = work_package.changesets.visible
.includes({ repository: { project: :enabled_modules } }, :user)
.all
changes.reverse! if current_user.wants_comments_in_reverse_order?
@ -454,7 +451,6 @@ class WorkPackagesController < ApplicationController
@work_packages = if @query.valid?
@results.work_packages.page(page_param)
.per_page(per_page_param)
.all
else
[]
end

@ -39,18 +39,18 @@ class WorkflowsController < ApplicationController
end
def edit
@role = Role.find_by_id(params[:role_id])
@type = Type.find_by_id(params[:type_id])
@role = Role.find_by(id: params[:role_id])
@type = ::Type.find_by(id: params[:type_id])
if request.post?
Workflow.destroy_all(['role_id=? and type_id=?', @role.id, @type.id])
(params[:status] || []).each { |status_id, transitions|
(params[:status] || []).each do |status_id, transitions|
transitions.each { |new_status_id, options|
author = options.is_a?(Array) && options.include?('author') && !options.include?('always')
assignee = options.is_a?(Array) && options.include?('assignee') && !options.include?('always')
@role.workflows.build(type_id: @type.id, old_status_id: status_id, new_status_id: new_status_id, author: author, assignee: assignee)
}
}
end
if @role.save
flash[:notice] = l(:notice_successful_update)
redirect_to action: 'edit', role_id: @role, type_id: @type
@ -65,7 +65,7 @@ class WorkflowsController < ApplicationController
@statuses ||= Status.all
if @type && @role && @statuses.any?
workflows = Workflow.all(conditions: { role_id: @role.id, type_id: @type.id })
workflows = Workflow.where(role_id: @role.id, type_id: @type.id)
@workflows = {}
@workflows['always'] = workflows.select { |w| !w.author && !w.assignee }
@workflows['author'] = workflows.select(&:author)
@ -77,16 +77,16 @@ class WorkflowsController < ApplicationController
if params[:source_type_id].blank? || params[:source_type_id] == 'any'
@source_type = nil
else
@source_type = Type.find_by_id(params[:source_type_id].to_i)
@source_type = ::Type.find_by(id: params[:source_type_id].to_i)
end
if params[:source_role_id].blank? || params[:source_role_id] == 'any'
@source_role = nil
else
@source_role = Role.find_by_id(params[:source_role_id].to_i)
@source_role = Role.find_by(id: params[:source_role_id].to_i)
end
@target_types = params[:target_type_ids].blank? ? nil : Type.find_all_by_id(params[:target_type_ids])
@target_roles = params[:target_role_ids].blank? ? nil : Role.find_all_by_id(params[:target_role_ids])
@target_types = params[:target_type_ids].blank? ? nil : ::Type.where(id: params[:target_type_ids])
@target_roles = params[:target_role_ids].blank? ? nil : Role.where(id: params[:target_role_ids])
if request.post?
if params[:source_type_id].blank? || params[:source_role_id].blank? || (@source_type.nil? && @source_role.nil?)
@ -104,10 +104,10 @@ class WorkflowsController < ApplicationController
private
def find_roles
@roles = Role.find(:all, order: 'builtin, position')
@roles = Role.order('builtin, position')
end
def find_types
@types = Type.find(:all, order: 'position')
@types = ::Type.order('position')
end
end

@ -36,9 +36,9 @@ class API::Experimental::WorkPackageDecorator < SimpleDelegator
def custom_values_display_data(field_ids)
field_ids = Array(field_ids)
field_ids.map do |field_id|
value = custom_values.detect do |cv|
value = custom_values.detect { |cv|
cv.custom_field_id == field_id.to_i
end
}
get_cast_custom_value_with_meta(value)
end

@ -108,9 +108,9 @@ module ApplicationHelper
def image_to_function(name, function, html_options = {})
html_options.symbolize_keys!
tag(:input, html_options.merge(
type: 'image', src: image_path(name),
onclick: (html_options[:onclick] ? "#{html_options[:onclick]}; " : '') + "#{function};"
))
type: 'image', src: image_path(name),
onclick: (html_options[:onclick] ? "#{html_options[:onclick]}; " : '') + "#{function};"
))
end
def prompt_to_remote(name, text, param, url, html_options = {})
@ -127,7 +127,7 @@ module ApplicationHelper
end
def format_activity_description(text)
h(truncate(text.to_s, length: 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, '<br />').html_safe
html_escape_once(truncate(text.to_s, length: 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, '<br />').html_safe
end
def format_version_name(version)
@ -144,13 +144,13 @@ module ApplicationHelper
return '' unless pages[node]
content_tag :ul, class: 'pages-hierarchy' do
pages[node].map do |page|
pages[node].map { |page|
content_tag :li do
concat link_to(page.pretty_title, project_wiki_path(page.project, page),
title: (options[:timestamp] && page.updated_on ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
concat render_page_hierarchy(pages, page.id, options) if pages[page.id]
end
end.join.html_safe
}.join.html_safe
end
end
@ -171,7 +171,7 @@ module ApplicationHelper
def extract_objects_from_params(params)
options = params.extract_options!.symbolize_keys
objects = Array.wrap(options.delete(:object) || params).map do |object|
objects = Array.wrap(options.delete(:object) || params).map { |object|
object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
object = convert_to_model(object)
@ -180,7 +180,7 @@ module ApplicationHelper
end
object
end
}
[objects.compact, options]
end
@ -218,8 +218,7 @@ module ApplicationHelper
end
def project_tree_options_for_select(projects, options = {}, &_block)
Project.project_level_list(projects).map do |element|
Project.project_level_list(projects).map { |element|
tag_options = {
value: h(element[:project].id),
title: h(element[:project].name),
@ -238,7 +237,7 @@ module ApplicationHelper
tag_options.merge!(yield(element[:project])) if block_given?
content_tag('option', level_prefix + h(element[:project].name), tag_options)
end.join('').html_safe
}.join('').html_safe
end
# Yields the given block for each project with its level in the tree
@ -279,16 +278,16 @@ module ApplicationHelper
end
def labeled_check_box_tags(name, collection, options = {})
collection.sort.map do |object|
collection.sort.map { |object|
id = name.gsub(/[\[\]]+/, '_') + object.id.to_s
object_options = options.inject({}) do |h, (k, v)|
object_options = options.inject({}) { |h, (k, v)|
h[k] = v.is_a?(Symbol) ?
send(v, object) :
v
h
end
}
object_options[:class] = Array(object_options[:class]) + %w(form--label-with-check-box)
@ -297,7 +296,7 @@ module ApplicationHelper
styled_check_box_tag(name, object.id, false, id: id) + object
end
end
end.join.html_safe
}.join.html_safe
end
def html_hours(text)
@ -339,7 +338,7 @@ module ApplicationHelper
link_to(image_tag('1downarrow.png', alt: l(:label_sort_lower)), url.merge("#{name}[move_to]" => 'lower'), method: method, title: l(:label_sort_lower)) +
link_to(image_tag('2downarrow.png', alt: l(:label_sort_lowest)), url.merge("#{name}[move_to]" => 'lowest'), method: method, title: l(:label_sort_lowest)),
class: 'reorder-icons'
)
)
end
def other_formats_links(&block)
@ -498,17 +497,17 @@ module ApplicationHelper
@calendar_headers_tags_included = true
content_for :header_tags do
start_of_week = case Setting.start_of_week.to_i
when 1
'1' # Monday
when 7
'0' # Sunday
when 6
'6' # Saturday
else
# use language (pass a blank string into the JSON object,
# as the datepicker implementation checks for numbers in
# /frontend/app/misc/datepicker-defaults.js:34)
'""'
when 1
'1' # Monday
when 7
'0' # Sunday
when 6
'6' # Saturday
else
# use language (pass a blank string into the JSON object,
# as the datepicker implementation checks for numbers in
# /frontend/app/misc/datepicker-defaults.js:34)
'""'
end
# FIXME: Get rid of this abomination
js = "var CS = { lang: '#{current_language.to_s.downcase}', firstDay: #{start_of_week} };"

@ -61,19 +61,19 @@ module AvatarHelper
# Returns the avatar image tag for the given +user+ if avatars are enabled
# +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 = {})
avatar = with_default_avatar_options(user, options) do |email, opts|
avatar = with_default_avatar_options(user, options) { |email, opts|
tag_options = merge_image_options(user, opts)
gravatar_image_tag(email, tag_options)
end
}
ensure # return is actually needed here
return (avatar || ''.html_safe)
end
def avatar_url(user, options = {})
url = with_default_avatar_options(user, options) do |email, opts|
url = with_default_avatar_options(user, options) { |email, opts|
gravatar_image_url(email, opts)
end
}
ensure # return is actually needed here
return (url || ''.html_safe)
end

@ -44,9 +44,9 @@ module BreadcrumbHelper
cutme_elements = []
breadcrumb_elements = [content_tag(:li, elements.shift.to_s, class: 'first-breadcrumb-element', style: 'list-style-image:none;')]
breadcrumb_elements += elements.map do |element|
breadcrumb_elements += elements.map { |element|
content_tag(:li, h(element.to_s)) if element
end
}
content_tag(:ul, breadcrumb_elements.join.html_safe, class: 'breadcrumb')
end

@ -49,29 +49,29 @@ module CustomFieldsHelper
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
tag = case field_format.try(:edit_as)
when 'date'
styled_text_field_tag(field_name, custom_value.value, id: field_id, size: 10) +
calendar_for(field_id)
when 'text'
styled_text_area_tag(field_name, custom_value.value, id: field_id, rows: 3)
when 'bool'
hidden_tag = hidden_field_tag(field_name, '0')
checkbox_tag = styled_check_box_tag(field_name, '1', custom_value.typed_value, id: field_id)
hidden_tag + checkbox_tag
when 'list'
blank_option = if custom_field.is_required? && custom_field.default_value.blank?
"<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>"
elsif custom_field.is_required? && !custom_field.default_value.blank?
''
else
'<option></option>'
end
options = blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value)
styled_select_tag(field_name, options, id: field_id)
else
styled_text_field_tag(field_name, custom_value.value, id: field_id)
when 'date'
styled_text_field_tag(field_name, custom_value.value, id: field_id, size: 10) +
calendar_for(field_id)
when 'text'
styled_text_area_tag(field_name, custom_value.value, id: field_id, rows: 3)
when 'bool'
hidden_tag = hidden_field_tag(field_name, '0')
checkbox_tag = styled_check_box_tag(field_name, '1', custom_value.typed_value, id: field_id)
hidden_tag + checkbox_tag
when 'list'
blank_option = if custom_field.is_required? && custom_field.default_value.blank?
"<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>"
elsif custom_field.is_required? && !custom_field.default_value.blank?
''
else
'<option></option>'
end
options = blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value)
styled_select_tag(field_name, options, id: field_id)
else
styled_text_field_tag(field_name, custom_value.value, id: field_id)
end
tag = content_tag :span, tag, lang: custom_field.name_locale
@ -107,19 +107,19 @@ module CustomFieldsHelper
field_id = "#{name}_custom_field_values_#{custom_field.id}"
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
case field_format.try(:edit_as)
when 'date'
styled_text_field_tag(field_name, '', id: field_id, size: 10) +
calendar_for(field_id)
when 'text'
styled_text_area_tag(field_name, '', id: field_id, rows: 3)
when 'bool'
styled_select_tag(field_name, options_for_select([[l(:label_no_change_option), ''],
[l(:general_text_yes), '1'],
[l(:general_text_no), '0']]), id: field_id)
when 'list'
styled_select_tag(field_name, options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values_options), id: field_id)
else
styled_text_field_tag(field_name, '', id: field_id)
when 'date'
styled_text_field_tag(field_name, '', id: field_id, size: 10) +
calendar_for(field_id)
when 'text'
styled_text_area_tag(field_name, '', id: field_id, rows: 3)
when 'bool'
styled_select_tag(field_name, options_for_select([[l(:label_no_change_option), ''],
[l(:general_text_yes), '1'],
[l(:general_text_no), '0']]), id: field_id)
when 'list'
styled_select_tag(field_name, options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values_options), id: field_id)
else
styled_text_field_tag(field_name, '', id: field_id)
end
end

@ -97,39 +97,18 @@ module IssuesHelper
n = 0
ordered_values.compact.each do |value|
s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
s << "\t<th>#{h(value.custom_field.name)}:</th><td>#{simple_format_without_paragraph(h(show_value(value)))}</td>\n"
n += 1
end
s << "</tr>\n"
s.html_safe
end
def visible_queries
unless @visible_queries
# User can see public queries and his own queries
visible = ARCondition.new(['is_public = ? OR user_id = ?', true, (User.current.logged? ? User.current.id : 0)])
# Project specific queries and global queries
visible << (@project.nil? ? ['project_id IS NULL'] : ['project_id IS NULL OR project_id = ?', @project.id])
@visible_queries = Query.find(:all,
select: 'id, name, is_public',
order: 'name ASC',
conditions: visible.conditions)
end
@visible_queries
end
def grouped_query_options
{
l(:label_my_queries) => visible_queries.select { |query| !query.is_public? }.map { |query| [query.name, query.id] },
l(:label_query_plural) => visible_queries.select(&:is_public?).map { |query| [query.name, query.id] }
}
end
# Find the name of an associated record stored in the field attribute
def find_name_by_reflection(field, id)
association = WorkPackage.reflect_on_association(field.to_sym)
if association
record = association.class_name.constantize.find_by_id(id)
record = association.class_name.constantize.find_by(id: id)
return record.name if record
end
end
@ -149,9 +128,9 @@ module IssuesHelper
end
def entries_for_filter_select_sorted(query)
[['', '']] + query.available_work_package_filters.map { |field| [field[1][:name] || WorkPackage.human_attribute_name(field[0]), field[0]] unless query.has_filter?(field[0]) }.compact.sort_by do |el|
[['', '']] + query.available_work_package_filters.map { |field| [field[1][:name] || WorkPackage.human_attribute_name(field[0]), field[0]] unless query.has_filter?(field[0]) }.compact.sort_by { |el|
ActiveSupport::Inflector.transliterate(el[0]).downcase
end
}
end
def value_overridden_by_children?(attrib)

@ -28,7 +28,6 @@
#++
module JournalsHelper
# unloadable
include ApplicationHelper
include ERB::Util
include ActionView::Helpers::TagHelper
@ -62,11 +61,11 @@ module JournalsHelper
if journal.details.any?
details = content_tag 'ul', class: 'details journal-attributes' do
journal.details.map do |detail|
journal.details.map { |detail|
if d = journal.render_detail(detail, cache: options[:cache])
content_tag('li', d.html_safe)
end
end.compact.join(' ').html_safe
}.compact.join(' ').html_safe
end
end
@ -128,7 +127,7 @@ module JournalsHelper
# This may conveniently be used by controllers to find journals referred to in the current request
def find_optional_journal
@journal = Journal.find_by_id(params[:journal_id])
@journal = Journal.find_by(id: params[:journal_id])
end
def render_reply(journal)

@ -35,7 +35,6 @@ module MyHelper
.where(project_id: User.current.projects.map(&:id))
.where('(start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)', startdt, enddt, startdt, enddt)
.includes(:project, :type, :priority, :assigned_to)
.all
end
def wps_assigned_to_me
@ -43,7 +42,6 @@ module MyHelper
.limit(10)
.order("#{IssuePriority.table_name}.position DESC, " \
"#{WorkPackage.table_name}.updated_at DESC")
.all
end
def wps_assigned_to_me_count

@ -53,11 +53,11 @@ module PaginationHelper
end
def per_page_links(selected = nil, options = params)
links = Setting.per_page_options_array.map do |n|
links = Setting.per_page_options_array.map { |n|
n == selected ?
content_tag(:span, n, class: 'current') :
link_to_content_update(n, options.merge(page: 1, per_page: n))
end
}
content_tag :span, class: 'per_page_options' do
links.size > 1 ? l(:label_display_per_page, links.join(', ')).html_safe : nil
end

@ -0,0 +1,56 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# 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.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
module PasswordHelper
def render_password_complexity_tooltip
rules = password_rules_description
s = OpenProject::Passwords::Evaluator.min_length_description
s += "<br> #{rules}" if rules.present?
s.html_safe
end
private
# Return a HTML list with active password complexity rules
def password_active_rules
rules = OpenProject::Passwords::Evaluator.active_rules_list
content_tag :ul do
rules.map { |item| concat(content_tag(:li, item)) }
end
end
# Returns a text describing the active password complexity rules,
# the minimum number of rules to adhere to and the total number of rules.
def password_rules_description
return '' if OpenProject::Passwords::Evaluator.min_adhered_rules == 0
OpenProject::Passwords::Evaluator.rules_description_locale(password_active_rules)
end
end

@ -44,7 +44,7 @@ module ProjectsHelper
{ name: 'repository', action: :manage_repository, partial: 'repositories/settings', label: :label_repository },
{ name: 'boards', action: :manage_boards, partial: 'projects/settings/boards', label: :label_board_plural },
{ name: 'activities', action: :manage_project_activities, partial: 'projects/settings/activities', label: :enumeration_activities },
{ name: 'types', action: :manage_types, partial: 'projects/settings/types', label: :'label_type_plural' }
{ name: 'types', action: :manage_types, partial: 'projects/settings/types', label: :label_type_plural }
]
tabs.select { |tab| User.current.allowed_to?(tab[:action], @project) }
end
@ -61,7 +61,7 @@ module ProjectsHelper
# 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"
s << "<ul class='projects #{ancestors.empty? ? 'root' : nil}'>\n"
else
ancestors.pop
s << '</li>'

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

Loading…
Cancel
Save