Compare commits
158
Commits
master
..
2.3-stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ce399b0fb | ||
|
|
e143f01e84 | ||
|
|
75e90593e0 | ||
|
|
daf2d54f27 | ||
|
|
8849727bd9 | ||
|
|
c4eb7c380e | ||
|
|
4deca5976e | ||
|
|
8a046027e5 | ||
|
|
711a8aa09b | ||
|
|
7ec18933e0 | ||
|
|
0a25ee385f | ||
|
|
79f90dfba5 | ||
|
|
2b53422d1d | ||
|
|
77ad962132 | ||
|
|
7bfb4759e7 | ||
|
|
9d3377c92c | ||
|
|
55a1869b86 | ||
|
|
bcae879091 | ||
|
|
2c44829509 | ||
|
|
d259dd2dd5 | ||
|
|
ddc016d81d | ||
|
|
e7c82e3934 | ||
|
|
e503f41f6f | ||
|
|
cd67243de5 | ||
|
|
b0c3b7a574 | ||
|
|
9a67caf248 | ||
|
|
67ee8653bd | ||
|
|
36978279c3 | ||
|
|
d155392b3c | ||
|
|
dc98cec17f | ||
|
|
e1e006f09e | ||
|
|
e8757fec2b | ||
|
|
591922c365 | ||
|
|
5eeca35317 | ||
|
|
2de51892ee | ||
|
|
3fe5e3bb6f | ||
|
|
bbf3ffe0aa | ||
|
|
b724eb4fec | ||
|
|
493119e795 | ||
|
|
f1b6b4ef33 | ||
|
|
ce002ee3df | ||
|
|
eb7862445c | ||
|
|
b31b5328e4 | ||
|
|
8efcf60319 | ||
|
|
e07bc81c5e | ||
|
|
5c6349a7ca | ||
|
|
37fbdb1457 | ||
|
|
a13acb7851 | ||
|
|
01887f1e67 | ||
|
|
3d9f274140 | ||
|
|
7375dff6d6 | ||
|
|
9874a61ec3 | ||
|
|
b5998b59ab | ||
|
|
c590cded4b | ||
|
|
5b8af329e2 | ||
|
|
0badc79162 | ||
|
|
5e57cbfdc4 | ||
|
|
489527ada7 | ||
|
|
6ce685a63c | ||
|
|
8045385990 | ||
|
|
3a4c46089f | ||
|
|
53d45273a9 | ||
|
|
cc23ab9652 | ||
|
|
ea33a66c6b | ||
|
|
a8c27df9fe | ||
|
|
af632568e3 | ||
|
|
2c408ca6a5 | ||
|
|
2a6dadf787 | ||
|
|
958f1accec | ||
|
|
77a2cbfa6a | ||
|
|
73b4b614ee | ||
|
|
1a71316b37 | ||
|
|
5fa087a792 | ||
|
|
425a0fe988 | ||
|
|
606762dcad | ||
|
|
07dc1e34ff | ||
|
|
1afe67bf74 | ||
|
|
f9f4591cff | ||
|
|
aa4fc1b58a | ||
|
|
8c17237638 | ||
|
|
06ab582e5d | ||
|
|
af66c42d9e | ||
|
|
655c50849d | ||
|
|
bd5b7428d8 | ||
|
|
4ed30a4495 | ||
|
|
ca39b05420 | ||
|
|
e189641e8c | ||
|
|
102dd4c11b | ||
|
|
c1d853d957 | ||
|
|
225f99377a | ||
|
|
d8cf4c57d3 | ||
|
|
4b5fa08f66 | ||
|
|
4380c0af73 | ||
|
|
61a32a5002 | ||
|
|
5745a2a2e3 | ||
|
|
f98f9b9ae1 | ||
|
|
cfec2018e3 | ||
|
|
0083420829 | ||
|
|
338d7ea91d | ||
|
|
73fb7e3427 | ||
|
|
edb7f2d2c5 | ||
|
|
594d9e9da2 | ||
|
|
7ebc62387a | ||
|
|
3269c42cdc | ||
|
|
9436318987 | ||
|
|
94ecabbaf9 | ||
|
|
063c9a2a83 | ||
|
|
376e8d4aa3 | ||
|
|
20114bd8e0 | ||
|
|
cfdd85173f | ||
|
|
5de8e9f04c | ||
|
|
79db8fd3e0 | ||
|
|
98b7900c5c | ||
|
|
23c28c1ef7 | ||
|
|
974863e8f4 | ||
|
|
58af20746b | ||
|
|
efcd602444 | ||
|
|
20cd146e93 | ||
|
|
8a97dfdeab | ||
|
|
b0b7f4d7d6 | ||
|
|
53680edb2d | ||
|
|
ddf0307718 | ||
|
|
0ab90145fe | ||
|
|
f4def66c58 | ||
|
|
4413e0e52e | ||
|
|
b2e1080007 | ||
|
|
8245eaa9f3 | ||
|
|
83430dacd9 | ||
|
|
998a29cbaf | ||
|
|
511099e9ca | ||
|
|
a18db94c06 | ||
|
|
fe3a4cdbd1 | ||
|
|
67bb69d68e | ||
|
|
639b6f5c85 | ||
|
|
b783bbf3bb | ||
|
|
a4b6928a26 | ||
|
|
0e92038047 | ||
|
|
35b17d3bdc | ||
|
|
8672114648 | ||
|
|
699fa9ac3f | ||
|
|
a5a1bd5a35 | ||
|
|
4100d3beeb | ||
|
|
58ebb87ae6 | ||
|
|
33ef9fbe29 | ||
|
|
b0fa5e7305 | ||
|
|
5bb2f5e211 | ||
|
|
2293a5d3f4 | ||
|
|
d14cd42a78 | ||
|
|
2a53538616 | ||
|
|
d1f63717dd | ||
|
|
d22b085d1d | ||
|
|
15751a6931 | ||
|
|
052cf73dfd | ||
|
|
a4bee12e5a | ||
|
|
92507382b4 | ||
|
|
e6d63a4e0d | ||
|
|
346085c5fc | ||
|
|
dcfc9170e6 |
@@ -1,7 +1,5 @@
|
|||||||
/.project
|
/.project
|
||||||
/.loadpath
|
/.loadpath
|
||||||
/.powrc
|
|
||||||
/.rvmrc
|
|
||||||
/config/additional_environment.rb
|
/config/additional_environment.rb
|
||||||
/config/configuration.yml
|
/config/configuration.yml
|
||||||
/config/database.yml
|
/config/database.yml
|
||||||
@@ -17,14 +15,8 @@
|
|||||||
/lib/redmine/scm/adapters/mercurial/redminehelper.pyo
|
/lib/redmine/scm/adapters/mercurial/redminehelper.pyo
|
||||||
/log/*.log*
|
/log/*.log*
|
||||||
/log/mongrel_debug
|
/log/mongrel_debug
|
||||||
/plugins/*
|
|
||||||
!/plugins/README
|
|
||||||
/public/dispatch.*
|
/public/dispatch.*
|
||||||
/public/plugin_assets
|
/public/plugin_assets
|
||||||
/public/themes/*
|
|
||||||
!/public/themes/alternate
|
|
||||||
!/public/themes/classic
|
|
||||||
!/public/themes/README
|
|
||||||
/tmp/*
|
/tmp/*
|
||||||
/tmp/cache/*
|
/tmp/cache/*
|
||||||
/tmp/pdf/*
|
/tmp/pdf/*
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ syntax: glob
|
|||||||
|
|
||||||
.project
|
.project
|
||||||
.loadpath
|
.loadpath
|
||||||
.powrc
|
|
||||||
.rvmrc
|
|
||||||
config/additional_environment.rb
|
config/additional_environment.rb
|
||||||
config/configuration.yml
|
config/configuration.yml
|
||||||
config/database.yml
|
config/database.yml
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
|
|
||||||
**Do not send a pull requst to this github repository**.
|
|
||||||
|
|
||||||
For more detail, please see [official website] wiki [Contribute].
|
|
||||||
|
|
||||||
[official website]: http://www.redmine.org
|
|
||||||
[Contribute]: http://www.redmine.org/projects/redmine/wiki/Contribute
|
|
||||||
|
|
||||||
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
|
|||||||
gem "rails", "3.2.13"
|
gem "rails", "3.2.13"
|
||||||
gem "jquery-rails", "~> 2.0.2"
|
gem "jquery-rails", "~> 2.0.2"
|
||||||
gem "i18n", "~> 0.6.0"
|
gem "i18n", "~> 0.6.0"
|
||||||
gem "coderay", "~> 1.1.0"
|
gem "coderay", "~> 1.0.9"
|
||||||
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
|
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
|
||||||
gem "builder", "3.0.0"
|
gem "builder", "3.0.0"
|
||||||
|
|
||||||
@@ -78,12 +78,10 @@ end
|
|||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem "shoulda", "~> 3.3.2"
|
gem "shoulda", "~> 3.3.2"
|
||||||
gem "mocha", ">= 0.14", :require => 'mocha/api'
|
gem "mocha", "~> 0.13.3"
|
||||||
if RUBY_VERSION >= '1.9.3'
|
gem 'capybara', '~> 2.0.0'
|
||||||
gem "capybara", "~> 2.1.0"
|
gem 'nokogiri', '< 1.6.0'
|
||||||
gem "selenium-webdriver"
|
gem 'selenium-webdriver', '2.35.1'
|
||||||
gem "database_cleaner"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
|
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
|
||||||
@@ -95,6 +93,5 @@ end
|
|||||||
# Load plugins' Gemfiles
|
# Load plugins' Gemfiles
|
||||||
Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
|
Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
|
||||||
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
|
||||||
#TODO: switch to "eval_gemfile file" when bundler >= 1.2.0 will be required (rails 4)
|
instance_eval File.read(file)
|
||||||
instance_eval File.read(file), file
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class AccountController < ApplicationController
|
|||||||
include CustomFieldsHelper
|
include CustomFieldsHelper
|
||||||
|
|
||||||
# prevents login action to be filtered by check_if_login_required application scope filter
|
# prevents login action to be filtered by check_if_login_required application scope filter
|
||||||
skip_before_filter :check_if_login_required, :check_password_change
|
skip_before_filter :check_if_login_required
|
||||||
|
|
||||||
# Login request and validation
|
# Login request and validation
|
||||||
def login
|
def login
|
||||||
@@ -75,15 +75,11 @@ class AccountController < ApplicationController
|
|||||||
else
|
else
|
||||||
if request.post?
|
if request.post?
|
||||||
user = User.find_by_mail(params[:mail].to_s)
|
user = User.find_by_mail(params[:mail].to_s)
|
||||||
# user not found
|
# user not found or not active
|
||||||
unless user
|
unless user && user.active?
|
||||||
flash.now[:error] = l(:notice_account_unknown_email)
|
flash.now[:error] = l(:notice_account_unknown_email)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
unless user.active?
|
|
||||||
handle_inactive_user(user, lost_password_path)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
# user cannot change its password
|
# user cannot change its password
|
||||||
unless user.change_password_allowed?
|
unless user.change_password_allowed?
|
||||||
flash.now[:error] = l(:notice_can_t_change_password)
|
flash.now[:error] = l(:notice_can_t_change_password)
|
||||||
@@ -156,19 +152,6 @@ class AccountController < ApplicationController
|
|||||||
redirect_to signin_path
|
redirect_to signin_path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sends a new account activation email
|
|
||||||
def activation_email
|
|
||||||
if session[:registered_user_id] && Setting.self_registration == '1'
|
|
||||||
user_id = session.delete(:registered_user_id).to_i
|
|
||||||
user = User.find_by_id(user_id)
|
|
||||||
if user && user.registered?
|
|
||||||
register_by_email_activation(user)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
redirect_to(home_url)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def authenticate_user
|
def authenticate_user
|
||||||
@@ -180,7 +163,7 @@ class AccountController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def password_authentication
|
def password_authentication
|
||||||
user = User.try_to_login(params[:username], params[:password], false)
|
user = User.try_to_login(params[:username], params[:password])
|
||||||
|
|
||||||
if user.nil?
|
if user.nil?
|
||||||
invalid_credentials
|
invalid_credentials
|
||||||
@@ -188,31 +171,27 @@ class AccountController < ApplicationController
|
|||||||
onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id })
|
onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id })
|
||||||
else
|
else
|
||||||
# Valid user
|
# Valid user
|
||||||
if user.active?
|
successful_authentication(user)
|
||||||
successful_authentication(user)
|
|
||||||
else
|
|
||||||
handle_inactive_user(user)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def open_id_authenticate(openid_url)
|
def open_id_authenticate(openid_url)
|
||||||
back_url = signin_url(:autologin => params[:autologin])
|
back_url = signin_url(:autologin => params[:autologin])
|
||||||
authenticate_with_open_id(
|
|
||||||
openid_url, :required => [:nickname, :fullname, :email],
|
authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => back_url, :method => :post) do |result, identity_url, registration|
|
||||||
:return_to => back_url, :method => :post
|
|
||||||
) do |result, identity_url, registration|
|
|
||||||
if result.successful?
|
if result.successful?
|
||||||
user = User.find_or_initialize_by_identity_url(identity_url)
|
user = User.find_or_initialize_by_identity_url(identity_url)
|
||||||
if user.new_record?
|
if user.new_record?
|
||||||
# Self-registration off
|
# Self-registration off
|
||||||
(redirect_to(home_url); return) unless Setting.self_registration?
|
(redirect_to(home_url); return) unless Setting.self_registration?
|
||||||
|
|
||||||
# Create on the fly
|
# Create on the fly
|
||||||
user.login = registration['nickname'] unless registration['nickname'].nil?
|
user.login = registration['nickname'] unless registration['nickname'].nil?
|
||||||
user.mail = registration['email'] unless registration['email'].nil?
|
user.mail = registration['email'] unless registration['email'].nil?
|
||||||
user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?
|
user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?
|
||||||
user.random_password
|
user.random_password
|
||||||
user.register
|
user.register
|
||||||
|
|
||||||
case Setting.self_registration
|
case Setting.self_registration
|
||||||
when '1'
|
when '1'
|
||||||
register_by_email_activation(user) do
|
register_by_email_activation(user) do
|
||||||
@@ -232,7 +211,7 @@ class AccountController < ApplicationController
|
|||||||
if user.active?
|
if user.active?
|
||||||
successful_authentication(user)
|
successful_authentication(user)
|
||||||
else
|
else
|
||||||
handle_inactive_user(user)
|
account_pending
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -282,7 +261,7 @@ class AccountController < ApplicationController
|
|||||||
token = Token.new(:user => user, :action => "register")
|
token = Token.new(:user => user, :action => "register")
|
||||||
if user.save and token.save
|
if user.save and token.save
|
||||||
Mailer.register(token).deliver
|
Mailer.register(token).deliver
|
||||||
flash[:notice] = l(:notice_account_register_done, :email => user.mail)
|
flash[:notice] = l(:notice_account_register_done)
|
||||||
redirect_to signin_path
|
redirect_to signin_path
|
||||||
else
|
else
|
||||||
yield if block_given?
|
yield if block_given?
|
||||||
@@ -312,32 +291,14 @@ class AccountController < ApplicationController
|
|||||||
if user.save
|
if user.save
|
||||||
# Sends an email to the administrators
|
# Sends an email to the administrators
|
||||||
Mailer.account_activation_request(user).deliver
|
Mailer.account_activation_request(user).deliver
|
||||||
account_pending(user)
|
account_pending
|
||||||
else
|
else
|
||||||
yield if block_given?
|
yield if block_given?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_inactive_user(user, redirect_path=signin_path)
|
def account_pending
|
||||||
if user.registered?
|
flash[:notice] = l(:notice_account_pending)
|
||||||
account_pending(user, redirect_path)
|
redirect_to signin_path
|
||||||
else
|
|
||||||
account_locked(user, redirect_path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def account_pending(user, redirect_path=signin_path)
|
|
||||||
if Setting.self_registration == '1'
|
|
||||||
flash[:error] = l(:notice_account_not_activated_yet, :url => activation_email_path)
|
|
||||||
session[:registered_user_id] = user.id
|
|
||||||
else
|
|
||||||
flash[:error] = l(:notice_account_pending)
|
|
||||||
end
|
|
||||||
redirect_to redirect_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def account_locked(user, redirect_path=signin_path)
|
|
||||||
flash[:error] = l(:notice_account_locked)
|
|
||||||
redirect_to redirect_path
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class AdminController < ApplicationController
|
|||||||
@test = Mailer.test_email(User.current).deliver
|
@test = Mailer.test_email(User.current).deliver
|
||||||
flash[:notice] = l(:notice_email_sent, User.current.mail)
|
flash[:notice] = l(:notice_email_sent, User.current.mail)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
flash[:error] = l(:notice_email_error, Redmine::CodesetUtil.replace_invalid_utf8(e.message))
|
flash[:error] = l(:notice_email_error, e.message)
|
||||||
end
|
end
|
||||||
ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
|
ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
|
||||||
redirect_to settings_path(:tab => 'notifications')
|
redirect_to settings_path(:tab => 'notifications')
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class ApplicationController < ActionController::Base
|
|||||||
cookies.delete(autologin_cookie_name)
|
cookies.delete(autologin_cookie_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
before_filter :session_expiration, :user_setup, :check_if_login_required, :check_password_change, :set_localization
|
before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization
|
||||||
|
|
||||||
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
|
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
|
||||||
rescue_from ::Unauthorized, :with => :deny_access
|
rescue_from ::Unauthorized, :with => :deny_access
|
||||||
@@ -78,9 +78,6 @@ class ApplicationController < ActionController::Base
|
|||||||
session[:user_id] = user.id
|
session[:user_id] = user.id
|
||||||
session[:ctime] = Time.now.utc.to_i
|
session[:ctime] = Time.now.utc.to_i
|
||||||
session[:atime] = Time.now.utc.to_i
|
session[:atime] = Time.now.utc.to_i
|
||||||
if user.must_change_password?
|
|
||||||
session[:pwd] = '1'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_setup
|
def user_setup
|
||||||
@@ -115,10 +112,6 @@ class ApplicationController < ActionController::Base
|
|||||||
authenticate_with_http_basic do |username, password|
|
authenticate_with_http_basic do |username, password|
|
||||||
user = User.try_to_login(username, password) || User.find_by_api_key(username)
|
user = User.try_to_login(username, password) || User.find_by_api_key(username)
|
||||||
end
|
end
|
||||||
if user && user.must_change_password?
|
|
||||||
render_error :message => 'You must change your password', :status => 403
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
# Switch user if requested by an admin user
|
# Switch user if requested by an admin user
|
||||||
if user && user.admin? && (username = api_switch_user_from_request)
|
if user && user.admin? && (username = api_switch_user_from_request)
|
||||||
@@ -177,16 +170,6 @@ class ApplicationController < ActionController::Base
|
|||||||
require_login if Setting.login_required?
|
require_login if Setting.login_required?
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_password_change
|
|
||||||
if session[:pwd]
|
|
||||||
if User.current.must_change_password?
|
|
||||||
redirect_to my_password_path
|
|
||||||
else
|
|
||||||
session.delete(:pwd)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_localization
|
def set_localization
|
||||||
lang = nil
|
lang = nil
|
||||||
if User.current.logged?
|
if User.current.logged?
|
||||||
@@ -212,13 +195,7 @@ class ApplicationController < ActionController::Base
|
|||||||
url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
|
url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html { redirect_to :controller => "account", :action => "login", :back_url => url }
|
||||||
if request.xhr?
|
|
||||||
head :unauthorized
|
|
||||||
else
|
|
||||||
redirect_to :controller => "account", :action => "login", :back_url => url
|
|
||||||
end
|
|
||||||
}
|
|
||||||
format.atom { redirect_to :controller => "account", :action => "login", :back_url => url }
|
format.atom { redirect_to :controller => "account", :action => "login", :back_url => url }
|
||||||
format.xml { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
|
format.xml { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
|
||||||
format.js { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
|
format.js { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
|
||||||
@@ -321,7 +298,7 @@ class ApplicationController < ActionController::Base
|
|||||||
# Find issues with a single :id param or :ids array param
|
# Find issues with a single :id param or :ids array param
|
||||||
# Raises a Unauthorized exception if one of the issues is not visible
|
# Raises a Unauthorized exception if one of the issues is not visible
|
||||||
def find_issues
|
def find_issues
|
||||||
@issues = Issue.where(:id => (params[:id] || params[:ids])).preload(:project, :status, :tracker, :priority, :author, :assigned_to, :relations_to).to_a
|
@issues = Issue.find_all_by_id(params[:id] || params[:ids])
|
||||||
raise ActiveRecord::RecordNotFound if @issues.empty?
|
raise ActiveRecord::RecordNotFound if @issues.empty?
|
||||||
raise Unauthorized unless @issues.all?(&:visible?)
|
raise Unauthorized unless @issues.all?(&:visible?)
|
||||||
@projects = @issues.collect(&:project).compact.uniq
|
@projects = @issues.collect(&:project).compact.uniq
|
||||||
@@ -578,6 +555,21 @@ class ApplicationController < ActionController::Base
|
|||||||
flash[:warning] = l(:warning_attachments_not_saved, obj.unsaved_attachments.size) if obj.unsaved_attachments.present?
|
flash[:warning] = l(:warning_attachments_not_saved, obj.unsaved_attachments.size) if obj.unsaved_attachments.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Sets the `flash` notice or error based the number of issues that did not save
|
||||||
|
#
|
||||||
|
# @param [Array, Issue] issues all of the saved and unsaved Issues
|
||||||
|
# @param [Array, Integer] unsaved_issue_ids the issue ids that were not saved
|
||||||
|
def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
|
||||||
|
if unsaved_issue_ids.empty?
|
||||||
|
flash[:notice] = l(:notice_successful_update) unless issues.empty?
|
||||||
|
else
|
||||||
|
flash[:error] = l(:notice_failed_to_save_issues,
|
||||||
|
:count => unsaved_issue_ids.size,
|
||||||
|
:total => issues.size,
|
||||||
|
:ids => '#' + unsaved_issue_ids.join(', #'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Rescues an invalid query statement. Just in case...
|
# Rescues an invalid query statement. Just in case...
|
||||||
def query_statement_invalid(exception)
|
def query_statement_invalid(exception)
|
||||||
logger.error "Query::StatementInvalid: #{exception.message}" if logger
|
logger.error "Query::StatementInvalid: #{exception.message}" if logger
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class BoardsController < ApplicationController
|
|||||||
helper :watchers
|
helper :watchers
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@boards = @project.boards.includes(:project, :last_message => :author).all
|
@boards = @project.boards.includes(:last_message => :author).all
|
||||||
# show the board if there is only one
|
# show the board if there is only one
|
||||||
if @boards.size == 1
|
if @boards.size == 1
|
||||||
@board = @boards.first
|
@board = @boards.first
|
||||||
|
|||||||
@@ -19,15 +19,17 @@ class ContextMenusController < ApplicationController
|
|||||||
helper :watchers
|
helper :watchers
|
||||||
helper :issues
|
helper :issues
|
||||||
|
|
||||||
before_filter :find_issues, :only => :issues
|
|
||||||
|
|
||||||
def issues
|
def issues
|
||||||
|
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
|
||||||
|
(render_404; return) unless @issues.present?
|
||||||
if (@issues.size == 1)
|
if (@issues.size == 1)
|
||||||
@issue = @issues.first
|
@issue = @issues.first
|
||||||
end
|
end
|
||||||
@issue_ids = @issues.map(&:id).sort
|
@issue_ids = @issues.map(&:id).sort
|
||||||
|
|
||||||
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
||||||
|
@projects = @issues.collect(&:project).compact.uniq
|
||||||
|
@project = @projects.first if @projects.size == 1
|
||||||
|
|
||||||
@can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
|
@can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
|
||||||
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
||||||
@@ -71,7 +73,8 @@ class ContextMenusController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def time_entries
|
def time_entries
|
||||||
@time_entries = TimeEntry.where(:id => params[:ids]).preload(:project).to_a
|
@time_entries = TimeEntry.all(
|
||||||
|
:conditions => {:id => params[:ids]}, :include => :project)
|
||||||
(render_404; return) unless @time_entries.present?
|
(render_404; return) unless @time_entries.present?
|
||||||
|
|
||||||
@projects = @time_entries.collect(&:project).compact.uniq
|
@projects = @time_entries.collect(&:project).compact.uniq
|
||||||
|
|||||||
@@ -21,18 +21,10 @@ class CustomFieldsController < ApplicationController
|
|||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
before_filter :build_new_custom_field, :only => [:new, :create]
|
before_filter :build_new_custom_field, :only => [:new, :create]
|
||||||
before_filter :find_custom_field, :only => [:edit, :update, :destroy]
|
before_filter :find_custom_field, :only => [:edit, :update, :destroy]
|
||||||
accept_api_auth :index
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
respond_to do |format|
|
@custom_fields_by_type = CustomField.all.group_by {|f| f.class.name }
|
||||||
format.html {
|
@tab = params[:tab] || 'IssueCustomField'
|
||||||
@custom_fields_by_type = CustomField.all.group_by {|f| f.class.name }
|
|
||||||
@tab = params[:tab] || 'IssueCustomField'
|
|
||||||
}
|
|
||||||
format.api {
|
|
||||||
@custom_fields = CustomField.all
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class IssueStatusesController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@issue_status = IssueStatus.new(params[:issue_status])
|
@issue_status = IssueStatus.new(params[:issue_status])
|
||||||
if @issue_status.save
|
if request.post? && @issue_status.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to issue_statuses_path
|
redirect_to issue_statuses_path
|
||||||
else
|
else
|
||||||
@@ -54,7 +54,7 @@ class IssueStatusesController < ApplicationController
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
@issue_status = IssueStatus.find(params[:id])
|
@issue_status = IssueStatus.find(params[:id])
|
||||||
if @issue_status.update_attributes(params[:issue_status])
|
if request.put? && @issue_status.update_attributes(params[:issue_status])
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to issue_statuses_path
|
redirect_to issue_statuses_path
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -103,9 +103,6 @@ class IssuesController < ApplicationController
|
|||||||
@journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
|
@journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
|
||||||
@journals.each_with_index {|j,i| j.indice = i+1}
|
@journals.each_with_index {|j,i| j.indice = i+1}
|
||||||
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
|
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
|
||||||
Journal.preload_journals_details_custom_fields(@journals)
|
|
||||||
# TODO: use #select! when ruby1.8 support is dropped
|
|
||||||
@journals.reject! {|journal| !journal.notes? && journal.visible_details.empty?}
|
|
||||||
@journals.reverse! if User.current.wants_comments_in_reverse_order?
|
@journals.reverse! if User.current.wants_comments_in_reverse_order?
|
||||||
|
|
||||||
@changesets = @issue.changesets.visible.all
|
@changesets = @issue.changesets.visible.all
|
||||||
@@ -116,8 +113,6 @@ class IssuesController < ApplicationController
|
|||||||
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||||||
@priorities = IssuePriority.active
|
@priorities = IssuePriority.active
|
||||||
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
|
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
|
||||||
@relation = IssueRelation.new
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
retrieve_previous_and_next_issue_ids
|
retrieve_previous_and_next_issue_ids
|
||||||
@@ -181,7 +176,7 @@ class IssuesController < ApplicationController
|
|||||||
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
|
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
|
||||||
saved = false
|
saved = false
|
||||||
begin
|
begin
|
||||||
saved = save_issue_with_child_records
|
saved = @issue.save_issue_with_child_records(params, @time_entry)
|
||||||
rescue ActiveRecord::StaleObjectError
|
rescue ActiveRecord::StaleObjectError
|
||||||
@conflict = true
|
@conflict = true
|
||||||
if params[:last_journal_id]
|
if params[:last_journal_id]
|
||||||
@@ -233,7 +228,7 @@ class IssuesController < ApplicationController
|
|||||||
else
|
else
|
||||||
@available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
@available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
||||||
end
|
end
|
||||||
@custom_fields = target_projects.map{|p|p.all_issue_custom_fields.visible}.reduce(:&)
|
@custom_fields = target_projects.map{|p|p.all_issue_custom_fields}.reduce(:&)
|
||||||
@assignables = target_projects.map(&:assignable_users).reduce(:&)
|
@assignables = target_projects.map(&:assignable_users).reduce(:&)
|
||||||
@trackers = target_projects.map(&:trackers).reduce(:&)
|
@trackers = target_projects.map(&:trackers).reduce(:&)
|
||||||
@versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
|
@versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
|
||||||
@@ -244,9 +239,7 @@ class IssuesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
|
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
|
||||||
|
render :layout => false if request.xhr?
|
||||||
@issue_params = params[:issue] || {}
|
|
||||||
@issue_params[:custom_field_values] ||= {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def bulk_update
|
def bulk_update
|
||||||
@@ -254,8 +247,8 @@ class IssuesController < ApplicationController
|
|||||||
@copy = params[:copy].present?
|
@copy = params[:copy].present?
|
||||||
attributes = parse_params_for_bulk_issue_attributes(params)
|
attributes = parse_params_for_bulk_issue_attributes(params)
|
||||||
|
|
||||||
unsaved_issues = []
|
unsaved_issue_ids = []
|
||||||
saved_issues = []
|
moved_issues = []
|
||||||
|
|
||||||
if @copy && params[:copy_subtasks].present?
|
if @copy && params[:copy_subtasks].present?
|
||||||
# Descendant issues will be copied with the parent task
|
# Descendant issues will be copied with the parent task
|
||||||
@@ -263,48 +256,39 @@ class IssuesController < ApplicationController
|
|||||||
@issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
|
@issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
|
||||||
end
|
end
|
||||||
|
|
||||||
@issues.each do |orig_issue|
|
@issues.each do |issue|
|
||||||
orig_issue.reload
|
issue.reload
|
||||||
if @copy
|
if @copy
|
||||||
issue = orig_issue.copy({},
|
issue = issue.copy({},
|
||||||
:attachments => params[:copy_attachments].present?,
|
:attachments => params[:copy_attachments].present?,
|
||||||
:subtasks => params[:copy_subtasks].present?
|
:subtasks => params[:copy_subtasks].present?
|
||||||
)
|
)
|
||||||
else
|
|
||||||
issue = orig_issue
|
|
||||||
end
|
end
|
||||||
journal = issue.init_journal(User.current, params[:notes])
|
journal = issue.init_journal(User.current, params[:notes])
|
||||||
issue.safe_attributes = attributes
|
issue.safe_attributes = attributes
|
||||||
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
|
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
|
||||||
if issue.save
|
if issue.save
|
||||||
saved_issues << issue
|
moved_issues << issue
|
||||||
else
|
else
|
||||||
unsaved_issues << orig_issue
|
# Keep unsaved issue ids to display them in flash error
|
||||||
|
unsaved_issue_ids << issue.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
|
||||||
|
|
||||||
if unsaved_issues.empty?
|
if params[:follow]
|
||||||
flash[:notice] = l(:notice_successful_update) unless saved_issues.empty?
|
if @issues.size == 1 && moved_issues.size == 1
|
||||||
if params[:follow]
|
redirect_to issue_path(moved_issues.first)
|
||||||
if @issues.size == 1 && saved_issues.size == 1
|
elsif moved_issues.map(&:project).uniq.size == 1
|
||||||
redirect_to issue_path(saved_issues.first)
|
redirect_to project_issues_path(moved_issues.map(&:project).first)
|
||||||
elsif saved_issues.map(&:project).uniq.size == 1
|
|
||||||
redirect_to project_issues_path(saved_issues.map(&:project).first)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
redirect_back_or_default _project_issues_path(@project)
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@saved_issues = @issues
|
redirect_back_or_default _project_issues_path(@project)
|
||||||
@unsaved_issues = unsaved_issues
|
|
||||||
@issues = Issue.visible.find_all_by_id(@unsaved_issues.map(&:id))
|
|
||||||
bulk_edit
|
|
||||||
render :action => 'bulk_edit'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f
|
@hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
|
||||||
if @hours > 0
|
if @hours > 0
|
||||||
case params[:todo]
|
case params[:todo]
|
||||||
when 'destroy'
|
when 'destroy'
|
||||||
@@ -452,26 +436,4 @@ class IssuesController < ApplicationController
|
|||||||
end
|
end
|
||||||
attributes
|
attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
# Saves @issue and a time_entry from the parameters
|
|
||||||
def save_issue_with_child_records
|
|
||||||
Issue.transaction do
|
|
||||||
if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, @issue.project)
|
|
||||||
time_entry = @time_entry || TimeEntry.new
|
|
||||||
time_entry.project = @issue.project
|
|
||||||
time_entry.issue = @issue
|
|
||||||
time_entry.user = User.current
|
|
||||||
time_entry.spent_on = User.current.today
|
|
||||||
time_entry.attributes = params[:time_entry]
|
|
||||||
@issue.time_entries << time_entry
|
|
||||||
end
|
|
||||||
|
|
||||||
call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
|
|
||||||
if @issue.save
|
|
||||||
call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => time_entry, :journal => @issue.current_journal})
|
|
||||||
else
|
|
||||||
raise ActiveRecord::Rollback
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class MessagesController < ApplicationController
|
|||||||
page = params[:page]
|
page = params[:page]
|
||||||
# Find the page of the requested reply
|
# Find the page of the requested reply
|
||||||
if params[:r] && page.nil?
|
if params[:r] && page.nil?
|
||||||
offset = @topic.children.where("#{Message.table_name}.id < ?", params[:r].to_i).count
|
offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i])
|
||||||
page = 1 + offset / REPLIES_PER_PAGE
|
page = 1 + offset / REPLIES_PER_PAGE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
class MyController < ApplicationController
|
class MyController < ApplicationController
|
||||||
before_filter :require_login
|
before_filter :require_login
|
||||||
# let user change user's password when user has to
|
|
||||||
skip_before_filter :check_password_change, :only => :password
|
|
||||||
|
|
||||||
helper :issues
|
helper :issues
|
||||||
helper :users
|
helper :users
|
||||||
@@ -57,6 +55,7 @@ class MyController < ApplicationController
|
|||||||
@user.pref.attributes = params[:pref]
|
@user.pref.attributes = params[:pref]
|
||||||
if @user.save
|
if @user.save
|
||||||
@user.pref.save
|
@user.pref.save
|
||||||
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||||
set_language_if_valid @user.language
|
set_language_if_valid @user.language
|
||||||
flash[:notice] = l(:notice_account_updated)
|
flash[:notice] = l(:notice_account_updated)
|
||||||
redirect_to my_account_path
|
redirect_to my_account_path
|
||||||
@@ -92,17 +91,14 @@ class MyController < ApplicationController
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if request.post?
|
if request.post?
|
||||||
if !@user.check_password?(params[:password])
|
if @user.check_password?(params[:password])
|
||||||
flash.now[:error] = l(:notice_account_wrong_password)
|
|
||||||
elsif params[:password] == params[:new_password]
|
|
||||||
flash.now[:error] = l(:notice_new_password_must_be_different)
|
|
||||||
else
|
|
||||||
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
||||||
@user.must_change_passwd = false
|
|
||||||
if @user.save
|
if @user.save
|
||||||
flash[:notice] = l(:notice_account_password_updated)
|
flash[:notice] = l(:notice_account_password_updated)
|
||||||
redirect_to my_account_path
|
redirect_to my_account_path
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
flash[:error] = l(:notice_account_wrong_password)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class ProjectsController < ApplicationController
|
|||||||
|
|
||||||
if validate_parent_id && @project.save
|
if validate_parent_id && @project.save
|
||||||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
||||||
# Add current user as a project member if current user is not admin
|
# Add current user as a project member if he is not admin
|
||||||
unless User.current.admin?
|
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(:user => User.current, :roles => [r])
|
m = Member.new(:user => User.current, :roles => [r])
|
||||||
@@ -155,7 +155,7 @@ class ProjectsController < ApplicationController
|
|||||||
@total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker)
|
@total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker)
|
||||||
|
|
||||||
if User.current.allowed_to?(:view_time_entries, @project)
|
if User.current.allowed_to?(:view_time_entries, @project)
|
||||||
@total_hours = TimeEntry.visible.where(cond).sum(:hours).to_f
|
@total_hours = TimeEntry.visible.sum(:hours, :include => :project, :conditions => cond).to_f
|
||||||
end
|
end
|
||||||
|
|
||||||
@key = User.current.rss_key
|
@key = User.current.rss_key
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class QueriesController < ApplicationController
|
|||||||
@query = IssueQuery.new
|
@query = IssueQuery.new
|
||||||
@query.user = User.current
|
@query.user = User.current
|
||||||
@query.project = @project
|
@query.project = @project
|
||||||
@query.visibility = IssueQuery::VISIBILITY_PRIVATE unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
||||||
@query.build_from_params(params)
|
@query.build_from_params(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -53,13 +53,13 @@ class QueriesController < ApplicationController
|
|||||||
@query = IssueQuery.new(params[:query])
|
@query = IssueQuery.new(params[:query])
|
||||||
@query.user = User.current
|
@query.user = User.current
|
||||||
@query.project = params[:query_is_for_all] ? nil : @project
|
@query.project = params[:query_is_for_all] ? nil : @project
|
||||||
@query.visibility = IssueQuery::VISIBILITY_PRIVATE unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
||||||
@query.build_from_params(params)
|
@query.build_from_params(params)
|
||||||
@query.column_names = nil if params[:default_columns]
|
@query.column_names = nil if params[:default_columns]
|
||||||
|
|
||||||
if @query.save
|
if @query.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to_issues(:query_id => @query)
|
redirect_to _project_issues_path(@project, :query_id => @query)
|
||||||
else
|
else
|
||||||
render :action => 'new', :layout => !request.xhr?
|
render :action => 'new', :layout => !request.xhr?
|
||||||
end
|
end
|
||||||
@@ -71,13 +71,13 @@ class QueriesController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
@query.attributes = params[:query]
|
@query.attributes = params[:query]
|
||||||
@query.project = nil if params[:query_is_for_all]
|
@query.project = nil if params[:query_is_for_all]
|
||||||
@query.visibility = IssueQuery::VISIBILITY_PRIVATE unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
@query.is_public = false unless User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
|
||||||
@query.build_from_params(params)
|
@query.build_from_params(params)
|
||||||
@query.column_names = nil if params[:default_columns]
|
@query.column_names = nil if params[:default_columns]
|
||||||
|
|
||||||
if @query.save
|
if @query.save
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to_issues(:query_id => @query)
|
redirect_to _project_issues_path(@project, :query_id => @query)
|
||||||
else
|
else
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
@@ -85,7 +85,7 @@ class QueriesController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@query.destroy
|
@query.destroy
|
||||||
redirect_to_issues(:set_filter => 1)
|
redirect_to _project_issues_path(@project, :set_filter => 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -103,16 +103,4 @@ private
|
|||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_to_issues(options)
|
|
||||||
if params[:gantt]
|
|
||||||
if @project
|
|
||||||
redirect_to project_gantt_path(@project, options)
|
|
||||||
else
|
|
||||||
redirect_to issues_gantt_path(options)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
redirect_to _project_issues_path(@project, options)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class RepositoriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@repository.fetch_changesets if @project.active? && Setting.autofetch_changesets? && @path.empty?
|
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
|
||||||
|
|
||||||
@entries = @repository.entries(@path, @rev)
|
@entries = @repository.entries(@path, @rev)
|
||||||
@changeset = @repository.find_changeset_by_name(@rev)
|
@changeset = @repository.find_changeset_by_name(@rev)
|
||||||
@@ -352,18 +352,15 @@ class RepositoriesController < ApplicationController
|
|||||||
@date_to = Date.today
|
@date_to = Date.today
|
||||||
@date_from = @date_to << 11
|
@date_from = @date_to << 11
|
||||||
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
|
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
|
||||||
commits_by_day = Changeset.
|
commits_by_day = Changeset.count(
|
||||||
where("repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to).
|
:all, :group => :commit_date,
|
||||||
group(:commit_date).
|
:conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
||||||
count
|
|
||||||
commits_by_month = [0] * 12
|
commits_by_month = [0] * 12
|
||||||
commits_by_day.each {|c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
|
commits_by_day.each {|c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
|
||||||
|
|
||||||
changes_by_day = Change.
|
changes_by_day = Change.count(
|
||||||
joins(:changeset).
|
:all, :group => :commit_date, :include => :changeset,
|
||||||
where("#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to).
|
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
||||||
group(:commit_date).
|
|
||||||
count
|
|
||||||
changes_by_month = [0] * 12
|
changes_by_month = [0] * 12
|
||||||
changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
|
changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
|
||||||
|
|
||||||
@@ -396,10 +393,10 @@ class RepositoriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def graph_commits_per_author(repository)
|
def graph_commits_per_author(repository)
|
||||||
commits_by_author = Changeset.where("repository_id = ?", repository.id).group(:committer).count
|
commits_by_author = Changeset.count(:all, :group => :committer, :conditions => ["repository_id = ?", repository.id])
|
||||||
commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}
|
commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}
|
||||||
|
|
||||||
changes_by_author = Change.joins(:changeset).where("#{Changeset.table_name}.repository_id = ?", repository.id).group(:committer).count
|
changes_by_author = Change.count(:all, :group => :committer, :include => :changeset, :conditions => ["#{Changeset.table_name}.repository_id = ?", repository.id])
|
||||||
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
||||||
|
|
||||||
fields = commits_by_author.collect {|r| r.first}
|
fields = commits_by_author.collect {|r| r.first}
|
||||||
@@ -414,7 +411,7 @@ class RepositoriesController < ApplicationController
|
|||||||
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||||||
|
|
||||||
graph = SVG::Graph::BarHorizontal.new(
|
graph = SVG::Graph::BarHorizontal.new(
|
||||||
:height => 30 * commits_data.length,
|
:height => 400,
|
||||||
:width => 800,
|
:width => 800,
|
||||||
:fields => fields,
|
:fields => fields,
|
||||||
:stack => :side,
|
:stack => :side,
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ class SettingsController < ApplicationController
|
|||||||
if request.post? && params[:settings] && params[:settings].is_a?(Hash)
|
if request.post? && params[:settings] && params[:settings].is_a?(Hash)
|
||||||
settings = (params[:settings] || {}).dup.symbolize_keys
|
settings = (params[:settings] || {}).dup.symbolize_keys
|
||||||
settings.each do |name, value|
|
settings.each do |name, value|
|
||||||
Setting.set_from_params name, value
|
# remove blank values in array settings
|
||||||
|
value.delete_if {|v| v.blank? } if value.is_a?(Array)
|
||||||
|
Setting[name] = value
|
||||||
end
|
end
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to settings_path(:tab => params[:tab])
|
redirect_to settings_path(:tab => params[:tab])
|
||||||
@@ -46,9 +48,6 @@ class SettingsController < ApplicationController
|
|||||||
@guessed_host_and_path = request.host_with_port.dup
|
@guessed_host_and_path = request.host_with_port.dup
|
||||||
@guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
|
@guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
|
||||||
|
|
||||||
@commit_update_keywords = Setting.commit_update_keywords.dup
|
|
||||||
@commit_update_keywords = [{}] unless @commit_update_keywords.is_a?(Array) && @commit_update_keywords.any?
|
|
||||||
|
|
||||||
Redmine::Themes.rescan
|
Redmine::Themes.rescan
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ class SysController < ActionController::Base
|
|||||||
before_filter :check_enabled
|
before_filter :check_enabled
|
||||||
|
|
||||||
def projects
|
def projects
|
||||||
p = Project.active.has_module(:repository).order("#{Project.table_name}.identifier").preload(:repository).all
|
p = Project.active.has_module(:repository).find(
|
||||||
|
:all,
|
||||||
|
:include => :repository,
|
||||||
|
:order => "#{Project.table_name}.identifier"
|
||||||
|
)
|
||||||
# extra_info attribute from repository breaks activeresource client
|
# extra_info attribute from repository breaks activeresource client
|
||||||
render :xml => p.to_xml(
|
render :xml => p.to_xml(
|
||||||
:only => [:id, :identifier, :name, :is_public, :status],
|
:only => [:id, :identifier, :name, :is_public, :status],
|
||||||
|
|||||||
@@ -46,15 +46,18 @@ class TimelogController < ApplicationController
|
|||||||
|
|
||||||
sort_init(@query.sort_criteria.empty? ? [['spent_on', 'desc']] : @query.sort_criteria)
|
sort_init(@query.sort_criteria.empty? ? [['spent_on', 'desc']] : @query.sort_criteria)
|
||||||
sort_update(@query.sortable_columns)
|
sort_update(@query.sortable_columns)
|
||||||
scope = time_entry_scope(:order => sort_clause).
|
scope = time_entry_scope(:order => sort_clause)
|
||||||
includes(:project, :activity, :user, :issue).
|
|
||||||
preload(:issue => [:project, :tracker, :status, :assigned_to, :priority])
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
|
# Paginate results
|
||||||
@entry_count = scope.count
|
@entry_count = scope.count
|
||||||
@entry_pages = Paginator.new @entry_count, per_page_option, params['page']
|
@entry_pages = Paginator.new @entry_count, per_page_option, params['page']
|
||||||
@entries = scope.offset(@entry_pages.offset).limit(@entry_pages.per_page).all
|
@entries = scope.all(
|
||||||
|
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||||
|
:limit => @entry_pages.per_page,
|
||||||
|
:offset => @entry_pages.offset
|
||||||
|
)
|
||||||
@total_hours = scope.sum(:hours).to_f
|
@total_hours = scope.sum(:hours).to_f
|
||||||
|
|
||||||
render :layout => !request.xhr?
|
render :layout => !request.xhr?
|
||||||
@@ -62,15 +65,24 @@ class TimelogController < ApplicationController
|
|||||||
format.api {
|
format.api {
|
||||||
@entry_count = scope.count
|
@entry_count = scope.count
|
||||||
@offset, @limit = api_offset_and_limit
|
@offset, @limit = api_offset_and_limit
|
||||||
@entries = scope.offset(@offset).limit(@limit).preload(:custom_values => :custom_field).all
|
@entries = scope.all(
|
||||||
|
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||||
|
:limit => @limit,
|
||||||
|
:offset => @offset
|
||||||
|
)
|
||||||
}
|
}
|
||||||
format.atom {
|
format.atom {
|
||||||
entries = scope.limit(Setting.feeds_limit.to_i).reorder("#{TimeEntry.table_name}.created_on DESC").all
|
entries = scope.reorder("#{TimeEntry.table_name}.created_on DESC").all(
|
||||||
|
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||||
|
:limit => Setting.feeds_limit.to_i
|
||||||
|
)
|
||||||
render_feed(entries, :title => l(:label_spent_time))
|
render_feed(entries, :title => l(:label_spent_time))
|
||||||
}
|
}
|
||||||
format.csv {
|
format.csv {
|
||||||
# Export all entries
|
# Export all entries
|
||||||
@entries = scope.all
|
@entries = scope.all(
|
||||||
|
:include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}]
|
||||||
|
)
|
||||||
send_data(query_to_csv(@entries, @query, params), :type => 'text/csv; header=present', :filename => 'timelog.csv')
|
send_data(query_to_csv(@entries, @query, params), :type => 'text/csv; header=present', :filename => 'timelog.csv')
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@@ -182,7 +194,6 @@ class TimelogController < ApplicationController
|
|||||||
time_entry.safe_attributes = attributes
|
time_entry.safe_attributes = attributes
|
||||||
call_hook(:controller_time_entries_bulk_edit_before_save, { :params => params, :time_entry => time_entry })
|
call_hook(:controller_time_entries_bulk_edit_before_save, { :params => params, :time_entry => time_entry })
|
||||||
unless time_entry.save
|
unless time_entry.save
|
||||||
logger.info "time entry could not be updated: #{time_entry.errors.full_messages}" if logger && logger.info
|
|
||||||
# Keep unsaved time_entry ids to display them in flash error
|
# Keep unsaved time_entry ids to display them in flash error
|
||||||
unsaved_time_entry_ids << time_entry.id
|
unsaved_time_entry_ids << time_entry.id
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class UsersController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
# show projects based on current user visibility
|
# show projects based on current user visibility
|
||||||
@memberships = @user.memberships.where(Project.visible_condition(User.current)).all
|
@memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||||
|
|
||||||
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
|
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
|
||||||
@events_by_day = events.group_by(&:event_date)
|
@events_by_day = events.group_by(&:event_date)
|
||||||
@@ -80,7 +80,6 @@ class UsersController < ApplicationController
|
|||||||
|
|
||||||
def new
|
def new
|
||||||
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
||||||
@user.safe_attributes = params[:user]
|
|
||||||
@auth_sources = AuthSource.all
|
@auth_sources = AuthSource.all
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -94,15 +93,15 @@ class UsersController < ApplicationController
|
|||||||
if @user.save
|
if @user.save
|
||||||
@user.pref.attributes = params[:pref]
|
@user.pref.attributes = params[:pref]
|
||||||
@user.pref.save
|
@user.pref.save
|
||||||
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||||
|
|
||||||
Mailer.account_information(@user, @user.password).deliver if params[:send_information]
|
Mailer.account_information(@user, params[:user][:password]).deliver if params[:send_information]
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
flash[:notice] = l(:notice_user_successful_create, :id => view_context.link_to(@user.login, user_path(@user)))
|
flash[:notice] = l(:notice_user_successful_create, :id => view_context.link_to(@user.login, user_path(@user)))
|
||||||
if params[:continue]
|
if params[:continue]
|
||||||
attrs = params[:user].slice(:generate_password)
|
redirect_to new_user_path
|
||||||
redirect_to new_user_path(:user => attrs)
|
|
||||||
else
|
else
|
||||||
redirect_to edit_user_path(@user)
|
redirect_to edit_user_path(@user)
|
||||||
end
|
end
|
||||||
@@ -140,11 +139,12 @@ class UsersController < ApplicationController
|
|||||||
|
|
||||||
if @user.save
|
if @user.save
|
||||||
@user.pref.save
|
@user.pref.save
|
||||||
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||||
|
|
||||||
if was_activated
|
if was_activated
|
||||||
Mailer.account_activated(@user).deliver
|
Mailer.account_activated(@user).deliver
|
||||||
elsif @user.active? && params[:send_information] && @user.password.present? && @user.auth_source_id.nil?
|
elsif @user.active? && params[:send_information] && !params[:user][:password].blank? && @user.auth_source_id.nil?
|
||||||
Mailer.account_information(@user, @user.password).deliver
|
Mailer.account_information(@user, params[:user][:password]).deliver
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|||||||
@@ -46,11 +46,11 @@ class VersionsController < ApplicationController
|
|||||||
|
|
||||||
@issues_by_version = {}
|
@issues_by_version = {}
|
||||||
if @selected_tracker_ids.any? && @versions.any?
|
if @selected_tracker_ids.any? && @versions.any?
|
||||||
issues = Issue.visible.
|
issues = Issue.visible.all(
|
||||||
includes(:project, :tracker).
|
:include => [:project, :status, :tracker, :priority, :fixed_version],
|
||||||
preload(:status, :priority, :fixed_version).
|
:conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids, :fixed_version_id => @versions.map(&:id)},
|
||||||
where(:tracker_id => @selected_tracker_ids, :project_id => project_ids, :fixed_version_id => @versions.map(&:id)).
|
:order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id"
|
||||||
order("#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id")
|
)
|
||||||
@issues_by_version = issues.group_by(&:fixed_version)
|
@issues_by_version = issues.group_by(&:fixed_version)
|
||||||
end
|
end
|
||||||
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
|
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
require 'diff'
|
||||||
|
|
||||||
# The WikiController follows the Rails REST controller pattern but with
|
# The WikiController follows the Rails REST controller pattern but with
|
||||||
# a few differences
|
# a few differences
|
||||||
#
|
#
|
||||||
@@ -62,12 +64,7 @@ class WikiController < ApplicationController
|
|||||||
|
|
||||||
# display a page (in editing mode if it doesn't exist)
|
# display a page (in editing mode if it doesn't exist)
|
||||||
def show
|
def show
|
||||||
if params[:version] && !User.current.allowed_to?(:view_wiki_edits, @project)
|
if @page.new_record?
|
||||||
deny_access
|
|
||||||
return
|
|
||||||
end
|
|
||||||
@content = @page.content_for_version(params[:version])
|
|
||||||
if @content.nil?
|
|
||||||
if User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request?
|
if User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request?
|
||||||
edit
|
edit
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
@@ -76,6 +73,11 @@ class WikiController < ApplicationController
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if params[:version] && !User.current.allowed_to?(:view_wiki_edits, @project)
|
||||||
|
deny_access
|
||||||
|
return
|
||||||
|
end
|
||||||
|
@content = @page.content_for_version(params[:version])
|
||||||
if User.current.allowed_to?(:export_wiki_pages, @project)
|
if User.current.allowed_to?(:export_wiki_pages, @project)
|
||||||
if params[:format] == 'pdf'
|
if params[:format] == 'pdf'
|
||||||
send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf")
|
send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf")
|
||||||
@@ -104,19 +106,19 @@ class WikiController < ApplicationController
|
|||||||
def edit
|
def edit
|
||||||
return render_403 unless editable?
|
return render_403 unless editable?
|
||||||
if @page.new_record?
|
if @page.new_record?
|
||||||
|
@page.content = WikiContent.new(:page => @page)
|
||||||
if params[:parent].present?
|
if params[:parent].present?
|
||||||
@page.parent = @page.wiki.find_page(params[:parent].to_s)
|
@page.parent = @page.wiki.find_page(params[:parent].to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@content = @page.content_for_version(params[:version])
|
@content = @page.content_for_version(params[:version])
|
||||||
@content ||= WikiContent.new(:page => @page)
|
|
||||||
@content.text = initial_page_content(@page) if @content.text.blank?
|
@content.text = initial_page_content(@page) if @content.text.blank?
|
||||||
# don't keep previous comment
|
# don't keep previous comment
|
||||||
@content.comments = nil
|
@content.comments = nil
|
||||||
|
|
||||||
# To prevent StaleObjectError exception when reverting to a previous version
|
# To prevent StaleObjectError exception when reverting to a previous version
|
||||||
@content.version = @page.content.version if @page.content
|
@content.version = @page.content.version
|
||||||
|
|
||||||
@text = @content.text
|
@text = @content.text
|
||||||
if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
|
if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
|
||||||
@@ -130,9 +132,10 @@ class WikiController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
return render_403 unless editable?
|
return render_403 unless editable?
|
||||||
was_new_page = @page.new_record?
|
was_new_page = @page.new_record?
|
||||||
|
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||||
@page.safe_attributes = params[:wiki_page]
|
@page.safe_attributes = params[:wiki_page]
|
||||||
|
|
||||||
@content = @page.content || WikiContent.new(:page => @page)
|
@content = @page.content
|
||||||
content_params = params[:content]
|
content_params = params[:content]
|
||||||
if content_params.nil? && params[:wiki_page].is_a?(Hash)
|
if content_params.nil? && params[:wiki_page].is_a?(Hash)
|
||||||
content_params = params[:wiki_page].slice(:text, :comments, :version)
|
content_params = params[:wiki_page].slice(:text, :comments, :version)
|
||||||
@@ -144,23 +147,20 @@ class WikiController < ApplicationController
|
|||||||
if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
|
if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
|
||||||
@section = params[:section].to_i
|
@section = params[:section].to_i
|
||||||
@section_hash = params[:section_hash]
|
@section_hash = params[:section_hash]
|
||||||
@content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(@section, @text, @section_hash)
|
@content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(params[:section].to_i, @text, @section_hash)
|
||||||
else
|
else
|
||||||
@content.version = content_params[:version] if content_params[:version]
|
@content.version = content_params[:version] if content_params[:version]
|
||||||
@content.text = @text
|
@content.text = @text
|
||||||
end
|
end
|
||||||
@content.author = User.current
|
@content.author = User.current
|
||||||
|
|
||||||
if @page.save_with_content(@content)
|
if @page.save_with_content
|
||||||
attachments = Attachment.attach_files(@page, params[:attachments])
|
attachments = Attachment.attach_files(@page, params[:attachments])
|
||||||
render_attachment_warning_if_needed(@page)
|
render_attachment_warning_if_needed(@page)
|
||||||
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
|
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html { redirect_to project_wiki_page_path(@project, @page.title) }
|
||||||
anchor = @section ? "section-#{@section}" : nil
|
|
||||||
redirect_to project_wiki_page_path(@project, @page.title, :anchor => anchor)
|
|
||||||
}
|
|
||||||
format.api {
|
format.api {
|
||||||
if was_new_page
|
if was_new_page
|
||||||
render :action => 'show', :status => :created, :location => project_wiki_page_path(@project, @page.title)
|
render :action => 'show', :status => :created, :location => project_wiki_page_path(@project, @page.title)
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
groups = ''
|
groups = ''
|
||||||
collection.sort.each do |element|
|
collection.sort.each do |element|
|
||||||
selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id.to_s == selected
|
selected_attribute = ' selected="selected"' if option_value_selected?(element, selected)
|
||||||
(element.is_a?(Group) ? groups : s) << %(<option value="#{element.id}"#{selected_attribute}>#{h element.name}</option>)
|
(element.is_a?(Group) ? groups : s) << %(<option value="#{element.id}"#{selected_attribute}>#{h element.name}</option>)
|
||||||
end
|
end
|
||||||
unless groups.empty?
|
unless groups.empty?
|
||||||
@@ -348,10 +348,6 @@ module ApplicationHelper
|
|||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
def option_tag(name, text, value, selected=nil, options={})
|
|
||||||
content_tag 'option', value, options.merge(:value => value, :selected => (value == selected))
|
|
||||||
end
|
|
||||||
|
|
||||||
# Truncates and returns the string as a single line
|
# Truncates and returns the string as a single line
|
||||||
def truncate_single_line(string, *args)
|
def truncate_single_line(string, *args)
|
||||||
truncate(string.to_s, *args).gsub(%r{[\r\n]+}m, ' ')
|
truncate(string.to_s, *args).gsub(%r{[\r\n]+}m, ' ')
|
||||||
@@ -384,7 +380,7 @@ module ApplicationHelper
|
|||||||
if @project
|
if @project
|
||||||
link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => User.current.time_to_date(time)}, :title => format_time(time))
|
link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => User.current.time_to_date(time)}, :title => format_time(time))
|
||||||
else
|
else
|
||||||
content_tag('abbr', text, :title => format_time(time))
|
content_tag('acronym', text, :title => format_time(time))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -449,31 +445,12 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a h2 tag and sets the html title with the given arguments
|
|
||||||
def title(*args)
|
|
||||||
strings = args.map do |arg|
|
|
||||||
if arg.is_a?(Array) && arg.size >= 2
|
|
||||||
link_to(*arg)
|
|
||||||
else
|
|
||||||
h(arg.to_s)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
html_title args.reverse.map {|s| (s.is_a?(Array) ? s.first : s).to_s}
|
|
||||||
content_tag('h2', strings.join(' » ').html_safe)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Sets the html title
|
|
||||||
# Returns the html title when called without arguments
|
|
||||||
# Current project name and app_title and automatically appended
|
|
||||||
# Exemples:
|
|
||||||
# html_title 'Foo', 'Bar'
|
|
||||||
# html_title # => 'Foo - Bar - My Project - Redmine'
|
|
||||||
def html_title(*args)
|
def html_title(*args)
|
||||||
if args.empty?
|
if args.empty?
|
||||||
title = @html_title || []
|
title = @html_title || []
|
||||||
title << @project.name if @project
|
title << @project.name if @project
|
||||||
title << Setting.app_title unless Setting.app_title == title.last
|
title << Setting.app_title unless Setting.app_title == title.last
|
||||||
title.reject(&:blank?).join(' - ')
|
title.select {|t| !t.blank? }.join(' - ')
|
||||||
else
|
else
|
||||||
@html_title ||= []
|
@html_title ||= []
|
||||||
@html_title += args
|
@html_title += args
|
||||||
@@ -488,7 +465,6 @@ module ApplicationHelper
|
|||||||
css << 'theme-' + theme.name
|
css << 'theme-' + theme.name
|
||||||
end
|
end
|
||||||
|
|
||||||
css << 'project-' + @project.identifier if @project && @project.identifier.present?
|
|
||||||
css << 'controller-' + controller_name
|
css << 'controller-' + controller_name
|
||||||
css << 'action-' + action_name
|
css << 'action-' + action_name
|
||||||
css.join(' ')
|
css.join(' ')
|
||||||
@@ -680,9 +656,6 @@ module ApplicationHelper
|
|||||||
# export:some/file -> Force the download of the file
|
# export:some/file -> Force the download of the file
|
||||||
# Forum messages:
|
# Forum messages:
|
||||||
# message#1218 -> Link to message with id 1218
|
# message#1218 -> Link to message with id 1218
|
||||||
# Projects:
|
|
||||||
# project:someproject -> Link to project named "someproject"
|
|
||||||
# project#3 -> Link to project with id 3
|
|
||||||
#
|
#
|
||||||
# Links can refer other objects from other projects, using project identifier:
|
# Links can refer other objects from other projects, using project identifier:
|
||||||
# identifier:r52
|
# identifier:r52
|
||||||
@@ -719,7 +692,7 @@ module ApplicationHelper
|
|||||||
when nil
|
when nil
|
||||||
if oid.to_s == identifier && issue = Issue.visible.find_by_id(oid, :include => :status)
|
if oid.to_s == identifier && issue = Issue.visible.find_by_id(oid, :include => :status)
|
||||||
anchor = comment_id ? "note-#{comment_id}" : nil
|
anchor = comment_id ? "note-#{comment_id}" : nil
|
||||||
link = link_to(h("##{oid}#{comment_suffix}"), {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
|
link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
|
||||||
:class => issue.css_classes,
|
:class => issue.css_classes,
|
||||||
:title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
|
:title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
|
||||||
end
|
end
|
||||||
@@ -831,8 +804,7 @@ module ApplicationHelper
|
|||||||
content_tag('div',
|
content_tag('div',
|
||||||
link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => @current_section)),
|
link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => @current_section)),
|
||||||
:class => 'contextual',
|
:class => 'contextual',
|
||||||
:title => l(:button_edit_section),
|
:title => l(:button_edit_section)) + heading.html_safe
|
||||||
:id => "section-#{@current_section}") + heading.html_safe
|
|
||||||
else
|
else
|
||||||
heading
|
heading
|
||||||
end
|
end
|
||||||
@@ -1063,7 +1035,7 @@ module ApplicationHelper
|
|||||||
(pcts[0] > 0 ? content_tag('td', '', :style => "width: #{pcts[0]}%;", :class => 'closed') : ''.html_safe) +
|
(pcts[0] > 0 ? content_tag('td', '', :style => "width: #{pcts[0]}%;", :class => 'closed') : ''.html_safe) +
|
||||||
(pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done') : ''.html_safe) +
|
(pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done') : ''.html_safe) +
|
||||||
(pcts[2] > 0 ? content_tag('td', '', :style => "width: #{pcts[2]}%;", :class => 'todo') : ''.html_safe)
|
(pcts[2] > 0 ? content_tag('td', '', :style => "width: #{pcts[2]}%;", :class => 'todo') : ''.html_safe)
|
||||||
), :class => 'progress progress-#{pcts[0]}', :style => "width: #{width};").html_safe +
|
), :class => 'progress', :style => "width: #{width};").html_safe +
|
||||||
content_tag('p', legend, :class => 'percent').html_safe
|
content_tag('p', legend, :class => 'percent').html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1096,7 +1068,6 @@ module ApplicationHelper
|
|||||||
|
|
||||||
def include_calendar_headers_tags
|
def include_calendar_headers_tags
|
||||||
unless @calendar_headers_tags_included
|
unless @calendar_headers_tags_included
|
||||||
tags = javascript_include_tag("datepicker")
|
|
||||||
@calendar_headers_tags_included = true
|
@calendar_headers_tags_included = true
|
||||||
content_for :header_tags do
|
content_for :header_tags do
|
||||||
start_of_week = Setting.start_of_week
|
start_of_week = Setting.start_of_week
|
||||||
@@ -1104,13 +1075,12 @@ module ApplicationHelper
|
|||||||
# Redmine uses 1..7 (monday..sunday) in settings and locales
|
# Redmine uses 1..7 (monday..sunday) in settings and locales
|
||||||
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
|
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
|
||||||
start_of_week = start_of_week.to_i % 7
|
start_of_week = start_of_week.to_i % 7
|
||||||
tags << javascript_tag(
|
|
||||||
|
tags = javascript_tag(
|
||||||
"var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
|
"var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
|
||||||
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
|
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
|
||||||
path_to_image('/images/calendar.png') +
|
path_to_image('/images/calendar.png') +
|
||||||
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, " +
|
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};")
|
||||||
"selectOtherMonths: true, changeMonth: true, changeYear: true, " +
|
|
||||||
"beforeShow: beforeShowDatePicker};")
|
|
||||||
jquery_locale = l('jquery.locale', :default => current_language.to_s)
|
jquery_locale = l('jquery.locale', :default => current_language.to_s)
|
||||||
unless jquery_locale == 'en'
|
unless jquery_locale == 'en'
|
||||||
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
|
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
|
||||||
|
|||||||
@@ -19,29 +19,8 @@
|
|||||||
|
|
||||||
module CustomFieldsHelper
|
module CustomFieldsHelper
|
||||||
|
|
||||||
CUSTOM_FIELDS_TABS = [
|
|
||||||
{:name => 'IssueCustomField', :partial => 'custom_fields/index',
|
|
||||||
:label => :label_issue_plural},
|
|
||||||
{:name => 'TimeEntryCustomField', :partial => 'custom_fields/index',
|
|
||||||
:label => :label_spent_time},
|
|
||||||
{:name => 'ProjectCustomField', :partial => 'custom_fields/index',
|
|
||||||
:label => :label_project_plural},
|
|
||||||
{:name => 'VersionCustomField', :partial => 'custom_fields/index',
|
|
||||||
:label => :label_version_plural},
|
|
||||||
{:name => 'UserCustomField', :partial => 'custom_fields/index',
|
|
||||||
:label => :label_user_plural},
|
|
||||||
{:name => 'GroupCustomField', :partial => 'custom_fields/index',
|
|
||||||
:label => :label_group_plural},
|
|
||||||
{:name => 'TimeEntryActivityCustomField', :partial => 'custom_fields/index',
|
|
||||||
:label => TimeEntryActivity::OptionName},
|
|
||||||
{:name => 'IssuePriorityCustomField', :partial => 'custom_fields/index',
|
|
||||||
:label => IssuePriority::OptionName},
|
|
||||||
{:name => 'DocumentCategoryCustomField', :partial => 'custom_fields/index',
|
|
||||||
:label => DocumentCategory::OptionName}
|
|
||||||
]
|
|
||||||
|
|
||||||
def custom_fields_tabs
|
def custom_fields_tabs
|
||||||
CUSTOM_FIELDS_TABS
|
CustomField::CUSTOM_FIELDS_TABS
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return custom field html tag corresponding to its format
|
# Return custom field html tag corresponding to its format
|
||||||
@@ -98,44 +77,32 @@ module CustomFieldsHelper
|
|||||||
custom_field_label_tag(name, custom_value, options) + custom_field_tag(name, custom_value)
|
custom_field_label_tag(name, custom_value, options) + custom_field_tag(name, custom_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_field_tag_for_bulk_edit(name, custom_field, projects=nil, value='')
|
def custom_field_tag_for_bulk_edit(name, custom_field, projects=nil)
|
||||||
field_name = "#{name}[custom_field_values][#{custom_field.id}]"
|
field_name = "#{name}[custom_field_values][#{custom_field.id}]"
|
||||||
field_name << "[]" if custom_field.multiple?
|
field_name << "[]" if custom_field.multiple?
|
||||||
field_id = "#{name}_custom_field_values_#{custom_field.id}"
|
field_id = "#{name}_custom_field_values_#{custom_field.id}"
|
||||||
|
|
||||||
tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"}
|
tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"}
|
||||||
|
|
||||||
unset_tag = ''
|
|
||||||
unless custom_field.is_required?
|
|
||||||
unset_tag = content_tag('label',
|
|
||||||
check_box_tag(field_name, '__none__', (value == '__none__'), :id => nil, :data => {:disables => "##{field_id}"}) + l(:button_clear),
|
|
||||||
:class => 'inline'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
|
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
|
||||||
case field_format.try(:edit_as)
|
case field_format.try(:edit_as)
|
||||||
when "date"
|
when "date"
|
||||||
text_field_tag(field_name, value, tag_options.merge(:size => 10)) +
|
text_field_tag(field_name, '', tag_options.merge(:size => 10)) +
|
||||||
calendar_for(field_id) +
|
calendar_for(field_id)
|
||||||
unset_tag
|
|
||||||
when "text"
|
when "text"
|
||||||
text_area_tag(field_name, value, tag_options.merge(:rows => 3)) +
|
text_area_tag(field_name, '', tag_options.merge(:rows => 3))
|
||||||
'<br />'.html_safe +
|
|
||||||
unset_tag
|
|
||||||
when "bool"
|
when "bool"
|
||||||
select_tag(field_name, options_for_select([[l(:label_no_change_option), ''],
|
select_tag(field_name, options_for_select([[l(:label_no_change_option), ''],
|
||||||
[l(:general_text_yes), '1'],
|
[l(:general_text_yes), '1'],
|
||||||
[l(:general_text_no), '0']], value), tag_options)
|
[l(:general_text_no), '0']]), tag_options)
|
||||||
when "list"
|
when "list"
|
||||||
options = []
|
options = []
|
||||||
options << [l(:label_no_change_option), ''] unless custom_field.multiple?
|
options << [l(:label_no_change_option), ''] unless custom_field.multiple?
|
||||||
options << [l(:label_none), '__none__'] unless custom_field.is_required?
|
options << [l(:label_none), '__none__'] unless custom_field.is_required?
|
||||||
options += custom_field.possible_values_options(projects)
|
options += custom_field.possible_values_options(projects)
|
||||||
select_tag(field_name, options_for_select(options, value), tag_options.merge(:multiple => custom_field.multiple?))
|
select_tag(field_name, options_for_select(options), tag_options.merge(:multiple => custom_field.multiple?))
|
||||||
else
|
else
|
||||||
text_field_tag(field_name, value, tag_options) +
|
text_field_tag(field_name, '', tag_options)
|
||||||
unset_tag
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -94,20 +94,6 @@ module IssuesHelper
|
|||||||
s.html_safe
|
s.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of error messages for bulk edited issues
|
|
||||||
def bulk_edit_error_messages(issues)
|
|
||||||
messages = {}
|
|
||||||
issues.each do |issue|
|
|
||||||
issue.errors.full_messages.each do |message|
|
|
||||||
messages[message] ||= []
|
|
||||||
messages[message] << issue
|
|
||||||
end
|
|
||||||
end
|
|
||||||
messages.map { |message, issues|
|
|
||||||
"#{message}: " + issues.map {|i| "##{i.id}"}.join(', ')
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a link for adding a new subtask to the given issue
|
# Returns a link for adding a new subtask to the given issue
|
||||||
def link_to_new_subtask(issue)
|
def link_to_new_subtask(issue)
|
||||||
attrs = {
|
attrs = {
|
||||||
@@ -160,13 +146,12 @@ module IssuesHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render_custom_fields_rows(issue)
|
def render_custom_fields_rows(issue)
|
||||||
values = issue.visible_custom_field_values
|
return if issue.custom_field_values.empty?
|
||||||
return if values.empty?
|
|
||||||
ordered_values = []
|
ordered_values = []
|
||||||
half = (values.size / 2.0).ceil
|
half = (issue.custom_field_values.size / 2.0).ceil
|
||||||
half.times do |i|
|
half.times do |i|
|
||||||
ordered_values << values[i]
|
ordered_values << issue.custom_field_values[i]
|
||||||
ordered_values << values[i + half]
|
ordered_values << issue.custom_field_values[i + half]
|
||||||
end
|
end
|
||||||
s = "<tr>\n"
|
s = "<tr>\n"
|
||||||
n = 0
|
n = 0
|
||||||
@@ -199,53 +184,51 @@ module IssuesHelper
|
|||||||
|
|
||||||
def sidebar_queries
|
def sidebar_queries
|
||||||
unless @sidebar_queries
|
unless @sidebar_queries
|
||||||
@sidebar_queries = IssueQuery.visible.
|
@sidebar_queries = IssueQuery.visible.all(
|
||||||
order("#{Query.table_name}.name ASC").
|
:order => "#{Query.table_name}.name ASC",
|
||||||
# Project specific queries and global queries
|
# Project specific queries and global queries
|
||||||
where(@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]).
|
:conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
|
||||||
all
|
)
|
||||||
end
|
end
|
||||||
@sidebar_queries
|
@sidebar_queries
|
||||||
end
|
end
|
||||||
|
|
||||||
def query_links(title, queries)
|
def query_links(title, queries)
|
||||||
return '' if queries.empty?
|
|
||||||
# links to #index on issues/show
|
# links to #index on issues/show
|
||||||
url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
|
url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
|
||||||
|
|
||||||
content_tag('h3', title) + "\n" +
|
content_tag('h3', h(title)) +
|
||||||
content_tag('ul',
|
queries.collect {|query|
|
||||||
queries.collect {|query|
|
css = 'query'
|
||||||
css = 'query'
|
css << ' selected' if query == @query
|
||||||
css << ' selected' if query == @query
|
link_to(h(query.name), url_params.merge(:query_id => query), :class => css)
|
||||||
content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css))
|
}.join('<br />').html_safe
|
||||||
}.join("\n").html_safe,
|
|
||||||
:class => 'queries'
|
|
||||||
) + "\n"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_sidebar_queries
|
def render_sidebar_queries
|
||||||
out = ''.html_safe
|
out = ''.html_safe
|
||||||
out << query_links(l(:label_my_queries), sidebar_queries.select(&:is_private?))
|
queries = sidebar_queries.select {|q| !q.is_public?}
|
||||||
out << query_links(l(:label_query_plural), sidebar_queries.reject(&:is_private?))
|
out << query_links(l(:label_my_queries), queries) if queries.any?
|
||||||
|
queries = sidebar_queries.select {|q| q.is_public?}
|
||||||
|
out << query_links(l(:label_query_plural), queries) if queries.any?
|
||||||
out
|
out
|
||||||
end
|
end
|
||||||
|
|
||||||
def email_issue_attributes(issue, user)
|
def email_issue_attributes(issue)
|
||||||
items = []
|
items = []
|
||||||
%w(author status priority assigned_to category fixed_version).each do |attribute|
|
%w(author status priority assigned_to category fixed_version).each do |attribute|
|
||||||
unless issue.disabled_core_fields.include?(attribute+"_id")
|
unless issue.disabled_core_fields.include?(attribute+"_id")
|
||||||
items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
|
items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
issue.visible_custom_field_values(user).each do |value|
|
issue.custom_field_values.each do |value|
|
||||||
items << "#{value.custom_field.name}: #{show_value(value)}"
|
items << "#{value.custom_field.name}: #{show_value(value)}"
|
||||||
end
|
end
|
||||||
items
|
items
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_email_issue_attributes(issue, user, html=false)
|
def render_email_issue_attributes(issue, html=false)
|
||||||
items = email_issue_attributes(issue, user)
|
items = email_issue_attributes(issue)
|
||||||
if html
|
if html
|
||||||
content_tag('ul', items.map{|s| content_tag('li', s)}.join("\n").html_safe)
|
content_tag('ul', items.map{|s| content_tag('li', s)}.join("\n").html_safe)
|
||||||
else
|
else
|
||||||
@@ -261,23 +244,23 @@ module IssuesHelper
|
|||||||
values_by_field = {}
|
values_by_field = {}
|
||||||
details.each do |detail|
|
details.each do |detail|
|
||||||
if detail.property == 'cf'
|
if detail.property == 'cf'
|
||||||
field = detail.custom_field
|
field_id = detail.prop_key
|
||||||
|
field = CustomField.find_by_id(field_id)
|
||||||
if field && field.multiple?
|
if field && field.multiple?
|
||||||
values_by_field[field] ||= {:added => [], :deleted => []}
|
values_by_field[field_id] ||= {:added => [], :deleted => []}
|
||||||
if detail.old_value
|
if detail.old_value
|
||||||
values_by_field[field][:deleted] << detail.old_value
|
values_by_field[field_id][:deleted] << detail.old_value
|
||||||
end
|
end
|
||||||
if detail.value
|
if detail.value
|
||||||
values_by_field[field][:added] << detail.value
|
values_by_field[field_id][:added] << detail.value
|
||||||
end
|
end
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
strings << show_detail(detail, no_html, options)
|
strings << show_detail(detail, no_html, options)
|
||||||
end
|
end
|
||||||
values_by_field.each do |field, changes|
|
values_by_field.each do |field_id, changes|
|
||||||
detail = JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s)
|
detail = JournalDetail.new(:property => 'cf', :prop_key => field_id)
|
||||||
detail.instance_variable_set "@custom_field", field
|
|
||||||
if changes[:added].any?
|
if changes[:added].any?
|
||||||
detail.value = changes[:added]
|
detail.value = changes[:added]
|
||||||
strings << show_detail(detail, no_html, options)
|
strings << show_detail(detail, no_html, options)
|
||||||
@@ -320,7 +303,7 @@ module IssuesHelper
|
|||||||
old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
|
old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
|
||||||
end
|
end
|
||||||
when 'cf'
|
when 'cf'
|
||||||
custom_field = detail.custom_field
|
custom_field = CustomField.find_by_id(detail.prop_key)
|
||||||
if custom_field
|
if custom_field
|
||||||
multiple = custom_field.multiple?
|
multiple = custom_field.multiple?
|
||||||
label = custom_field.name
|
label = custom_field.name
|
||||||
@@ -329,17 +312,6 @@ module IssuesHelper
|
|||||||
end
|
end
|
||||||
when 'attachment'
|
when 'attachment'
|
||||||
label = l(:label_attachment)
|
label = l(:label_attachment)
|
||||||
when 'relation'
|
|
||||||
if detail.value && !detail.old_value
|
|
||||||
rel_issue = Issue.visible.find_by_id(detail.value)
|
|
||||||
value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.value}" :
|
|
||||||
(no_html ? rel_issue : link_to_issue(rel_issue))
|
|
||||||
elsif detail.old_value && !detail.value
|
|
||||||
rel_issue = Issue.visible.find_by_id(detail.old_value)
|
|
||||||
old_value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.old_value}" :
|
|
||||||
(no_html ? rel_issue : link_to_issue(rel_issue))
|
|
||||||
end
|
|
||||||
label = l(detail.prop_key.to_sym)
|
|
||||||
end
|
end
|
||||||
call_hook(:helper_issues_show_detail_after_setting,
|
call_hook(:helper_issues_show_detail_after_setting,
|
||||||
{:detail => detail, :label => label, :value => value, :old_value => old_value })
|
{:detail => detail, :label => label, :value => value, :old_value => old_value })
|
||||||
@@ -351,9 +323,7 @@ module IssuesHelper
|
|||||||
unless no_html
|
unless no_html
|
||||||
label = content_tag('strong', label)
|
label = content_tag('strong', label)
|
||||||
old_value = content_tag("i", h(old_value)) if detail.old_value
|
old_value = content_tag("i", h(old_value)) if detail.old_value
|
||||||
if detail.old_value && detail.value.blank? && detail.property != 'relation'
|
old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank?
|
||||||
old_value = content_tag("del", old_value)
|
|
||||||
end
|
|
||||||
if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
|
if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
|
||||||
# Link to the attachment if it has not been removed
|
# Link to the attachment if it has not been removed
|
||||||
value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
|
value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
|
||||||
@@ -389,7 +359,7 @@ module IssuesHelper
|
|||||||
else
|
else
|
||||||
l(:text_journal_set_to, :label => label, :value => value).html_safe
|
l(:text_journal_set_to, :label => label, :value => value).html_safe
|
||||||
end
|
end
|
||||||
when 'attachment', 'relation'
|
when 'attachment'
|
||||||
l(:text_journal_added, :label => label, :value => value).html_safe
|
l(:text_journal_added, :label => label, :value => value).html_safe
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module ProjectsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
options = ''
|
options = ''
|
||||||
options << "<option value=''> </option>" if project.allowed_parents.include?(nil)
|
options << "<option value=''></option>" if project.allowed_parents.include?(nil)
|
||||||
options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected)
|
options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected)
|
||||||
content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
|
content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
|
||||||
end
|
end
|
||||||
@@ -69,11 +69,10 @@ module ProjectsHelper
|
|||||||
grouped[version.project.name] << [version.name, version.id]
|
grouped[version.project.name] << [version.name, version.id]
|
||||||
end
|
end
|
||||||
|
|
||||||
selected = selected.is_a?(Version) ? selected.id : selected
|
|
||||||
if grouped.keys.size > 1
|
if grouped.keys.size > 1
|
||||||
grouped_options_for_select(grouped, selected)
|
grouped_options_for_select(grouped, selected && selected.id)
|
||||||
else
|
else
|
||||||
options_for_select((grouped.values.first || []), selected)
|
options_for_select((grouped.values.first || []), selected && selected.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ module QueriesHelper
|
|||||||
if !params[:query_id].blank?
|
if !params[:query_id].blank?
|
||||||
cond = "project_id IS NULL"
|
cond = "project_id IS NULL"
|
||||||
cond << " OR project_id = #{@project.id}" if @project
|
cond << " OR project_id = #{@project.id}" if @project
|
||||||
@query = IssueQuery.where(cond).find(params[:query_id])
|
@query = IssueQuery.find(params[:query_id], :conditions => cond)
|
||||||
raise ::Unauthorized unless @query.visible?
|
raise ::Unauthorized unless @query.visible?
|
||||||
@query.project = @project
|
@query.project = @project
|
||||||
session[:query] = {:id => @query.id, :project_id => @query.project_id}
|
session[:query] = {:id => @query.id, :project_id => @query.project_id}
|
||||||
@@ -198,7 +198,6 @@ module QueriesHelper
|
|||||||
session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names}
|
session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names}
|
||||||
else
|
else
|
||||||
# retrieve from session
|
# retrieve from session
|
||||||
@query = nil
|
|
||||||
@query = IssueQuery.find_by_id(session[:query][:id]) if session[:query][:id]
|
@query = IssueQuery.find_by_id(session[:query][:id]) if session[:query][:id]
|
||||||
@query ||= IssueQuery.new(:name => "_", :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
|
@query ||= IssueQuery.new(:name => "_", :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
|
||||||
@query.project = @project
|
@query.project = @project
|
||||||
|
|||||||
@@ -35,9 +35,12 @@ module VersionsHelper
|
|||||||
h = Hash.new {|k,v| k[v] = [0, 0]}
|
h = Hash.new {|k,v| k[v] = [0, 0]}
|
||||||
begin
|
begin
|
||||||
# Total issue count
|
# Total issue count
|
||||||
Issue.where(:fixed_version_id => version.id).group(criteria).count.each {|c,s| h[c][0] = s}
|
Issue.count(:group => criteria,
|
||||||
|
:conditions => ["#{Issue.table_name}.fixed_version_id = ?", version.id]).each {|c,s| h[c][0] = s}
|
||||||
# Open issues count
|
# Open issues count
|
||||||
Issue.open.where(:fixed_version_id => version.id).group(criteria).count.each {|c,s| h[c][1] = s}
|
Issue.count(:group => criteria,
|
||||||
|
:include => :status,
|
||||||
|
:conditions => ["#{Issue.table_name}.fixed_version_id = ? AND #{IssueStatus.table_name}.is_closed = ?", version.id, false]).each {|c,s| h[c][1] = s}
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
# When grouping by an association, Rails throws this exception if there's no result (bug)
|
# When grouping by an association, Rails throws this exception if there's no result (bug)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module WatchersHelper
|
|||||||
return '' unless user && user.logged?
|
return '' unless user && user.logged?
|
||||||
objects = Array.wrap(objects)
|
objects = Array.wrap(objects)
|
||||||
|
|
||||||
watched = Watcher.any_watched?(objects, user)
|
watched = objects.any? {|object| object.watched_by?(user)}
|
||||||
css = [watcher_css(objects), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ')
|
css = [watcher_css(objects), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ')
|
||||||
text = watched ? l(:button_unwatch) : l(:button_watch)
|
text = watched ? l(:button_unwatch) : l(:button_watch)
|
||||||
url = watch_path(
|
url = watch_path(
|
||||||
|
|||||||
@@ -22,20 +22,11 @@ module WorkflowsHelper
|
|||||||
field.is_a?(CustomField) ? field.is_required? : %w(project_id tracker_id subject priority_id is_private).include?(field)
|
field.is_a?(CustomField) ? field.is_required? : %w(project_id tracker_id subject priority_id is_private).include?(field)
|
||||||
end
|
end
|
||||||
|
|
||||||
def field_permission_tag(permissions, status, field, role)
|
def field_permission_tag(permissions, status, field)
|
||||||
name = field.is_a?(CustomField) ? field.id.to_s : field
|
name = field.is_a?(CustomField) ? field.id.to_s : field
|
||||||
options = [["", ""], [l(:label_readonly), "readonly"]]
|
options = [["", ""], [l(:label_readonly), "readonly"]]
|
||||||
options << [l(:label_required), "required"] unless field_required?(field)
|
options << [l(:label_required), "required"] unless field_required?(field)
|
||||||
html_options = {}
|
|
||||||
selected = permissions[status.id][name]
|
|
||||||
|
|
||||||
hidden = field.is_a?(CustomField) && !field.visible? && !role.custom_fields.to_a.include?(field)
|
select_tag("permissions[#{name}][#{status.id}]", options_for_select(options, permissions[status.id][name]))
|
||||||
if hidden
|
|
||||||
options[0][0] = l(:label_hidden)
|
|
||||||
selected = ''
|
|
||||||
html_options[:disabled] = true
|
|
||||||
end
|
|
||||||
|
|
||||||
select_tag("permissions[#{name}][#{status.id}]", options_for_select(options, selected), html_options)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -294,10 +294,10 @@ class Attachment < ActiveRecord::Base
|
|||||||
|
|
||||||
def sanitize_filename(value)
|
def sanitize_filename(value)
|
||||||
# get only the filename, not the whole path
|
# get only the filename, not the whole path
|
||||||
just_filename = value.gsub(/\A.*(\\|\/)/m, '')
|
just_filename = value.gsub(/^.*(\\|\/)/, '')
|
||||||
|
|
||||||
# Finally, replace invalid characters with underscore
|
# Finally, replace invalid characters with underscore
|
||||||
@filename = just_filename.gsub(/[\/\?\%\*\:\|\"\'<>\n\r]+/, '_')
|
@filename = just_filename.gsub(/[\/\?\%\*\:\|\"\'<>]+/, '_')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the subdirectory in which the attachment will be saved
|
# Returns the subdirectory in which the attachment will be saved
|
||||||
|
|||||||
+16
-20
@@ -118,25 +118,22 @@ class Changeset < ActiveRecord::Base
|
|||||||
ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip)
|
ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip)
|
||||||
ref_keywords_any = ref_keywords.delete('*')
|
ref_keywords_any = ref_keywords.delete('*')
|
||||||
# keywords used to fix issues
|
# keywords used to fix issues
|
||||||
fix_keywords = Setting.commit_update_keywords_array.map {|r| r['keywords']}.flatten.compact
|
fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip)
|
||||||
|
|
||||||
kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|")
|
kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|")
|
||||||
|
|
||||||
referenced_issues = []
|
referenced_issues = []
|
||||||
|
|
||||||
comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match|
|
comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match|
|
||||||
action, refs = match[2].to_s.downcase, match[3]
|
action, refs = match[2], match[3]
|
||||||
next unless action.present? || ref_keywords_any
|
next unless action.present? || ref_keywords_any
|
||||||
|
|
||||||
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
|
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
|
||||||
issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
|
issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
|
||||||
if issue
|
if issue
|
||||||
referenced_issues << issue
|
referenced_issues << issue
|
||||||
# Don't update issues or log time when importing old commits
|
fix_issue(issue) if fix_keywords.include?(action.to_s.downcase)
|
||||||
unless repository.created_on && committed_on && committed_on < repository.created_on
|
log_time(issue, hours) if hours && Setting.commit_logtime_enabled?
|
||||||
fix_issue(issue, action) if fix_keywords.include?(action)
|
|
||||||
log_time(issue, hours) if hours && Setting.commit_logtime_enabled?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -213,26 +210,25 @@ class Changeset < ActiveRecord::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Updates the +issue+ according to +action+
|
def fix_issue(issue)
|
||||||
def fix_issue(issue, action)
|
status = IssueStatus.find_by_id(Setting.commit_fix_status_id.to_i)
|
||||||
|
if status.nil?
|
||||||
|
logger.warn("No status matches commit_fix_status_id setting (#{Setting.commit_fix_status_id})") if logger
|
||||||
|
return issue
|
||||||
|
end
|
||||||
|
|
||||||
# the issue may have been updated by the closure of another one (eg. duplicate)
|
# the issue may have been updated by the closure of another one (eg. duplicate)
|
||||||
issue.reload
|
issue.reload
|
||||||
# don't change the status is the issue is closed
|
# don't change the status is the issue is closed
|
||||||
return if issue.status && issue.status.is_closed?
|
return if issue.status && issue.status.is_closed?
|
||||||
|
|
||||||
journal = issue.init_journal(user || User.anonymous,
|
journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag(issue.project)))
|
||||||
ll(Setting.default_language,
|
issue.status = status
|
||||||
:text_status_changed_by_changeset,
|
unless Setting.commit_fix_done_ratio.blank?
|
||||||
text_tag(issue.project)))
|
issue.done_ratio = Setting.commit_fix_done_ratio.to_i
|
||||||
rule = Setting.commit_update_keywords_array.detect do |rule|
|
|
||||||
rule['keywords'].include?(action) &&
|
|
||||||
(rule['if_tracker_id'].blank? || rule['if_tracker_id'] == issue.tracker_id.to_s)
|
|
||||||
end
|
|
||||||
if rule
|
|
||||||
issue.assign_attributes rule.slice(*Issue.attribute_names)
|
|
||||||
end
|
end
|
||||||
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update,
|
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update,
|
||||||
{ :changeset => self, :issue => issue, :action => action })
|
{ :changeset => self, :issue => issue })
|
||||||
unless issue.save
|
unless issue.save
|
||||||
logger.warn("Issue ##{issue.id} could not be saved by changeset #{id}: #{issue.errors.full_messages}") if logger
|
logger.warn("Issue ##{issue.id} could not be saved by changeset #{id}: #{issue.errors.full_messages}") if logger
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,16 +22,5 @@ class Comment < ActiveRecord::Base
|
|||||||
|
|
||||||
validates_presence_of :commented, :author, :comments
|
validates_presence_of :commented, :author, :comments
|
||||||
|
|
||||||
after_create :send_notification
|
|
||||||
|
|
||||||
safe_attributes 'comments'
|
safe_attributes 'comments'
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def send_notification
|
|
||||||
mailer_method = "#{commented.class.name.underscore}_comment_added"
|
|
||||||
if Setting.notified_events.include?(mailer_method)
|
|
||||||
Mailer.send(mailer_method, self).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,28 +15,10 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
class CommentObserver < ActiveRecord::Observer
|
||||||
|
def after_create(comment)
|
||||||
class IssueCustomFieldTest < ActiveSupport::TestCase
|
if comment.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added')
|
||||||
include Redmine::I18n
|
Mailer.news_comment_added(comment).deliver
|
||||||
|
end
|
||||||
fixtures :roles
|
|
||||||
|
|
||||||
def test_custom_field_with_visible_set_to_false_should_validate_roles
|
|
||||||
set_language_if_valid 'en'
|
|
||||||
field = IssueCustomField.new(:name => 'Field', :field_format => 'string', :visible => false)
|
|
||||||
assert !field.save
|
|
||||||
assert_include "Roles can't be blank", field.errors.full_messages
|
|
||||||
field.role_ids = [1, 2]
|
|
||||||
assert field.save
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_changing_visible_to_true_should_clear_roles
|
|
||||||
field = IssueCustomField.create!(:name => 'Field', :field_format => 'string', :visible => false, :role_ids => [1, 2])
|
|
||||||
assert_equal 2, field.roles.count
|
|
||||||
|
|
||||||
field.visible = true
|
|
||||||
field.save!
|
|
||||||
assert_equal 0, field.roles.count
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
+25
-58
@@ -19,7 +19,6 @@ class CustomField < ActiveRecord::Base
|
|||||||
include Redmine::SubclassFactory
|
include Redmine::SubclassFactory
|
||||||
|
|
||||||
has_many :custom_values, :dependent => :delete_all
|
has_many :custom_values, :dependent => :delete_all
|
||||||
has_and_belongs_to_many :roles, :join_table => "#{table_name_prefix}custom_fields_roles#{table_name_suffix}", :foreign_key => "custom_field_id"
|
|
||||||
acts_as_list :scope => 'type = \'#{self.class}\''
|
acts_as_list :scope => 'type = \'#{self.class}\''
|
||||||
serialize :possible_values
|
serialize :possible_values
|
||||||
|
|
||||||
@@ -27,35 +26,35 @@ class CustomField < ActiveRecord::Base
|
|||||||
validates_uniqueness_of :name, :scope => :type
|
validates_uniqueness_of :name, :scope => :type
|
||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 30
|
||||||
validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
|
validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
|
||||||
validate :validate_custom_field
|
|
||||||
|
|
||||||
|
validate :validate_custom_field
|
||||||
before_validation :set_searchable
|
before_validation :set_searchable
|
||||||
after_save :handle_multiplicity_change
|
after_save :handle_multiplicity_change
|
||||||
after_save do |field|
|
|
||||||
if field.visible_changed? && field.visible
|
|
||||||
field.roles.clear
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
scope :sorted, lambda { order("#{table_name}.position ASC") }
|
scope :sorted, lambda { order("#{table_name}.position ASC") }
|
||||||
scope :visible, lambda {|*args|
|
|
||||||
user = args.shift || User.current
|
|
||||||
if user.admin?
|
|
||||||
# nop
|
|
||||||
elsif user.memberships.any?
|
|
||||||
where("#{table_name}.visible = ? OR #{table_name}.id IN (SELECT DISTINCT cfr.custom_field_id FROM #{Member.table_name} m" +
|
|
||||||
" INNER JOIN #{MemberRole.table_name} mr ON mr.member_id = m.id" +
|
|
||||||
" INNER JOIN #{table_name_prefix}custom_fields_roles#{table_name_suffix} cfr ON cfr.role_id = mr.role_id" +
|
|
||||||
" WHERE m.user_id = ?)",
|
|
||||||
true, user.id)
|
|
||||||
else
|
|
||||||
where(:visible => true)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
def visible_by?(project, user=User.current)
|
CUSTOM_FIELDS_TABS = [
|
||||||
visible? || user.admin?
|
{:name => 'IssueCustomField', :partial => 'custom_fields/index',
|
||||||
end
|
:label => :label_issue_plural},
|
||||||
|
{:name => 'TimeEntryCustomField', :partial => 'custom_fields/index',
|
||||||
|
:label => :label_spent_time},
|
||||||
|
{:name => 'ProjectCustomField', :partial => 'custom_fields/index',
|
||||||
|
:label => :label_project_plural},
|
||||||
|
{:name => 'VersionCustomField', :partial => 'custom_fields/index',
|
||||||
|
:label => :label_version_plural},
|
||||||
|
{:name => 'UserCustomField', :partial => 'custom_fields/index',
|
||||||
|
:label => :label_user_plural},
|
||||||
|
{:name => 'GroupCustomField', :partial => 'custom_fields/index',
|
||||||
|
:label => :label_group_plural},
|
||||||
|
{:name => 'TimeEntryActivityCustomField', :partial => 'custom_fields/index',
|
||||||
|
:label => TimeEntryActivity::OptionName},
|
||||||
|
{:name => 'IssuePriorityCustomField', :partial => 'custom_fields/index',
|
||||||
|
:label => IssuePriority::OptionName},
|
||||||
|
{:name => 'DocumentCategoryCustomField', :partial => 'custom_fields/index',
|
||||||
|
:label => DocumentCategory::OptionName}
|
||||||
|
]
|
||||||
|
|
||||||
|
CUSTOM_FIELDS_NAMES = CUSTOM_FIELDS_TABS.collect{|v| v[:name]}
|
||||||
|
|
||||||
def field_format=(arg)
|
def field_format=(arg)
|
||||||
# cannot change format of a saved custom field
|
# cannot change format of a saved custom field
|
||||||
@@ -123,10 +122,8 @@ class CustomField < ActiveRecord::Base
|
|||||||
values.each do |value|
|
values.each do |value|
|
||||||
value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
|
value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
|
||||||
end
|
end
|
||||||
values
|
|
||||||
else
|
|
||||||
[]
|
|
||||||
end
|
end
|
||||||
|
values || []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -218,7 +215,6 @@ class CustomField < ActiveRecord::Base
|
|||||||
" ON #{join_alias}.customized_type = '#{self.class.customized_class.base_class.name}'" +
|
" ON #{join_alias}.customized_type = '#{self.class.customized_class.base_class.name}'" +
|
||||||
" AND #{join_alias}.customized_id = #{self.class.customized_class.table_name}.id" +
|
" AND #{join_alias}.customized_id = #{self.class.customized_class.table_name}.id" +
|
||||||
" AND #{join_alias}.custom_field_id = #{id}" +
|
" AND #{join_alias}.custom_field_id = #{id}" +
|
||||||
" AND (#{visibility_by_project_condition})" +
|
|
||||||
" AND #{join_alias}.value <> ''" +
|
" AND #{join_alias}.value <> ''" +
|
||||||
" AND #{join_alias}.id = (SELECT max(#{join_alias}_2.id) FROM #{CustomValue.table_name} #{join_alias}_2" +
|
" AND #{join_alias}.id = (SELECT max(#{join_alias}_2.id) FROM #{CustomValue.table_name} #{join_alias}_2" +
|
||||||
" WHERE #{join_alias}_2.customized_type = #{join_alias}.customized_type" +
|
" WHERE #{join_alias}_2.customized_type = #{join_alias}.customized_type" +
|
||||||
@@ -231,7 +227,6 @@ class CustomField < ActiveRecord::Base
|
|||||||
" ON #{join_alias}.customized_type = '#{self.class.customized_class.base_class.name}'" +
|
" ON #{join_alias}.customized_type = '#{self.class.customized_class.base_class.name}'" +
|
||||||
" AND #{join_alias}.customized_id = #{self.class.customized_class.table_name}.id" +
|
" AND #{join_alias}.customized_id = #{self.class.customized_class.table_name}.id" +
|
||||||
" AND #{join_alias}.custom_field_id = #{id}" +
|
" AND #{join_alias}.custom_field_id = #{id}" +
|
||||||
" AND (#{visibility_by_project_condition})" +
|
|
||||||
" AND #{join_alias}.value <> ''" +
|
" AND #{join_alias}.value <> ''" +
|
||||||
" AND #{join_alias}.id = (SELECT max(#{join_alias}_2.id) FROM #{CustomValue.table_name} #{join_alias}_2" +
|
" AND #{join_alias}.id = (SELECT max(#{join_alias}_2.id) FROM #{CustomValue.table_name} #{join_alias}_2" +
|
||||||
" WHERE #{join_alias}_2.customized_type = #{join_alias}.customized_type" +
|
" WHERE #{join_alias}_2.customized_type = #{join_alias}.customized_type" +
|
||||||
@@ -242,7 +237,6 @@ class CustomField < ActiveRecord::Base
|
|||||||
" ON #{join_alias}.customized_type = '#{self.class.customized_class.base_class.name}'" +
|
" ON #{join_alias}.customized_type = '#{self.class.customized_class.base_class.name}'" +
|
||||||
" AND #{join_alias}.customized_id = #{self.class.customized_class.table_name}.id" +
|
" AND #{join_alias}.customized_id = #{self.class.customized_class.table_name}.id" +
|
||||||
" AND #{join_alias}.custom_field_id = #{id}" +
|
" AND #{join_alias}.custom_field_id = #{id}" +
|
||||||
" AND (#{visibility_by_project_condition})" +
|
|
||||||
" AND #{join_alias}.id = (SELECT max(#{join_alias}_2.id) FROM #{CustomValue.table_name} #{join_alias}_2" +
|
" AND #{join_alias}.id = (SELECT max(#{join_alias}_2.id) FROM #{CustomValue.table_name} #{join_alias}_2" +
|
||||||
" WHERE #{join_alias}_2.customized_type = #{join_alias}.customized_type" +
|
" WHERE #{join_alias}_2.customized_type = #{join_alias}.customized_type" +
|
||||||
" AND #{join_alias}_2.customized_id = #{join_alias}.customized_id" +
|
" AND #{join_alias}_2.customized_id = #{join_alias}.customized_id" +
|
||||||
@@ -260,33 +254,6 @@ class CustomField < ActiveRecord::Base
|
|||||||
join_alias + "_" + field_format
|
join_alias + "_" + field_format
|
||||||
end
|
end
|
||||||
|
|
||||||
def visibility_by_project_condition(project_key=nil, user=User.current)
|
|
||||||
if visible? || user.admin?
|
|
||||||
"1=1"
|
|
||||||
elsif user.anonymous?
|
|
||||||
"1=0"
|
|
||||||
else
|
|
||||||
project_key ||= "#{self.class.customized_class.table_name}.project_id"
|
|
||||||
"#{project_key} IN (SELECT DISTINCT m.project_id FROM #{Member.table_name} m" +
|
|
||||||
" INNER JOIN #{MemberRole.table_name} mr ON mr.member_id = m.id" +
|
|
||||||
" INNER JOIN #{table_name_prefix}custom_fields_roles#{table_name_suffix} cfr ON cfr.role_id = mr.role_id" +
|
|
||||||
" WHERE m.user_id = #{user.id} AND cfr.custom_field_id = #{id})"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.visibility_condition
|
|
||||||
if user.admin?
|
|
||||||
"1=1"
|
|
||||||
elsif user.anonymous?
|
|
||||||
"#{table_name}.visible"
|
|
||||||
else
|
|
||||||
"#{project_key} IN (SELECT DISTINCT m.project_id FROM #{Member.table_name} m" +
|
|
||||||
" INNER JOIN #{MemberRole.table_name} mr ON mr.member_id = m.id" +
|
|
||||||
" INNER JOIN #{table_name_prefix}custom_fields_roles#{table_name_suffix} cfr ON cfr.role_id = mr.role_id" +
|
|
||||||
" WHERE m.user_id = #{user.id} AND cfr.custom_field_id = #{id})"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def <=>(field)
|
def <=>(field)
|
||||||
position <=> field.position
|
position <=> field.position
|
||||||
end
|
end
|
||||||
@@ -303,7 +270,7 @@ class CustomField < ActiveRecord::Base
|
|||||||
|
|
||||||
def self.customized_class
|
def self.customized_class
|
||||||
self.name =~ /^(.+)CustomField$/
|
self.name =~ /^(.+)CustomField$/
|
||||||
$1.constantize rescue nil
|
begin; $1.constantize; rescue nil; end
|
||||||
end
|
end
|
||||||
|
|
||||||
# to move in project_custom_field
|
# to move in project_custom_field
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ class Document < ActiveRecord::Base
|
|||||||
validates_presence_of :project, :title, :category
|
validates_presence_of :project, :title, :category
|
||||||
validates_length_of :title, :maximum => 60
|
validates_length_of :title, :maximum => 60
|
||||||
|
|
||||||
after_create :send_notification
|
|
||||||
|
|
||||||
scope :visible, lambda {|*args|
|
scope :visible, lambda {|*args|
|
||||||
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
|
||||||
}
|
}
|
||||||
@@ -56,12 +54,4 @@ class Document < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
@updated_on
|
@updated_on
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def send_notification
|
|
||||||
if Setting.notified_events.include?('document_added')
|
|
||||||
Mailer.document_added(self).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,11 +15,8 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../../../../test_helper', __FILE__)
|
class DocumentObserver < ActiveRecord::Observer
|
||||||
|
def after_create(document)
|
||||||
class DiffTest < ActiveSupport::TestCase
|
Mailer.document_added(document).deliver if Setting.notified_events.include?('document_added')
|
||||||
def test_diff
|
|
||||||
diff = Redmine::Helpers::Diff.new("foo", "bar")
|
|
||||||
assert_not_nil diff
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
+85
-104
@@ -18,7 +18,6 @@
|
|||||||
class Issue < ActiveRecord::Base
|
class Issue < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
include Redmine::Utils::DateCalculation
|
include Redmine::Utils::DateCalculation
|
||||||
include Redmine::I18n
|
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :tracker
|
belongs_to :tracker
|
||||||
@@ -92,15 +91,12 @@ class Issue < ActiveRecord::Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
before_create :default_assign
|
before_create :default_assign
|
||||||
before_save :close_duplicates, :update_done_ratio_from_issue_status,
|
before_save :close_duplicates, :update_done_ratio_from_issue_status, :force_updated_on_change, :update_closed_on
|
||||||
:force_updated_on_change, :update_closed_on
|
|
||||||
after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?}
|
after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?}
|
||||||
after_save :reschedule_following_issues, :update_nested_set_attributes,
|
after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal
|
||||||
:update_parent_attributes, :create_journal
|
|
||||||
# Should be after_create but would be called before previous after_save callbacks
|
# Should be after_create but would be called before previous after_save callbacks
|
||||||
after_save :after_create_from_copy
|
after_save :after_create_from_copy
|
||||||
after_destroy :update_parent_attributes
|
after_destroy :update_parent_attributes
|
||||||
after_create :send_notification
|
|
||||||
|
|
||||||
# Returns a SQL conditions string used to find all issues visible by the specified user
|
# Returns a SQL conditions string used to find all issues visible by the specified user
|
||||||
def self.visible_condition(user, options={})
|
def self.visible_condition(user, options={})
|
||||||
@@ -201,13 +197,6 @@ class Issue < ActiveRecord::Base
|
|||||||
(project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : []
|
(project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : []
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_custom_field_values(user=nil)
|
|
||||||
user_real = user || User.current
|
|
||||||
custom_field_values.select do |value|
|
|
||||||
value.custom_field.visible_by?(project, user_real)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Copies attributes from another issue, arg can be an id or an Issue
|
# Copies attributes from another issue, arg can be an id or an Issue
|
||||||
def copy_from(arg, options={})
|
def copy_from(arg, options={})
|
||||||
issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
|
issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
|
||||||
@@ -358,7 +347,8 @@ class Issue < ActiveRecord::Base
|
|||||||
if issue.new_record?
|
if issue.new_record?
|
||||||
issue.copy?
|
issue.copy?
|
||||||
elsif user.allowed_to?(:move_issues, issue.project)
|
elsif user.allowed_to?(:move_issues, issue.project)
|
||||||
Issue.allowed_target_projects_on_move.count > 1
|
projects = Issue.allowed_target_projects_on_move(user)
|
||||||
|
projects.include?(issue.project) && projects.size > 1
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,7 +415,7 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
# Project and Tracker must be set before since new_statuses_allowed_to depends on it.
|
# Project and Tracker must be set before since new_statuses_allowed_to depends on it.
|
||||||
if (p = attrs.delete('project_id')) && safe_attribute?('project_id')
|
if (p = attrs.delete('project_id')) && safe_attribute?('project_id')
|
||||||
if allowed_target_projects(user).where(:id => p.to_i).exists?
|
if allowed_target_projects(user).collect(&:id).include?(p.to_i)
|
||||||
self.project_id = p
|
self.project_id = p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -455,15 +445,11 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
if attrs['custom_field_values'].present?
|
if attrs['custom_field_values'].present?
|
||||||
editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}
|
attrs['custom_field_values'] = attrs['custom_field_values'].reject {|k, v| read_only_attribute_names(user).include? k.to_s}
|
||||||
# TODO: use #select when ruby1.8 support is dropped
|
|
||||||
attrs['custom_field_values'] = attrs['custom_field_values'].reject {|k, v| !editable_custom_field_ids.include?(k.to_s)}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if attrs['custom_fields'].present?
|
if attrs['custom_fields'].present?
|
||||||
editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}
|
attrs['custom_fields'] = attrs['custom_fields'].reject {|c| read_only_attribute_names(user).include? c['id'].to_s}
|
||||||
# TODO: use #select when ruby1.8 support is dropped
|
|
||||||
attrs['custom_fields'] = attrs['custom_fields'].reject {|c| !editable_custom_field_ids.include?(c['id'].to_s)}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# mass-assignment security bypass
|
# mass-assignment security bypass
|
||||||
@@ -476,7 +462,7 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
# Returns the custom_field_values that can be edited by the given user
|
# Returns the custom_field_values that can be edited by the given user
|
||||||
def editable_custom_field_values(user=nil)
|
def editable_custom_field_values(user=nil)
|
||||||
visible_custom_field_values(user).reject do |value|
|
custom_field_values.reject do |value|
|
||||||
read_only_attribute_names(user).include?(value.custom_field_id.to_s)
|
read_only_attribute_names(user).include?(value.custom_field_id.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -561,12 +547,12 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def validate_issue
|
def validate_issue
|
||||||
if due_date && start_date && (start_date_changed? || due_date_changed?) && due_date < start_date
|
if due_date && start_date && due_date < start_date
|
||||||
errors.add :due_date, :greater_than_start_date
|
errors.add :due_date, :greater_than_start_date
|
||||||
end
|
end
|
||||||
|
|
||||||
if start_date && start_date_changed? && soonest_start && start_date < soonest_start
|
if start_date && soonest_start && start_date < soonest_start
|
||||||
errors.add :start_date, :earlier_than_minimum_start_date, :date => format_date(soonest_start)
|
errors.add :start_date, :invalid
|
||||||
end
|
end
|
||||||
|
|
||||||
if fixed_version
|
if fixed_version
|
||||||
@@ -705,7 +691,7 @@ class Issue < ActiveRecord::Base
|
|||||||
# Is the amount of work done less than it should for the due date
|
# Is the amount of work done less than it should for the due date
|
||||||
def behind_schedule?
|
def behind_schedule?
|
||||||
return false if start_date.nil? || due_date.nil?
|
return false if start_date.nil? || due_date.nil?
|
||||||
done_date = start_date + ((due_date - start_date + 1) * done_ratio / 100).floor
|
done_date = start_date + ((due_date - start_date+1)* done_ratio/100).floor
|
||||||
return done_date <= Date.today
|
return done_date <= Date.today
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -808,21 +794,6 @@ class Issue < ActiveRecord::Base
|
|||||||
notified_users.collect(&:mail)
|
notified_users.collect(&:mail)
|
||||||
end
|
end
|
||||||
|
|
||||||
def each_notification(users, &block)
|
|
||||||
if users.any?
|
|
||||||
if custom_field_values.detect {|value| !value.custom_field.visible?}
|
|
||||||
users_by_custom_field_visibility = users.group_by do |user|
|
|
||||||
visible_custom_field_values(user).map(&:custom_field_id).sort
|
|
||||||
end
|
|
||||||
users_by_custom_field_visibility.values.each do |users|
|
|
||||||
yield(users)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
yield(users)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns the number of hours spent on this issue
|
# Returns the number of hours spent on this issue
|
||||||
def spent_hours
|
def spent_hours
|
||||||
@spent_hours ||= time_entries.sum(:hours) || 0
|
@spent_hours ||= time_entries.sum(:hours) || 0
|
||||||
@@ -845,7 +816,7 @@ class Issue < ActiveRecord::Base
|
|||||||
# Preloads relations for a collection of issues
|
# Preloads relations for a collection of issues
|
||||||
def self.load_relations(issues)
|
def self.load_relations(issues)
|
||||||
if issues.any?
|
if issues.any?
|
||||||
relations = IssueRelation.where("issue_from_id IN (:ids) OR issue_to_id IN (:ids)", :ids => issues.map(&:id)).all
|
relations = IssueRelation.all(:conditions => ["issue_from_id IN (:ids) OR issue_to_id IN (:ids)", {:ids => issues.map(&:id)}])
|
||||||
issues.each do |issue|
|
issues.each do |issue|
|
||||||
issue.instance_variable_set "@relations", relations.select {|r| r.issue_from_id == issue.id || r.issue_to_id == issue.id}
|
issue.instance_variable_set "@relations", relations.select {|r| r.issue_from_id == issue.id || r.issue_to_id == issue.id}
|
||||||
end
|
end
|
||||||
@@ -855,7 +826,7 @@ class Issue < ActiveRecord::Base
|
|||||||
# Preloads visible spent time for a collection of issues
|
# Preloads visible spent time for a collection of issues
|
||||||
def self.load_visible_spent_hours(issues, user=User.current)
|
def self.load_visible_spent_hours(issues, user=User.current)
|
||||||
if issues.any?
|
if issues.any?
|
||||||
hours_by_issue_id = TimeEntry.visible(user).group(:issue_id).sum(:hours)
|
hours_by_issue_id = TimeEntry.visible(user).sum(:hours, :group => :issue_id)
|
||||||
issues.each do |issue|
|
issues.each do |issue|
|
||||||
issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0)
|
issue.instance_variable_set "@spent_hours", (hours_by_issue_id[issue.id] || 0)
|
||||||
end
|
end
|
||||||
@@ -883,7 +854,7 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
# Finds an issue relation given its id.
|
# Finds an issue relation given its id.
|
||||||
def find_relation(relation_id)
|
def find_relation(relation_id)
|
||||||
IssueRelation.where("issue_to_id = ? OR issue_from_id = ?", id, id).find(relation_id)
|
IssueRelation.find(relation_id, :conditions => ["issue_to_id = ? OR issue_from_id = ?", id, id])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns all the other issues that depend on the issue
|
# Returns all the other issues that depend on the issue
|
||||||
@@ -1074,21 +1045,42 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Returns a string of css classes that apply to the issue
|
# Returns a string of css classes that apply to the issue
|
||||||
def css_classes(user=User.current)
|
def css_classes
|
||||||
s = "issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}"
|
s = "issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}"
|
||||||
s << ' closed' if closed?
|
s << ' closed' if closed?
|
||||||
s << ' overdue' if overdue?
|
s << ' overdue' if overdue?
|
||||||
s << ' child' if child?
|
s << ' child' if child?
|
||||||
s << ' parent' unless leaf?
|
s << ' parent' unless leaf?
|
||||||
s << ' private' if is_private?
|
s << ' private' if is_private?
|
||||||
if user.logged?
|
s << ' created-by-me' if User.current.logged? && author_id == User.current.id
|
||||||
s << ' created-by-me' if author_id == user.id
|
s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
|
||||||
s << ' assigned-to-me' if assigned_to_id == user.id
|
|
||||||
s << ' assigned-to-my-group' if user.groups.any? {|g| g.id = assigned_to_id}
|
|
||||||
end
|
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Saves an issue and a time_entry from the parameters
|
||||||
|
def save_issue_with_child_records(params, existing_time_entry=nil)
|
||||||
|
Issue.transaction do
|
||||||
|
if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, project)
|
||||||
|
@time_entry = existing_time_entry || TimeEntry.new
|
||||||
|
@time_entry.project = project
|
||||||
|
@time_entry.issue = self
|
||||||
|
@time_entry.user = User.current
|
||||||
|
@time_entry.spent_on = User.current.today
|
||||||
|
@time_entry.attributes = params[:time_entry]
|
||||||
|
self.time_entries << @time_entry
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: Rename hook
|
||||||
|
Redmine::Hook.call_hook(:controller_issues_edit_before_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
|
||||||
|
if save
|
||||||
|
# TODO: Rename hook
|
||||||
|
Redmine::Hook.call_hook(:controller_issues_edit_after_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal})
|
||||||
|
else
|
||||||
|
raise ActiveRecord::Rollback
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Unassigns issues from +version+ if it's no longer shared with issue's project
|
# Unassigns issues from +version+ if it's no longer shared with issue's project
|
||||||
def self.update_versions_from_sharing_change(version)
|
def self.update_versions_from_sharing_change(version)
|
||||||
# Update issues assigned to the version
|
# Update issues assigned to the version
|
||||||
@@ -1107,10 +1099,6 @@ class Issue < ActiveRecord::Base
|
|||||||
s = arg.to_s.strip.presence
|
s = arg.to_s.strip.presence
|
||||||
if s && (m = s.match(%r{\A#?(\d+)\z})) && (@parent_issue = Issue.find_by_id(m[1]))
|
if s && (m = s.match(%r{\A#?(\d+)\z})) && (@parent_issue = Issue.find_by_id(m[1]))
|
||||||
@parent_issue.id
|
@parent_issue.id
|
||||||
@invalid_parent_issue_id = nil
|
|
||||||
elsif s.blank?
|
|
||||||
@parent_issue = nil
|
|
||||||
@invalid_parent_issue_id = nil
|
|
||||||
else
|
else
|
||||||
@parent_issue = nil
|
@parent_issue = nil
|
||||||
@invalid_parent_issue_id = arg
|
@invalid_parent_issue_id = arg
|
||||||
@@ -1199,18 +1187,18 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
# End ReportsController extraction
|
# End ReportsController extraction
|
||||||
|
|
||||||
# Returns a scope of projects that user can assign the issue to
|
# Returns an array of projects that user can assign the issue to
|
||||||
def allowed_target_projects(user=User.current)
|
def allowed_target_projects(user=User.current)
|
||||||
if new_record?
|
if new_record?
|
||||||
Project.where(Project.allowed_to_condition(user, :add_issues))
|
Project.all(:conditions => Project.allowed_to_condition(user, :add_issues))
|
||||||
else
|
else
|
||||||
self.class.allowed_target_projects_on_move(user)
|
self.class.allowed_target_projects_on_move(user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a scope of projects that user can move issues to
|
# Returns an array of projects that user can move issues to
|
||||||
def self.allowed_target_projects_on_move(user=User.current)
|
def self.allowed_target_projects_on_move(user=User.current)
|
||||||
Project.where(Project.allowed_to_condition(user, :move_issues))
|
Project.all(:conditions => Project.allowed_to_condition(user, :move_issues))
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -1281,50 +1269,48 @@ class Issue < ActiveRecord::Base
|
|||||||
# issue was just created
|
# issue was just created
|
||||||
self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id)
|
self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id)
|
||||||
set_default_left_and_right
|
set_default_left_and_right
|
||||||
Issue.update_all(["root_id = ?, lft = ?, rgt = ?", root_id, lft, rgt], ["id = ?", id])
|
Issue.update_all("root_id = #{root_id}, lft = #{lft}, rgt = #{rgt}", ["id = ?", id])
|
||||||
if @parent_issue
|
if @parent_issue
|
||||||
move_to_child_of(@parent_issue)
|
move_to_child_of(@parent_issue)
|
||||||
end
|
end
|
||||||
|
reload
|
||||||
elsif parent_issue_id != parent_id
|
elsif parent_issue_id != parent_id
|
||||||
update_nested_set_attributes_on_parent_change
|
former_parent_id = parent_id
|
||||||
|
# moving an existing issue
|
||||||
|
if @parent_issue && @parent_issue.root_id == root_id
|
||||||
|
# inside the same tree
|
||||||
|
move_to_child_of(@parent_issue)
|
||||||
|
else
|
||||||
|
# to another tree
|
||||||
|
unless root?
|
||||||
|
move_to_right_of(root)
|
||||||
|
reload
|
||||||
|
end
|
||||||
|
old_root_id = root_id
|
||||||
|
self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id )
|
||||||
|
target_maxright = nested_set_scope.maximum(right_column_name) || 0
|
||||||
|
offset = target_maxright + 1 - lft
|
||||||
|
Issue.update_all("root_id = #{root_id}, lft = lft + #{offset}, rgt = rgt + #{offset}",
|
||||||
|
["root_id = ? AND lft >= ? AND rgt <= ? ", old_root_id, lft, rgt])
|
||||||
|
self[left_column_name] = lft + offset
|
||||||
|
self[right_column_name] = rgt + offset
|
||||||
|
if @parent_issue
|
||||||
|
move_to_child_of(@parent_issue)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
reload
|
||||||
|
# delete invalid relations of all descendants
|
||||||
|
self_and_descendants.each do |issue|
|
||||||
|
issue.relations.each do |relation|
|
||||||
|
relation.destroy unless relation.valid?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# update former parent
|
||||||
|
recalculate_attributes_for(former_parent_id) if former_parent_id
|
||||||
end
|
end
|
||||||
remove_instance_variable(:@parent_issue) if instance_variable_defined?(:@parent_issue)
|
remove_instance_variable(:@parent_issue) if instance_variable_defined?(:@parent_issue)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Updates the nested set for when an existing issue is moved
|
|
||||||
def update_nested_set_attributes_on_parent_change
|
|
||||||
former_parent_id = parent_id
|
|
||||||
# moving an existing issue
|
|
||||||
if @parent_issue && @parent_issue.root_id == root_id
|
|
||||||
# inside the same tree
|
|
||||||
move_to_child_of(@parent_issue)
|
|
||||||
else
|
|
||||||
# to another tree
|
|
||||||
unless root?
|
|
||||||
move_to_right_of(root)
|
|
||||||
end
|
|
||||||
old_root_id = root_id
|
|
||||||
self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id )
|
|
||||||
target_maxright = nested_set_scope.maximum(right_column_name) || 0
|
|
||||||
offset = target_maxright + 1 - lft
|
|
||||||
Issue.update_all(["root_id = ?, lft = lft + ?, rgt = rgt + ?", root_id, offset, offset],
|
|
||||||
["root_id = ? AND lft >= ? AND rgt <= ? ", old_root_id, lft, rgt])
|
|
||||||
self[left_column_name] = lft + offset
|
|
||||||
self[right_column_name] = rgt + offset
|
|
||||||
if @parent_issue
|
|
||||||
move_to_child_of(@parent_issue)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# delete invalid relations of all descendants
|
|
||||||
self_and_descendants.each do |issue|
|
|
||||||
issue.relations.each do |relation|
|
|
||||||
relation.destroy unless relation.valid?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# update former parent
|
|
||||||
recalculate_attributes_for(former_parent_id) if former_parent_id
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_parent_attributes
|
def update_parent_attributes
|
||||||
recalculate_attributes_for(parent_id) if parent_id
|
recalculate_attributes_for(parent_id) if parent_id
|
||||||
end
|
end
|
||||||
@@ -1372,11 +1358,12 @@ class Issue < ActiveRecord::Base
|
|||||||
def self.update_versions(conditions=nil)
|
def self.update_versions(conditions=nil)
|
||||||
# Only need to update issues with a fixed_version from
|
# Only need to update issues with a fixed_version from
|
||||||
# a different project and that is not systemwide shared
|
# a different project and that is not systemwide shared
|
||||||
Issue.includes(:project, :fixed_version).
|
Issue.scoped(:conditions => conditions).all(
|
||||||
where("#{Issue.table_name}.fixed_version_id IS NOT NULL" +
|
:conditions => "#{Issue.table_name}.fixed_version_id IS NOT NULL" +
|
||||||
" AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
|
" AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
|
||||||
" AND #{Version.table_name}.sharing <> 'system'").
|
" AND #{Version.table_name}.sharing <> 'system'",
|
||||||
where(conditions).each do |issue|
|
:include => [:project, :fixed_version]
|
||||||
|
).each do |issue|
|
||||||
next if issue.project.nil? || issue.fixed_version.nil?
|
next if issue.project.nil? || issue.fixed_version.nil?
|
||||||
unless issue.project.shared_versions.include?(issue.fixed_version)
|
unless issue.project.shared_versions.include?(issue.fixed_version)
|
||||||
issue.init_journal(User.current)
|
issue.init_journal(User.current)
|
||||||
@@ -1509,12 +1496,6 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_notification
|
|
||||||
if Setting.notified_events.include?('issue_added')
|
|
||||||
Mailer.deliver_issue_add(self)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Query generator for selecting groups of issue counts for a project
|
# Query generator for selecting groups of issue counts for a project
|
||||||
# based on specific criteria
|
# based on specific criteria
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -23,22 +23,5 @@ class IssueCustomField < CustomField
|
|||||||
def type_name
|
def type_name
|
||||||
:label_issue_plural
|
:label_issue_plural
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_by?(project, user=User.current)
|
|
||||||
super || (roles & user.roles_for_project(project)).present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def visibility_by_project_condition(*args)
|
|
||||||
sql = super
|
|
||||||
additional_sql = "#{Issue.table_name}.tracker_id IN (SELECT tracker_id FROM #{table_name_prefix}custom_fields_trackers#{table_name_suffix} WHERE custom_field_id = #{id})"
|
|
||||||
unless is_for_all?
|
|
||||||
additional_sql << " AND #{Issue.table_name}.project_id IN (SELECT project_id FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} WHERE custom_field_id = #{id})"
|
|
||||||
end
|
|
||||||
"((#{sql}) AND (#{additional_sql}))"
|
|
||||||
end
|
|
||||||
|
|
||||||
def validate_custom_field
|
|
||||||
super
|
|
||||||
errors.add(:base, l(:label_role_plural) + ' ' + l('activerecord.errors.messages.blank')) unless visible? || roles.present?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class IssueObserver < ActiveRecord::Observer
|
||||||
|
def after_create(issue)
|
||||||
|
Mailer.issue_add(issue).deliver if Setting.notified_events.include?('issue_added')
|
||||||
|
end
|
||||||
|
end
|
||||||
+34
-113
@@ -45,25 +45,9 @@ class IssueQuery < Query
|
|||||||
scope :visible, lambda {|*args|
|
scope :visible, lambda {|*args|
|
||||||
user = args.shift || User.current
|
user = args.shift || User.current
|
||||||
base = Project.allowed_to_condition(user, :view_issues, *args)
|
base = Project.allowed_to_condition(user, :view_issues, *args)
|
||||||
scope = includes(:project).where("#{table_name}.project_id IS NULL OR (#{base})")
|
user_id = user.logged? ? user.id : 0
|
||||||
|
|
||||||
if user.admin?
|
includes(:project).where("(#{table_name}.project_id IS NULL OR (#{base})) AND (#{table_name}.is_public = ? OR #{table_name}.user_id = ?)", true, user_id)
|
||||||
scope.where("#{table_name}.visibility <> ? OR #{table_name}.user_id = ?", VISIBILITY_PRIVATE, user.id)
|
|
||||||
elsif user.memberships.any?
|
|
||||||
scope.where("#{table_name}.visibility = ?" +
|
|
||||||
" OR (#{table_name}.visibility = ? AND #{table_name}.id IN (" +
|
|
||||||
"SELECT DISTINCT q.id FROM #{table_name} q" +
|
|
||||||
" INNER JOIN #{table_name_prefix}queries_roles#{table_name_suffix} qr on qr.query_id = q.id" +
|
|
||||||
" INNER JOIN #{MemberRole.table_name} mr ON mr.role_id = qr.role_id" +
|
|
||||||
" INNER JOIN #{Member.table_name} m ON m.id = mr.member_id AND m.user_id = ?" +
|
|
||||||
" WHERE q.project_id IS NULL OR q.project_id = m.project_id))" +
|
|
||||||
" OR #{table_name}.user_id = ?",
|
|
||||||
VISIBILITY_PUBLIC, VISIBILITY_ROLES, user.id, user.id)
|
|
||||||
elsif user.logged?
|
|
||||||
scope.where("#{table_name}.visibility = ? OR #{table_name}.user_id = ?", VISIBILITY_PUBLIC, user.id)
|
|
||||||
else
|
|
||||||
scope.where("#{table_name}.visibility = ?", VISIBILITY_PUBLIC)
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def initialize(attributes=nil, *args)
|
def initialize(attributes=nil, *args)
|
||||||
@@ -73,53 +57,7 @@ class IssueQuery < Query
|
|||||||
|
|
||||||
# Returns true if the query is visible to +user+ or the current user.
|
# Returns true if the query is visible to +user+ or the current user.
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
return true if user.admin?
|
(project.nil? || user.allowed_to?(:view_issues, project)) && (self.is_public? || self.user_id == user.id)
|
||||||
return false unless project.nil? || user.allowed_to?(:view_issues, project)
|
|
||||||
case visibility
|
|
||||||
when VISIBILITY_PUBLIC
|
|
||||||
true
|
|
||||||
when VISIBILITY_ROLES
|
|
||||||
if project
|
|
||||||
(user.roles_for_project(project) & roles).any?
|
|
||||||
else
|
|
||||||
Member.where(:user_id => user.id).joins(:roles).where(:member_roles => {:role_id => roles.map(&:id)}).any?
|
|
||||||
end
|
|
||||||
else
|
|
||||||
user == self.user
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_private?
|
|
||||||
visibility == VISIBILITY_PRIVATE
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_public?
|
|
||||||
!is_private?
|
|
||||||
end
|
|
||||||
|
|
||||||
def draw_relations
|
|
||||||
r = options[:draw_relations]
|
|
||||||
r.nil? || r == '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
def draw_relations=(arg)
|
|
||||||
options[:draw_relations] = (arg == '0' ? '0' : nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
def draw_progress_line
|
|
||||||
r = options[:draw_progress_line]
|
|
||||||
r == '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
def draw_progress_line=(arg)
|
|
||||||
options[:draw_progress_line] = (arg == '1' ? '1' : nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
def build_from_params(params)
|
|
||||||
super
|
|
||||||
self.draw_relations = params[:draw_relations] || (params[:query] && params[:query][:draw_relations])
|
|
||||||
self.draw_progress_line = params[:draw_progress_line] || (params[:query] && params[:query][:draw_progress_line])
|
|
||||||
self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_available_filters
|
def initialize_available_filters
|
||||||
@@ -143,12 +81,13 @@ class IssueQuery < Query
|
|||||||
principals += Principal.member_of(all_projects)
|
principals += Principal.member_of(all_projects)
|
||||||
end
|
end
|
||||||
versions = Version.visible.find_all_by_sharing('system')
|
versions = Version.visible.find_all_by_sharing('system')
|
||||||
issue_custom_fields = IssueCustomField.where(:is_for_all => true)
|
issue_custom_fields = IssueCustomField.where(:is_filter => true, :is_for_all => true).all
|
||||||
end
|
end
|
||||||
principals.uniq!
|
principals.uniq!
|
||||||
principals.sort!
|
principals.sort!
|
||||||
users = principals.select {|p| p.is_a?(User)}
|
users = principals.select {|p| p.is_a?(User)}
|
||||||
|
|
||||||
|
|
||||||
add_available_filter "status_id",
|
add_available_filter "status_id",
|
||||||
:type => :list_status, :values => IssueStatus.sorted.all.collect{|s| [s.name, s.id.to_s] }
|
:type => :list_status, :values => IssueStatus.sorted.all.collect{|s| [s.name, s.id.to_s] }
|
||||||
|
|
||||||
@@ -250,8 +189,8 @@ class IssueQuery < Query
|
|||||||
@available_columns = self.class.available_columns.dup
|
@available_columns = self.class.available_columns.dup
|
||||||
@available_columns += (project ?
|
@available_columns += (project ?
|
||||||
project.all_issue_custom_fields :
|
project.all_issue_custom_fields :
|
||||||
IssueCustomField
|
IssueCustomField.all
|
||||||
).visible.collect {|cf| QueryCustomFieldColumn.new(cf) }
|
).collect {|cf| QueryCustomFieldColumn.new(cf) }
|
||||||
|
|
||||||
if User.current.allowed_to?(:view_time_entries, project, :global => true)
|
if User.current.allowed_to?(:view_time_entries, project, :global => true)
|
||||||
index = nil
|
index = nil
|
||||||
@@ -288,7 +227,7 @@ class IssueQuery < Query
|
|||||||
|
|
||||||
# Returns the issue count
|
# Returns the issue count
|
||||||
def issue_count
|
def issue_count
|
||||||
Issue.visible.joins(:status, :project).where(statement).count
|
Issue.visible.count(:include => [:status, :project], :conditions => statement)
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
@@ -299,12 +238,7 @@ class IssueQuery < Query
|
|||||||
if grouped?
|
if grouped?
|
||||||
begin
|
begin
|
||||||
# Rails3 will raise an (unexpected) RecordNotFound if there's only a nil group value
|
# Rails3 will raise an (unexpected) RecordNotFound if there's only a nil group value
|
||||||
r = Issue.visible.
|
r = Issue.visible.count(:joins => joins_for_order_statement(group_by_statement), :group => group_by_statement, :include => [:status, :project], :conditions => statement)
|
||||||
joins(:status, :project).
|
|
||||||
where(statement).
|
|
||||||
joins(joins_for_order_statement(group_by_statement)).
|
|
||||||
group(group_by_statement).
|
|
||||||
count
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
r = {nil => issue_count}
|
r = {nil => issue_count}
|
||||||
end
|
end
|
||||||
@@ -323,21 +257,14 @@ class IssueQuery < Query
|
|||||||
def issues(options={})
|
def issues(options={})
|
||||||
order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
|
order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
|
||||||
|
|
||||||
scope = Issue.visible.
|
issues = Issue.visible.where(options[:conditions]).all(
|
||||||
joins(:status, :project).
|
:include => ([:status, :project] + (options[:include] || [])).uniq,
|
||||||
where(statement).
|
:conditions => statement,
|
||||||
includes(([:status, :project] + (options[:include] || [])).uniq).
|
:order => order_option,
|
||||||
where(options[:conditions]).
|
:joins => joins_for_order_statement(order_option.join(',')),
|
||||||
order(order_option).
|
:limit => options[:limit],
|
||||||
joins(joins_for_order_statement(order_option.join(','))).
|
:offset => options[:offset]
|
||||||
limit(options[:limit]).
|
)
|
||||||
offset(options[:offset])
|
|
||||||
|
|
||||||
if has_custom_field_column?
|
|
||||||
scope = scope.preload(:custom_values)
|
|
||||||
end
|
|
||||||
|
|
||||||
issues = scope.all
|
|
||||||
|
|
||||||
if has_column?(:spent_hours)
|
if has_column?(:spent_hours)
|
||||||
Issue.load_visible_spent_hours(issues)
|
Issue.load_visible_spent_hours(issues)
|
||||||
@@ -354,16 +281,12 @@ class IssueQuery < Query
|
|||||||
def issue_ids(options={})
|
def issue_ids(options={})
|
||||||
order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
|
order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
|
||||||
|
|
||||||
Issue.visible.
|
Issue.visible.scoped(:conditions => options[:conditions]).scoped(:include => ([:status, :project] + (options[:include] || [])).uniq,
|
||||||
joins(:status, :project).
|
:conditions => statement,
|
||||||
where(statement).
|
:order => order_option,
|
||||||
includes(([:status, :project] + (options[:include] || [])).uniq).
|
:joins => joins_for_order_statement(order_option.join(',')),
|
||||||
where(options[:conditions]).
|
:limit => options[:limit],
|
||||||
order(order_option).
|
:offset => options[:offset]).find_ids
|
||||||
joins(joins_for_order_statement(order_option.join(','))).
|
|
||||||
limit(options[:limit]).
|
|
||||||
offset(options[:offset]).
|
|
||||||
find_ids
|
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
@@ -371,14 +294,13 @@ class IssueQuery < Query
|
|||||||
# Returns the journals
|
# Returns the journals
|
||||||
# Valid options are :order, :offset, :limit
|
# Valid options are :order, :offset, :limit
|
||||||
def journals(options={})
|
def journals(options={})
|
||||||
Journal.visible.
|
Journal.visible.all(
|
||||||
joins(:issue => [:project, :status]).
|
:include => [:details, :user, {:issue => [:project, :author, :tracker, :status]}],
|
||||||
where(statement).
|
:conditions => statement,
|
||||||
order(options[:order]).
|
:order => options[:order],
|
||||||
limit(options[:limit]).
|
:limit => options[:limit],
|
||||||
offset(options[:offset]).
|
:offset => options[:offset]
|
||||||
preload(:details, :user, {:issue => [:project, :author, :tracker, :status]}).
|
)
|
||||||
all
|
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
@@ -386,11 +308,10 @@ class IssueQuery < Query
|
|||||||
# Returns the versions
|
# Returns the versions
|
||||||
# Valid options are :conditions
|
# Valid options are :conditions
|
||||||
def versions(options={})
|
def versions(options={})
|
||||||
Version.visible.
|
Version.visible.where(options[:conditions]).all(
|
||||||
where(project_statement).
|
:include => :project,
|
||||||
where(options[:conditions]).
|
:conditions => project_statement
|
||||||
includes(:project).
|
)
|
||||||
all
|
|
||||||
rescue ::ActiveRecord::StatementInvalid => e
|
rescue ::ActiveRecord::StatementInvalid => e
|
||||||
raise StatementInvalid.new(e.message)
|
raise StatementInvalid.new(e.message)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -72,8 +72,6 @@ class IssueRelation < ActiveRecord::Base
|
|||||||
|
|
||||||
attr_protected :issue_from_id, :issue_to_id
|
attr_protected :issue_from_id, :issue_to_id
|
||||||
before_save :handle_issue_order
|
before_save :handle_issue_order
|
||||||
after_create :create_journal_after_create
|
|
||||||
after_destroy :create_journal_after_delete
|
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
(issue_from.nil? || issue_from.visible?(user)) && (issue_to.nil? || issue_to.visible?(user))
|
(issue_from.nil? || issue_from.visible?(user)) && (issue_to.nil? || issue_to.visible?(user))
|
||||||
@@ -181,30 +179,4 @@ class IssueRelation < ActiveRecord::Base
|
|||||||
self.relation_type = TYPES[relation_type][:reverse]
|
self.relation_type = TYPES[relation_type][:reverse]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_journal_after_create
|
|
||||||
journal = issue_from.init_journal(User.current)
|
|
||||||
journal.details << JournalDetail.new(:property => 'relation',
|
|
||||||
:prop_key => label_for(issue_from).to_s,
|
|
||||||
:value => issue_to.id)
|
|
||||||
journal.save
|
|
||||||
journal = issue_to.init_journal(User.current)
|
|
||||||
journal.details << JournalDetail.new(:property => 'relation',
|
|
||||||
:prop_key => label_for(issue_to).to_s,
|
|
||||||
:value => issue_from.id)
|
|
||||||
journal.save
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_journal_after_delete
|
|
||||||
journal = issue_from.init_journal(User.current)
|
|
||||||
journal.details << JournalDetail.new(:property => 'relation',
|
|
||||||
:prop_key => label_for(issue_from).to_s,
|
|
||||||
:old_value => issue_to.id)
|
|
||||||
journal.save
|
|
||||||
journal = issue_to.init_journal(User.current)
|
|
||||||
journal.details << JournalDetail.new(:property => 'relation',
|
|
||||||
:prop_key => label_for(issue_to).to_s,
|
|
||||||
:old_value => issue_from.id)
|
|
||||||
journal.save
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
+4
-65
@@ -39,7 +39,6 @@ class Journal < ActiveRecord::Base
|
|||||||
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"}
|
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"}
|
||||||
|
|
||||||
before_create :split_private_notes
|
before_create :split_private_notes
|
||||||
after_create :send_notification
|
|
||||||
|
|
||||||
scope :visible, lambda {|*args|
|
scope :visible, lambda {|*args|
|
||||||
user = args.shift || User.current
|
user = args.shift || User.current
|
||||||
@@ -54,32 +53,6 @@ class Journal < ActiveRecord::Base
|
|||||||
(details.empty? && notes.blank?) ? false : super
|
(details.empty? && notes.blank?) ? false : super
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns journal details that are visible to user
|
|
||||||
def visible_details(user=User.current)
|
|
||||||
details.select do |detail|
|
|
||||||
if detail.property == 'cf'
|
|
||||||
detail.custom_field && detail.custom_field.visible_by?(project, user)
|
|
||||||
elsif detail.property == 'relation'
|
|
||||||
Issue.find_by_id(detail.value || detail.old_value).try(:visible?, user)
|
|
||||||
else
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def each_notification(users, &block)
|
|
||||||
if users.any?
|
|
||||||
users_by_details_visibility = users.group_by do |user|
|
|
||||||
visible_details(user)
|
|
||||||
end
|
|
||||||
users_by_details_visibility.each do |visible_details, users|
|
|
||||||
if notes? || visible_details.any?
|
|
||||||
yield(users)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns the new status if the journal contains a status change, otherwise nil
|
# Returns the new status if the journal contains a status change, otherwise nil
|
||||||
def new_status
|
def new_status
|
||||||
c = details.detect {|detail| detail.prop_key == 'status_id'}
|
c = details.detect {|detail| detail.prop_key == 'status_id'}
|
||||||
@@ -120,44 +93,20 @@ class Journal < ActiveRecord::Base
|
|||||||
@notify = arg
|
@notify = arg
|
||||||
end
|
end
|
||||||
|
|
||||||
def notified_users
|
def recipients
|
||||||
notified = journalized.notified_users
|
notified = journalized.notified_users
|
||||||
if private_notes?
|
if private_notes?
|
||||||
notified = notified.select {|user| user.allowed_to?(:view_private_notes, journalized.project)}
|
notified = notified.select {|user| user.allowed_to?(:view_private_notes, journalized.project)}
|
||||||
end
|
end
|
||||||
notified
|
notified.map(&:mail)
|
||||||
end
|
end
|
||||||
|
|
||||||
def recipients
|
def watcher_recipients
|
||||||
notified_users.map(&:mail)
|
|
||||||
end
|
|
||||||
|
|
||||||
def notified_watchers
|
|
||||||
notified = journalized.notified_watchers
|
notified = journalized.notified_watchers
|
||||||
if private_notes?
|
if private_notes?
|
||||||
notified = notified.select {|user| user.allowed_to?(:view_private_notes, journalized.project)}
|
notified = notified.select {|user| user.allowed_to?(:view_private_notes, journalized.project)}
|
||||||
end
|
end
|
||||||
notified
|
notified.map(&:mail)
|
||||||
end
|
|
||||||
|
|
||||||
def watcher_recipients
|
|
||||||
notified_watchers.map(&:mail)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Sets @custom_field instance variable on journals details using a single query
|
|
||||||
def self.preload_journals_details_custom_fields(journals)
|
|
||||||
field_ids = journals.map(&:details).flatten.select {|d| d.property == 'cf'}.map(&:prop_key).uniq
|
|
||||||
if field_ids.any?
|
|
||||||
fields_by_id = CustomField.find_all_by_id(field_ids).inject({}) {|h, f| h[f.id] = f; h}
|
|
||||||
journals.each do |journal|
|
|
||||||
journal.details.each do |detail|
|
|
||||||
if detail.property == 'cf'
|
|
||||||
detail.instance_variable_set "@custom_field", fields_by_id[detail.prop_key.to_i]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
journals
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -180,14 +129,4 @@ class Journal < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_notification
|
|
||||||
if notify? && (Setting.notified_events.include?('issue_updated') ||
|
|
||||||
(Setting.notified_events.include?('issue_note_added') && notes.present?) ||
|
|
||||||
(Setting.notified_events.include?('issue_status_updated') && new_status.present?) ||
|
|
||||||
(Setting.notified_events.include?('issue_priority_updated') && new_value_for('priority_id').present?)
|
|
||||||
)
|
|
||||||
Mailer.deliver_issue_edit(self)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ class JournalDetail < ActiveRecord::Base
|
|||||||
belongs_to :journal
|
belongs_to :journal
|
||||||
before_save :normalize_values
|
before_save :normalize_values
|
||||||
|
|
||||||
def custom_field
|
|
||||||
if property == 'cf'
|
|
||||||
@custom_field ||= CustomField.find_by_id(prop_key)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def normalize_values
|
def normalize_values
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class JournalObserver < ActiveRecord::Observer
|
||||||
|
def after_create(journal)
|
||||||
|
if journal.notify? &&
|
||||||
|
(Setting.notified_events.include?('issue_updated') ||
|
||||||
|
(Setting.notified_events.include?('issue_note_added') && journal.notes.present?) ||
|
||||||
|
(Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) ||
|
||||||
|
(Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?)
|
||||||
|
)
|
||||||
|
Mailer.issue_edit(journal).deliver
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
+18
-59
@@ -46,19 +46,6 @@ class MailHandler < ActionMailer::Base
|
|||||||
super(email)
|
super(email)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Extracts MailHandler options from environment variables
|
|
||||||
# Use when receiving emails with rake tasks
|
|
||||||
def self.extract_options_from_env(env)
|
|
||||||
options = {:issue => {}}
|
|
||||||
%w(project status tracker category priority).each do |option|
|
|
||||||
options[:issue][option.to_sym] = env[option] if env[option]
|
|
||||||
end
|
|
||||||
%w(allow_override unknown_user no_permission_check no_account_notice default_group).each do |option|
|
|
||||||
options[option.to_sym] = env[option] if env[option]
|
|
||||||
end
|
|
||||||
options
|
|
||||||
end
|
|
||||||
|
|
||||||
def logger
|
def logger
|
||||||
Rails.logger
|
Rails.logger
|
||||||
end
|
end
|
||||||
@@ -76,7 +63,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
sender_email = email.from.to_a.first.to_s.strip
|
sender_email = email.from.to_a.first.to_s.strip
|
||||||
# Ignore emails received from the application emission address to avoid hell cycles
|
# Ignore emails received from the application emission address to avoid hell cycles
|
||||||
if sender_email.downcase == Setting.mail_from.to_s.strip.downcase
|
if sender_email.downcase == Setting.mail_from.to_s.strip.downcase
|
||||||
if logger
|
if logger && logger.info
|
||||||
logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]"
|
logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -87,7 +74,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
if value
|
if value
|
||||||
value = value.to_s.downcase
|
value = value.to_s.downcase
|
||||||
if (ignored_value.is_a?(Regexp) && value.match(ignored_value)) || value == ignored_value
|
if (ignored_value.is_a?(Regexp) && value.match(ignored_value)) || value == ignored_value
|
||||||
if logger
|
if logger && logger.info
|
||||||
logger.info "MailHandler: ignoring email with #{key}:#{value} header"
|
logger.info "MailHandler: ignoring email with #{key}:#{value} header"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -96,7 +83,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
@user = User.find_by_mail(sender_email) if sender_email.present?
|
@user = User.find_by_mail(sender_email) if sender_email.present?
|
||||||
if @user && !@user.active?
|
if @user && !@user.active?
|
||||||
if logger
|
if logger && logger.info
|
||||||
logger.info "MailHandler: ignoring email from non-active user [#{@user.login}]"
|
logger.info "MailHandler: ignoring email from non-active user [#{@user.login}]"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -109,7 +96,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
when 'create'
|
when 'create'
|
||||||
@user = create_user_from_email
|
@user = create_user_from_email
|
||||||
if @user
|
if @user
|
||||||
if logger
|
if logger && logger.info
|
||||||
logger.info "MailHandler: [#{@user.login}] account created"
|
logger.info "MailHandler: [#{@user.login}] account created"
|
||||||
end
|
end
|
||||||
add_user_to_group(@@handler_options[:default_group])
|
add_user_to_group(@@handler_options[:default_group])
|
||||||
@@ -117,14 +104,14 @@ class MailHandler < ActionMailer::Base
|
|||||||
Mailer.account_information(@user, @user.password).deliver
|
Mailer.account_information(@user, @user.password).deliver
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if logger
|
if logger && logger.error
|
||||||
logger.error "MailHandler: could not create account for [#{sender_email}]"
|
logger.error "MailHandler: could not create account for [#{sender_email}]"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# Default behaviour, emails from unknown users are ignored
|
# Default behaviour, emails from unknown users are ignored
|
||||||
if logger
|
if logger && logger.info
|
||||||
logger.info "MailHandler: ignoring email from unknown user [#{sender_email}]"
|
logger.info "MailHandler: ignoring email from unknown user [#{sender_email}]"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -136,7 +123,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+(\.[a-f0-9]+)?@}
|
MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
|
||||||
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]}
|
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]}
|
||||||
MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
|
MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
|
||||||
|
|
||||||
@@ -195,7 +182,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
add_watchers(issue)
|
add_watchers(issue)
|
||||||
issue.save!
|
issue.save!
|
||||||
add_attachments(issue)
|
add_attachments(issue)
|
||||||
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger
|
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
|
||||||
issue
|
issue
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -224,7 +211,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
journal.notes = cleaned_up_text_body
|
journal.notes = cleaned_up_text_body
|
||||||
add_attachments(issue)
|
add_attachments(issue)
|
||||||
issue.save!
|
issue.save!
|
||||||
if logger
|
if logger && logger.info
|
||||||
logger.info "MailHandler: issue ##{issue.id} updated by #{user}"
|
logger.info "MailHandler: issue ##{issue.id} updated by #{user}"
|
||||||
end
|
end
|
||||||
journal
|
journal
|
||||||
@@ -257,7 +244,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
add_attachments(reply)
|
add_attachments(reply)
|
||||||
reply
|
reply
|
||||||
else
|
else
|
||||||
if logger
|
if logger && logger.info
|
||||||
logger.info "MailHandler: ignoring reply from [#{sender_email}] to a locked topic"
|
logger.info "MailHandler: ignoring reply from [#{sender_email}] to a locked topic"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -267,7 +254,6 @@ class MailHandler < ActionMailer::Base
|
|||||||
def add_attachments(obj)
|
def add_attachments(obj)
|
||||||
if email.attachments && email.attachments.any?
|
if email.attachments && email.attachments.any?
|
||||||
email.attachments.each do |attachment|
|
email.attachments.each do |attachment|
|
||||||
next unless accept_attachment?(attachment)
|
|
||||||
obj.attachments << Attachment.create(:container => obj,
|
obj.attachments << Attachment.create(:container => obj,
|
||||||
:file => attachment.decoded,
|
:file => attachment.decoded,
|
||||||
:filename => attachment.filename,
|
:filename => attachment.filename,
|
||||||
@@ -277,19 +263,6 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns false if the +attachment+ of the incoming email should be ignored
|
|
||||||
def accept_attachment?(attachment)
|
|
||||||
@excluded ||= Setting.mail_handler_excluded_filenames.to_s.split(',').map(&:strip).reject(&:blank?)
|
|
||||||
@excluded.each do |pattern|
|
|
||||||
regexp = %r{\A#{Regexp.escape(pattern).gsub("\\*", ".*")}\z}i
|
|
||||||
if attachment.filename.to_s =~ regexp
|
|
||||||
logger.info "MailHandler: ignoring attachment #{attachment.filename} matching #{pattern}"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
# Adds To and Cc as watchers of the given object if the sender has the
|
# Adds To and Cc as watchers of the given object if the sender has the
|
||||||
# appropriate permission
|
# appropriate permission
|
||||||
def add_watchers(obj)
|
def add_watchers(obj)
|
||||||
@@ -347,13 +320,6 @@ class MailHandler < ActionMailer::Base
|
|||||||
# * parse the email To field
|
# * parse the email To field
|
||||||
# * specific project (eg. Setting.mail_handler_target_project)
|
# * specific project (eg. Setting.mail_handler_target_project)
|
||||||
target = Project.find_by_identifier(get_keyword(:project))
|
target = Project.find_by_identifier(get_keyword(:project))
|
||||||
if target.nil?
|
|
||||||
# Invalid project keyword, use the project specified as the default one
|
|
||||||
default_project = @@handler_options[:issue][:project]
|
|
||||||
if default_project.present?
|
|
||||||
target = Project.find_by_identifier(default_project)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
raise MissingInformation.new('Unable to determine target project') if target.nil?
|
raise MissingInformation.new('Unable to determine target project') if target.nil?
|
||||||
target
|
target
|
||||||
end
|
end
|
||||||
@@ -398,21 +364,12 @@ class MailHandler < ActionMailer::Base
|
|||||||
def plain_text_body
|
def plain_text_body
|
||||||
return @plain_text_body unless @plain_text_body.nil?
|
return @plain_text_body unless @plain_text_body.nil?
|
||||||
|
|
||||||
parts = if (text_parts = email.all_parts.select {|p| p.mime_type == 'text/plain'}).present?
|
part = email.text_part || email.html_part || email
|
||||||
text_parts
|
@plain_text_body = Redmine::CodesetUtil.to_utf8(part.body.decoded, part.charset)
|
||||||
elsif (html_parts = email.all_parts.select {|p| p.mime_type == 'text/html'}).present?
|
|
||||||
html_parts
|
|
||||||
else
|
|
||||||
[email]
|
|
||||||
end
|
|
||||||
@plain_text_body = parts.map {|p| Redmine::CodesetUtil.to_utf8(p.body.decoded, p.charset)}.join("\r\n")
|
|
||||||
|
|
||||||
# strip html tags and remove doctype directive
|
# strip html tags and remove doctype directive
|
||||||
if parts.any? {|p| p.mime_type == 'text/html'}
|
@plain_text_body = strip_tags(@plain_text_body.strip)
|
||||||
@plain_text_body = strip_tags(@plain_text_body.strip)
|
@plain_text_body.sub! %r{^<!DOCTYPE .*$}, ''
|
||||||
@plain_text_body.sub! %r{^<!DOCTYPE .*$}, ''
|
|
||||||
end
|
|
||||||
|
|
||||||
@plain_text_body
|
@plain_text_body
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -447,8 +404,10 @@ class MailHandler < ActionMailer::Base
|
|||||||
assign_string_attribute_with_limit(user, 'firstname', names.shift, 30)
|
assign_string_attribute_with_limit(user, 'firstname', names.shift, 30)
|
||||||
assign_string_attribute_with_limit(user, 'lastname', names.join(' '), 30)
|
assign_string_attribute_with_limit(user, 'lastname', names.join(' '), 30)
|
||||||
user.lastname = '-' if user.lastname.blank?
|
user.lastname = '-' if user.lastname.blank?
|
||||||
|
|
||||||
|
password_length = [Setting.password_min_length.to_i, 10].max
|
||||||
|
user.password = Redmine::Utils.random_hex(password_length / 2 + 1)
|
||||||
user.language = Setting.default_language
|
user.language = Setting.default_language
|
||||||
user.generate_password = true
|
|
||||||
user.mail_notification = 'only_my_events'
|
user.mail_notification = 'only_my_events'
|
||||||
|
|
||||||
unless user.valid?
|
unless user.valid?
|
||||||
@@ -485,7 +444,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds the newly created user to default group
|
# Adds the newly created user to default group
|
||||||
def add_user_to_group(default_group)
|
def add_user_to_group(default_group)
|
||||||
if default_group.present?
|
if default_group.present?
|
||||||
default_group.split(',').each do |group_name|
|
default_group.split(',').each do |group_name|
|
||||||
|
|||||||
+62
-82
@@ -27,35 +27,34 @@ class Mailer < ActionMailer::Base
|
|||||||
{ :host => Setting.host_name, :protocol => Setting.protocol }
|
{ :host => Setting.host_name, :protocol => Setting.protocol }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a mail for notifying to_users and cc_users about a new issue
|
# Builds a Mail::Message object used to email recipients of the added issue.
|
||||||
def issue_add(issue, to_users, cc_users)
|
#
|
||||||
|
# Example:
|
||||||
|
# issue_add(issue) => Mail::Message object
|
||||||
|
# Mailer.issue_add(issue).deliver => sends an email to issue recipients
|
||||||
|
def issue_add(issue)
|
||||||
redmine_headers 'Project' => issue.project.identifier,
|
redmine_headers 'Project' => issue.project.identifier,
|
||||||
'Issue-Id' => issue.id,
|
'Issue-Id' => issue.id,
|
||||||
'Issue-Author' => issue.author.login
|
'Issue-Author' => issue.author.login
|
||||||
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
|
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
|
||||||
message_id issue
|
message_id issue
|
||||||
references issue
|
|
||||||
@author = issue.author
|
@author = issue.author
|
||||||
@issue = issue
|
@issue = issue
|
||||||
@users = to_users + cc_users
|
|
||||||
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
|
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
|
||||||
mail :to => to_users.map(&:mail),
|
recipients = issue.recipients
|
||||||
:cc => cc_users.map(&:mail),
|
cc = issue.watcher_recipients - recipients
|
||||||
|
mail :to => recipients,
|
||||||
|
:cc => cc,
|
||||||
:subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
|
:subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Notifies users about a new issue
|
# Builds a Mail::Message object used to email recipients of the edited issue.
|
||||||
def self.deliver_issue_add(issue)
|
#
|
||||||
to = issue.notified_users
|
# Example:
|
||||||
cc = issue.notified_watchers - to
|
# issue_edit(journal) => Mail::Message object
|
||||||
issue.each_notification(to + cc) do |users|
|
# Mailer.issue_edit(journal).deliver => sends an email to issue recipients
|
||||||
Mailer.issue_add(issue, to & users, cc & users).deliver
|
def issue_edit(journal)
|
||||||
end
|
issue = journal.journalized.reload
|
||||||
end
|
|
||||||
|
|
||||||
# Builds a mail for notifying to_users and cc_users about an issue update
|
|
||||||
def issue_edit(journal, to_users, cc_users)
|
|
||||||
issue = journal.journalized
|
|
||||||
redmine_headers 'Project' => issue.project.identifier,
|
redmine_headers 'Project' => issue.project.identifier,
|
||||||
'Issue-Id' => issue.id,
|
'Issue-Id' => issue.id,
|
||||||
'Issue-Author' => issue.author.login
|
'Issue-Author' => issue.author.login
|
||||||
@@ -63,31 +62,20 @@ class Mailer < ActionMailer::Base
|
|||||||
message_id journal
|
message_id journal
|
||||||
references issue
|
references issue
|
||||||
@author = journal.user
|
@author = journal.user
|
||||||
|
recipients = journal.recipients
|
||||||
|
# Watchers in cc
|
||||||
|
cc = journal.watcher_recipients - recipients
|
||||||
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
|
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
|
||||||
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
|
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
|
||||||
s << issue.subject
|
s << issue.subject
|
||||||
@issue = issue
|
@issue = issue
|
||||||
@users = to_users + cc_users
|
|
||||||
@journal = journal
|
@journal = journal
|
||||||
@journal_details = journal.visible_details(@users.first)
|
|
||||||
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
|
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
|
||||||
mail :to => to_users.map(&:mail),
|
mail :to => recipients,
|
||||||
:cc => cc_users.map(&:mail),
|
:cc => cc,
|
||||||
:subject => s
|
:subject => s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Notifies users about an issue update
|
|
||||||
def self.deliver_issue_edit(journal)
|
|
||||||
issue = journal.journalized.reload
|
|
||||||
to = journal.notified_users
|
|
||||||
cc = journal.notified_watchers
|
|
||||||
journal.each_notification(to + cc) do |users|
|
|
||||||
issue.each_notification(users) do |users2|
|
|
||||||
Mailer.issue_edit(journal, to & users2, cc & users2).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def reminder(user, issues, days)
|
def reminder(user, issues, days)
|
||||||
set_language_if_valid user.language
|
set_language_if_valid user.language
|
||||||
@issues = issues
|
@issues = issues
|
||||||
@@ -154,7 +142,6 @@ class Mailer < ActionMailer::Base
|
|||||||
redmine_headers 'Project' => news.project.identifier
|
redmine_headers 'Project' => news.project.identifier
|
||||||
@author = news.author
|
@author = news.author
|
||||||
message_id news
|
message_id news
|
||||||
references news
|
|
||||||
@news = news
|
@news = news
|
||||||
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
||||||
mail :to => news.recipients,
|
mail :to => news.recipients,
|
||||||
@@ -171,7 +158,6 @@ class Mailer < ActionMailer::Base
|
|||||||
redmine_headers 'Project' => news.project.identifier
|
redmine_headers 'Project' => news.project.identifier
|
||||||
@author = comment.author
|
@author = comment.author
|
||||||
message_id comment
|
message_id comment
|
||||||
references news
|
|
||||||
@news = news
|
@news = news
|
||||||
@comment = comment
|
@comment = comment
|
||||||
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
||||||
@@ -190,7 +176,7 @@ class Mailer < ActionMailer::Base
|
|||||||
'Topic-Id' => (message.parent_id || message.id)
|
'Topic-Id' => (message.parent_id || message.id)
|
||||||
@author = message.author
|
@author = message.author
|
||||||
message_id message
|
message_id message
|
||||||
references message.root
|
references message.parent unless message.parent.nil?
|
||||||
recipients = message.recipients
|
recipients = message.recipients
|
||||||
cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
|
cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
|
||||||
@message = message
|
@message = message
|
||||||
@@ -311,6 +297,31 @@ class Mailer < ActionMailer::Base
|
|||||||
:subject => 'Redmine test'
|
:subject => 'Redmine test'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Overrides default deliver! method to prevent from sending an email
|
||||||
|
# with no recipient, cc or bcc
|
||||||
|
def deliver!(mail = @mail)
|
||||||
|
set_language_if_valid @initial_language
|
||||||
|
return false if (recipients.nil? || recipients.empty?) &&
|
||||||
|
(cc.nil? || cc.empty?) &&
|
||||||
|
(bcc.nil? || bcc.empty?)
|
||||||
|
|
||||||
|
|
||||||
|
# Log errors when raise_delivery_errors is set to false, Rails does not
|
||||||
|
raise_errors = self.class.raise_delivery_errors
|
||||||
|
self.class.raise_delivery_errors = true
|
||||||
|
begin
|
||||||
|
return super(mail)
|
||||||
|
rescue Exception => e
|
||||||
|
if raise_errors
|
||||||
|
raise e
|
||||||
|
elsif mylogger
|
||||||
|
mylogger.error "The following error occured while sending email notification: \"#{e.message}\". Check your configuration in config/configuration.yml."
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
self.class.raise_delivery_errors = raise_errors
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Sends reminders to issue assignees
|
# Sends reminders to issue assignees
|
||||||
# Available options:
|
# Available options:
|
||||||
# * :days => how many days in the future to remind about (defaults to 7)
|
# * :days => how many days in the future to remind about (defaults to 7)
|
||||||
@@ -368,7 +379,7 @@ class Mailer < ActionMailer::Base
|
|||||||
ActionMailer::Base.delivery_method = saved_method
|
ActionMailer::Base.delivery_method = saved_method
|
||||||
end
|
end
|
||||||
|
|
||||||
def mail(headers={}, &block)
|
def mail(headers={})
|
||||||
headers.merge! 'X-Mailer' => 'Redmine',
|
headers.merge! 'X-Mailer' => 'Redmine',
|
||||||
'X-Redmine-Host' => Setting.host_name,
|
'X-Redmine-Host' => Setting.host_name,
|
||||||
'X-Redmine-Site' => Setting.app_title,
|
'X-Redmine-Site' => Setting.app_title,
|
||||||
@@ -378,8 +389,7 @@ class Mailer < ActionMailer::Base
|
|||||||
'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
|
'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
|
||||||
|
|
||||||
# Removes the author from the recipients and cc
|
# Removes the author from the recipients and cc
|
||||||
# if the author does not want to receive notifications
|
# if he doesn't want to receive notifications about what he does
|
||||||
# about what the author do
|
|
||||||
if @author && @author.logged? && @author.pref.no_self_notified
|
if @author && @author.logged? && @author.pref.no_self_notified
|
||||||
headers[:to].delete(@author.mail) if headers[:to].is_a?(Array)
|
headers[:to].delete(@author.mail) if headers[:to].is_a?(Array)
|
||||||
headers[:cc].delete(@author.mail) if headers[:cc].is_a?(Array)
|
headers[:cc].delete(@author.mail) if headers[:cc].is_a?(Array)
|
||||||
@@ -400,20 +410,15 @@ class Mailer < ActionMailer::Base
|
|||||||
headers[:message_id] = "<#{self.class.message_id_for(@message_id_object)}>"
|
headers[:message_id] = "<#{self.class.message_id_for(@message_id_object)}>"
|
||||||
end
|
end
|
||||||
if @references_objects
|
if @references_objects
|
||||||
headers[:references] = @references_objects.collect {|o| "<#{self.class.references_for(o)}>"}.join(' ')
|
headers[:references] = @references_objects.collect {|o| "<#{self.class.message_id_for(o)}>"}.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
m = if block_given?
|
super headers do |format|
|
||||||
super headers, &block
|
format.text
|
||||||
else
|
format.html unless Setting.plain_text_mail?
|
||||||
super headers do |format|
|
|
||||||
format.text
|
|
||||||
format.html unless Setting.plain_text_mail?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
set_language_if_valid @initial_language
|
set_language_if_valid @initial_language
|
||||||
|
|
||||||
m
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
@@ -424,17 +429,7 @@ class Mailer < ActionMailer::Base
|
|||||||
|
|
||||||
def self.deliver_mail(mail)
|
def self.deliver_mail(mail)
|
||||||
return false if mail.to.blank? && mail.cc.blank? && mail.bcc.blank?
|
return false if mail.to.blank? && mail.cc.blank? && mail.bcc.blank?
|
||||||
begin
|
super
|
||||||
# Log errors when raise_delivery_errors is set to false, Rails does not
|
|
||||||
mail.raise_delivery_errors = true
|
|
||||||
super
|
|
||||||
rescue Exception => e
|
|
||||||
if ActionMailer::Base.raise_delivery_errors
|
|
||||||
raise e
|
|
||||||
else
|
|
||||||
Rails.logger.error "Email delivery error: #{e.message}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.method_missing(method, *args, &block)
|
def self.method_missing(method, *args, &block)
|
||||||
@@ -453,30 +448,15 @@ class Mailer < ActionMailer::Base
|
|||||||
h.each { |k,v| headers["X-Redmine-#{k}"] = v.to_s }
|
h.each { |k,v| headers["X-Redmine-#{k}"] = v.to_s }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.token_for(object, rand=true)
|
# Returns a predictable Message-Id for the given object
|
||||||
|
def self.message_id_for(object)
|
||||||
|
# id + timestamp should reduce the odds of a collision
|
||||||
|
# as far as we don't send multiple emails for the same object
|
||||||
timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on)
|
timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on)
|
||||||
hash = [
|
hash = "redmine.#{object.class.name.demodulize.underscore}-#{object.id}.#{timestamp.strftime("%Y%m%d%H%M%S")}"
|
||||||
"redmine",
|
|
||||||
"#{object.class.name.demodulize.underscore}-#{object.id}",
|
|
||||||
timestamp.strftime("%Y%m%d%H%M%S")
|
|
||||||
]
|
|
||||||
if rand
|
|
||||||
hash << Redmine::Utils.random_hex(8)
|
|
||||||
end
|
|
||||||
host = Setting.mail_from.to_s.gsub(%r{^.*@}, '')
|
host = Setting.mail_from.to_s.gsub(%r{^.*@}, '')
|
||||||
host = "#{::Socket.gethostname}.redmine" if host.empty?
|
host = "#{::Socket.gethostname}.redmine" if host.empty?
|
||||||
"#{hash.join('.')}@#{host}"
|
"#{hash}@#{host}"
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a Message-Id for the given object
|
|
||||||
def self.message_id_for(object)
|
|
||||||
token_for(object, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a uniq token for a given object referenced by all notifications
|
|
||||||
# related to this object
|
|
||||||
def self.references_for(object)
|
|
||||||
token_for(object, false)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def message_id(object)
|
def message_id(object)
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ class Message < ActiveRecord::Base
|
|||||||
after_create :add_author_as_watcher, :reset_counters!
|
after_create :add_author_as_watcher, :reset_counters!
|
||||||
after_update :update_messages_board
|
after_update :update_messages_board
|
||||||
after_destroy :reset_counters!
|
after_destroy :reset_counters!
|
||||||
after_create :send_notification
|
|
||||||
|
|
||||||
scope :visible, lambda {|*args|
|
scope :visible, lambda {|*args|
|
||||||
includes(:board => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_messages, *args))
|
includes(:board => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_messages, *args))
|
||||||
@@ -106,10 +105,4 @@ class Message < ActiveRecord::Base
|
|||||||
def add_author_as_watcher
|
def add_author_as_watcher
|
||||||
Watcher.create(:watchable => self.root, :user => author)
|
Watcher.create(:watchable => self.root, :user => author)
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_notification
|
|
||||||
if Setting.notified_events.include?('message_posted')
|
|
||||||
Mailer.message_posted(self).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class MessageObserver < ActiveRecord::Observer
|
||||||
|
def after_create(message)
|
||||||
|
Mailer.message_posted(message).deliver if Setting.notified_events.include?('message_posted')
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -33,7 +33,6 @@ class News < ActiveRecord::Base
|
|||||||
acts_as_watchable
|
acts_as_watchable
|
||||||
|
|
||||||
after_create :add_author_as_watcher
|
after_create :add_author_as_watcher
|
||||||
after_create :send_notification
|
|
||||||
|
|
||||||
scope :visible, lambda {|*args|
|
scope :visible, lambda {|*args|
|
||||||
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
|
||||||
@@ -64,10 +63,4 @@ class News < ActiveRecord::Base
|
|||||||
def add_author_as_watcher
|
def add_author_as_watcher
|
||||||
Watcher.create(:watchable => self, :user => author)
|
Watcher.create(:watchable => self, :user => author)
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_notification
|
|
||||||
if Setting.notified_events.include?('news_added')
|
|
||||||
Mailer.news_added(self).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class NewsObserver < ActiveRecord::Observer
|
||||||
|
def after_create(news)
|
||||||
|
Mailer.news_added(news).deliver if Setting.notified_events.include?('news_added')
|
||||||
|
end
|
||||||
|
end
|
||||||
+18
-33
@@ -33,6 +33,8 @@ class Project < ActiveRecord::Base
|
|||||||
has_many :member_principals, :class_name => 'Member',
|
has_many :member_principals, :class_name => 'Member',
|
||||||
:include => :principal,
|
:include => :principal,
|
||||||
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
|
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
|
||||||
|
has_many :users, :through => :members
|
||||||
|
has_many :principals, :through => :member_principals, :source => :principal
|
||||||
|
|
||||||
has_many :enabled_modules, :dependent => :delete_all
|
has_many :enabled_modules, :dependent => :delete_all
|
||||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||||
@@ -186,7 +188,7 @@ class Project < ActiveRecord::Base
|
|||||||
else
|
else
|
||||||
statement_by_role = {}
|
statement_by_role = {}
|
||||||
unless options[:member]
|
unless options[:member]
|
||||||
role = user.builtin_role
|
role = user.logged? ? Role.non_member : Role.anonymous
|
||||||
if role.allowed_to?(permission)
|
if role.allowed_to?(permission)
|
||||||
statement_by_role[role] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
statement_by_role[role] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
||||||
end
|
end
|
||||||
@@ -213,14 +215,6 @@ class Project < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def principals
|
|
||||||
@principals ||= Principal.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).uniq
|
|
||||||
end
|
|
||||||
|
|
||||||
def users
|
|
||||||
@users ||= User.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).uniq
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns the Systemwide and project specific activities
|
# Returns the Systemwide and project specific activities
|
||||||
def activities(include_inactive=false)
|
def activities(include_inactive=false)
|
||||||
if include_inactive
|
if include_inactive
|
||||||
@@ -293,8 +287,6 @@ class Project < ActiveRecord::Base
|
|||||||
|
|
||||||
alias :base_reload :reload
|
alias :base_reload :reload
|
||||||
def reload(*args)
|
def reload(*args)
|
||||||
@principals = nil
|
|
||||||
@users = nil
|
|
||||||
@shared_versions = nil
|
@shared_versions = nil
|
||||||
@rolled_up_versions = nil
|
@rolled_up_versions = nil
|
||||||
@rolled_up_trackers = nil
|
@rolled_up_trackers = nil
|
||||||
@@ -451,29 +443,26 @@ class Project < ActiveRecord::Base
|
|||||||
# Returns a scope of the Versions on subprojects
|
# Returns a scope of the Versions on subprojects
|
||||||
def rolled_up_versions
|
def rolled_up_versions
|
||||||
@rolled_up_versions ||=
|
@rolled_up_versions ||=
|
||||||
Version.
|
Version.scoped(:include => :project,
|
||||||
includes(:project).
|
:conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> #{STATUS_ARCHIVED}", lft, rgt])
|
||||||
where("#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> ?", lft, rgt, STATUS_ARCHIVED)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a scope of the Versions used by the project
|
# Returns a scope of the Versions used by the project
|
||||||
def shared_versions
|
def shared_versions
|
||||||
if new_record?
|
if new_record?
|
||||||
Version.
|
Version.scoped(:include => :project,
|
||||||
includes(:project).
|
:conditions => "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND #{Version.table_name}.sharing = 'system'")
|
||||||
where("#{Project.table_name}.status <> ? AND #{Version.table_name}.sharing = 'system'", STATUS_ARCHIVED)
|
|
||||||
else
|
else
|
||||||
@shared_versions ||= begin
|
@shared_versions ||= begin
|
||||||
r = root? ? self : root
|
r = root? ? self : root
|
||||||
Version.
|
Version.scoped(:include => :project,
|
||||||
includes(:project).
|
:conditions => "#{Project.table_name}.id = #{id}" +
|
||||||
where("#{Project.table_name}.id = #{id}" +
|
" OR (#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND (" +
|
||||||
" OR (#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND (" +
|
" #{Version.table_name}.sharing = 'system'" +
|
||||||
" #{Version.table_name}.sharing = 'system'" +
|
" OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" +
|
||||||
" OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" +
|
" OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" +
|
||||||
" OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" +
|
" OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" +
|
||||||
" OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" +
|
"))")
|
||||||
"))")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -513,14 +502,10 @@ class Project < ActiveRecord::Base
|
|||||||
members.select {|m| m.principal.present? && (m.mail_notification? || m.principal.mail_notification == 'all')}.collect {|m| m.principal}
|
members.select {|m| m.principal.present? && (m.mail_notification? || m.principal.mail_notification == 'all')}.collect {|m| m.principal}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a scope of all custom fields enabled for project issues
|
# Returns an array of all custom fields enabled for project issues
|
||||||
# (explictly associated custom fields and custom fields enabled for all projects)
|
# (explictly associated custom fields and custom fields enabled for all projects)
|
||||||
def all_issue_custom_fields
|
def all_issue_custom_fields
|
||||||
@all_issue_custom_fields ||= IssueCustomField.
|
@all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq.sort
|
||||||
sorted.
|
|
||||||
where("is_for_all = ? OR id IN (SELECT DISTINCT cfp.custom_field_id" +
|
|
||||||
" FROM #{table_name_prefix}custom_fields_projects#{table_name_suffix} cfp" +
|
|
||||||
" WHERE cfp.project_id = ?)", true, id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of all custom fields enabled for project time entries
|
# Returns an array of all custom fields enabled for project time entries
|
||||||
@@ -961,7 +946,7 @@ class Project < ActiveRecord::Base
|
|||||||
|
|
||||||
def allowed_permissions
|
def allowed_permissions
|
||||||
@allowed_permissions ||= begin
|
@allowed_permissions ||= begin
|
||||||
module_names = enabled_modules.loaded? ? enabled_modules.map(&:name) : enabled_modules.pluck(:name)
|
module_names = enabled_modules.all(:select => :name).collect {|m| m.name}
|
||||||
Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name}
|
Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+44
-83
@@ -81,12 +81,8 @@ class QueryCustomFieldColumn < QueryColumn
|
|||||||
end
|
end
|
||||||
|
|
||||||
def value(object)
|
def value(object)
|
||||||
if custom_field.visible_by?(object.project, User.current)
|
cv = object.custom_values.select {|v| v.custom_field_id == @cf.id}.collect {|v| @cf.cast_value(v.value)}
|
||||||
cv = object.custom_values.select {|v| v.custom_field_id == @cf.id}.collect {|v| @cf.cast_value(v.value)}
|
cv.size > 1 ? cv.sort {|a,b| a.to_s <=> b.to_s} : cv.first
|
||||||
cv.size > 1 ? cv.sort {|a,b| a.to_s <=> b.to_s} : cv.first
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def css_classes
|
def css_classes
|
||||||
@@ -120,33 +116,17 @@ class Query < ActiveRecord::Base
|
|||||||
class StatementInvalid < ::ActiveRecord::StatementInvalid
|
class StatementInvalid < ::ActiveRecord::StatementInvalid
|
||||||
end
|
end
|
||||||
|
|
||||||
VISIBILITY_PRIVATE = 0
|
|
||||||
VISIBILITY_ROLES = 1
|
|
||||||
VISIBILITY_PUBLIC = 2
|
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
has_and_belongs_to_many :roles, :join_table => "#{table_name_prefix}queries_roles#{table_name_suffix}", :foreign_key => "query_id"
|
|
||||||
serialize :filters
|
serialize :filters
|
||||||
serialize :column_names
|
serialize :column_names
|
||||||
serialize :sort_criteria, Array
|
serialize :sort_criteria, Array
|
||||||
serialize :options, Hash
|
|
||||||
|
|
||||||
attr_protected :project_id, :user_id
|
attr_protected :project_id, :user_id
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_length_of :name, :maximum => 255
|
validates_length_of :name, :maximum => 255
|
||||||
validates :visibility, :inclusion => { :in => [VISIBILITY_PUBLIC, VISIBILITY_ROLES, VISIBILITY_PRIVATE] }
|
|
||||||
validate :validate_query_filters
|
validate :validate_query_filters
|
||||||
validate do |query|
|
|
||||||
errors.add(:base, l(:label_role_plural) + ' ' + l('activerecord.errors.messages.blank')) if query.visibility == VISIBILITY_ROLES && roles.blank?
|
|
||||||
end
|
|
||||||
|
|
||||||
after_save do |query|
|
|
||||||
if query.visibility_changed? && query.visibility != VISIBILITY_ROLES
|
|
||||||
query.roles.clear
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class_attribute :operators
|
class_attribute :operators
|
||||||
self.operators = {
|
self.operators = {
|
||||||
@@ -265,9 +245,9 @@ class Query < ActiveRecord::Base
|
|||||||
def editable_by?(user)
|
def editable_by?(user)
|
||||||
return false unless user
|
return false unless user
|
||||||
# Admin can edit them all and regular users can edit their private queries
|
# Admin can edit them all and regular users can edit their private queries
|
||||||
return true if user.admin? || (is_private? && self.user_id == user.id)
|
return true if user.admin? || (!is_public && self.user_id == user.id)
|
||||||
# Members can not edit public queries that are for all project (only admin is allowed to)
|
# Members can not edit public queries that are for all project (only admin is allowed to)
|
||||||
is_public? && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
|
is_public && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
def trackers
|
def trackers
|
||||||
@@ -449,10 +429,6 @@ class Query < ActiveRecord::Base
|
|||||||
column_names && column_names.include?(column.is_a?(QueryColumn) ? column.name : column)
|
column_names && column_names.include?(column.is_a?(QueryColumn) ? column.name : column)
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_custom_field_column?
|
|
||||||
columns.any? {|column| column.is_a? QueryCustomFieldColumn}
|
|
||||||
end
|
|
||||||
|
|
||||||
def has_default_columns?
|
def has_default_columns?
|
||||||
column_names.nil? || column_names.empty?
|
column_names.nil? || column_names.empty?
|
||||||
end
|
end
|
||||||
@@ -569,11 +545,6 @@ class Query < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end if filters and valid?
|
end if filters and valid?
|
||||||
|
|
||||||
if (c = group_by_column) && c.is_a?(QueryCustomFieldColumn)
|
|
||||||
# Excludes results for which the grouped custom field is not visible
|
|
||||||
filters_clauses << c.custom_field.visibility_by_project_condition
|
|
||||||
end
|
|
||||||
|
|
||||||
filters_clauses << project_statement
|
filters_clauses << project_statement
|
||||||
filters_clauses.reject!(&:blank?)
|
filters_clauses.reject!(&:blank?)
|
||||||
|
|
||||||
@@ -610,10 +581,7 @@ class Query < ActiveRecord::Base
|
|||||||
if operator =~ /[<>]/
|
if operator =~ /[<>]/
|
||||||
where = "(#{where}) AND #{db_table}.#{db_field} <> ''"
|
where = "(#{where}) AND #{db_table}.#{db_field} <> ''"
|
||||||
end
|
end
|
||||||
"#{queried_table_name}.#{customized_key} #{not_in} IN (" +
|
"#{queried_table_name}.#{customized_key} #{not_in} IN (SELECT #{customized_class.table_name}.id FROM #{customized_class.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='#{customized_class}' AND #{db_table}.customized_id=#{customized_class.table_name}.id AND #{db_table}.custom_field_id=#{custom_field_id} WHERE #{where})"
|
||||||
"SELECT #{customized_class.table_name}.id FROM #{customized_class.table_name}" +
|
|
||||||
" LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='#{customized_class}' AND #{db_table}.customized_id=#{customized_class.table_name}.id AND #{db_table}.custom_field_id=#{custom_field_id}" +
|
|
||||||
" WHERE (#{where}) AND (#{filter[:field].visibility_by_project_condition}))"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Helper method to generate the WHERE sql for a +field+, +operator+ and a +value+
|
# Helper method to generate the WHERE sql for a +field+, +operator+ and a +value+
|
||||||
@@ -762,61 +730,54 @@ class Query < ActiveRecord::Base
|
|||||||
return sql
|
return sql
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds a filter for the given custom field
|
def add_custom_fields_filters(custom_fields, assoc=nil)
|
||||||
def add_custom_field_filter(field, assoc=nil)
|
return unless custom_fields.present?
|
||||||
case field.field_format
|
|
||||||
when "text"
|
custom_fields.select(&:is_filter?).sort.each do |field|
|
||||||
options = { :type => :text }
|
case field.field_format
|
||||||
when "list"
|
when "text"
|
||||||
options = { :type => :list_optional, :values => field.possible_values }
|
options = { :type => :text }
|
||||||
when "date"
|
when "list"
|
||||||
options = { :type => :date }
|
options = { :type => :list_optional, :values => field.possible_values }
|
||||||
when "bool"
|
when "date"
|
||||||
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]] }
|
options = { :type => :date }
|
||||||
when "int"
|
when "bool"
|
||||||
options = { :type => :integer }
|
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]] }
|
||||||
when "float"
|
when "int"
|
||||||
options = { :type => :float }
|
options = { :type => :integer }
|
||||||
when "user", "version"
|
when "float"
|
||||||
return unless project
|
options = { :type => :float }
|
||||||
values = field.possible_values_options(project)
|
when "user", "version"
|
||||||
if User.current.logged? && field.field_format == 'user'
|
next unless project
|
||||||
values.unshift ["<< #{l(:label_me)} >>", "me"]
|
values = field.possible_values_options(project)
|
||||||
|
if User.current.logged? && field.field_format == 'user'
|
||||||
|
values.unshift ["<< #{l(:label_me)} >>", "me"]
|
||||||
|
end
|
||||||
|
options = { :type => :list_optional, :values => values }
|
||||||
|
else
|
||||||
|
options = { :type => :string }
|
||||||
end
|
end
|
||||||
options = { :type => :list_optional, :values => values }
|
filter_id = "cf_#{field.id}"
|
||||||
else
|
filter_name = field.name
|
||||||
options = { :type => :string }
|
if assoc.present?
|
||||||
end
|
filter_id = "#{assoc}.#{filter_id}"
|
||||||
filter_id = "cf_#{field.id}"
|
filter_name = l("label_attribute_of_#{assoc}", :name => filter_name)
|
||||||
filter_name = field.name
|
end
|
||||||
if assoc.present?
|
add_available_filter filter_id, options.merge({
|
||||||
filter_id = "#{assoc}.#{filter_id}"
|
:name => filter_name,
|
||||||
filter_name = l("label_attribute_of_#{assoc}", :name => filter_name)
|
:format => field.field_format,
|
||||||
end
|
:field => field
|
||||||
add_available_filter filter_id, options.merge({
|
})
|
||||||
:name => filter_name,
|
|
||||||
:format => field.field_format,
|
|
||||||
:field => field
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
# Adds filters for the given custom fields scope
|
|
||||||
def add_custom_fields_filters(scope, assoc=nil)
|
|
||||||
scope.visible.where(:is_filter => true).sorted.each do |field|
|
|
||||||
add_custom_field_filter(field, assoc)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds filters for the given associations custom fields
|
|
||||||
def add_associations_custom_fields_filters(*associations)
|
def add_associations_custom_fields_filters(*associations)
|
||||||
fields_by_class = CustomField.visible.where(:is_filter => true).group_by(&:class)
|
fields_by_class = CustomField.where(:is_filter => true).group_by(&:class)
|
||||||
associations.each do |assoc|
|
associations.each do |assoc|
|
||||||
association_klass = queried_class.reflect_on_association(assoc).klass
|
association_klass = queried_class.reflect_on_association(assoc).klass
|
||||||
fields_by_class.each do |field_class, fields|
|
fields_by_class.each do |field_class, fields|
|
||||||
if field_class.customized_class <= association_klass
|
if field_class.customized_class <= association_klass
|
||||||
fields.sort.each do |field|
|
add_custom_fields_filters(fields, assoc)
|
||||||
add_custom_field_filter(field, assoc)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+13
-12
@@ -249,18 +249,19 @@ class Repository < ActiveRecord::Base
|
|||||||
# Default behaviour is to search in cached changesets
|
# Default behaviour is to search in cached changesets
|
||||||
def latest_changesets(path, rev, limit=10)
|
def latest_changesets(path, rev, limit=10)
|
||||||
if path.blank?
|
if path.blank?
|
||||||
changesets.
|
changesets.find(
|
||||||
reorder("#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC").
|
:all,
|
||||||
limit(limit).
|
:include => :user,
|
||||||
preload(:user).
|
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
|
||||||
all
|
:limit => limit)
|
||||||
else
|
else
|
||||||
filechanges.
|
filechanges.find(
|
||||||
where("path = ?", path.with_leading_slash).
|
:all,
|
||||||
reorder("#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC").
|
:include => {:changeset => :user},
|
||||||
limit(limit).
|
:conditions => ["path = ?", path.with_leading_slash],
|
||||||
preload(:changeset => :user).
|
:order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
|
||||||
collect(&:changeset)
|
:limit => limit
|
||||||
|
).collect(&:changeset)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -392,7 +393,7 @@ class Repository < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_as_default?
|
def set_as_default?
|
||||||
new_record? && project && Repository.where(:project_id => project.id).empty?
|
new_record? && project && !Repository.first(:conditions => {:project_id => project.id})
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|||||||
@@ -68,11 +68,15 @@ class Repository::Bazaar < Repository
|
|||||||
full_path = File.join(root_url, e.path)
|
full_path = File.join(root_url, e.path)
|
||||||
e.size = File.stat(full_path).size if File.file?(full_path)
|
e.size = File.stat(full_path).size if File.file?(full_path)
|
||||||
end
|
end
|
||||||
c = Change.
|
c = Change.find(
|
||||||
includes(:changeset).
|
:first,
|
||||||
where("#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?", e.lastrev.revision, id).
|
:include => :changeset,
|
||||||
order("#{Changeset.table_name}.revision DESC").
|
:conditions => [
|
||||||
first
|
"#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?",
|
||||||
|
e.lastrev.revision,
|
||||||
|
id
|
||||||
|
],
|
||||||
|
:order => "#{Changeset.table_name}.revision DESC")
|
||||||
if c
|
if c
|
||||||
e.lastrev.identifier = c.changeset.revision
|
e.lastrev.identifier = c.changeset.revision
|
||||||
e.lastrev.name = c.changeset.revision
|
e.lastrev.name = c.changeset.revision
|
||||||
|
|||||||
@@ -143,11 +143,14 @@ class Repository::Cvs < Repository
|
|||||||
)
|
)
|
||||||
cmt = Changeset.normalize_comments(revision.message, repo_log_encoding)
|
cmt = Changeset.normalize_comments(revision.message, repo_log_encoding)
|
||||||
author_utf8 = Changeset.to_utf8(revision.author, repo_log_encoding)
|
author_utf8 = Changeset.to_utf8(revision.author, repo_log_encoding)
|
||||||
cs = changesets.where(
|
cs = changesets.find(
|
||||||
:committed_on => tmp_time - time_delta .. tmp_time + time_delta,
|
:first,
|
||||||
:committer => author_utf8,
|
:conditions => {
|
||||||
:comments => cmt
|
:committed_on => tmp_time - time_delta .. tmp_time + time_delta,
|
||||||
).first
|
:committer => author_utf8,
|
||||||
|
:comments => cmt
|
||||||
|
}
|
||||||
|
)
|
||||||
# create a new changeset....
|
# create a new changeset....
|
||||||
unless cs
|
unless cs
|
||||||
# we use a temporaray revision number here (just for inserting)
|
# we use a temporaray revision number here (just for inserting)
|
||||||
@@ -182,10 +185,10 @@ class Repository::Cvs < Repository
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Renumber new changesets in chronological order
|
# Renumber new changesets in chronological order
|
||||||
Changeset.
|
Changeset.all(
|
||||||
order('committed_on ASC, id ASC').
|
:order => 'committed_on ASC, id ASC',
|
||||||
where("repository_id = ? AND revision LIKE 'tmp%'", id).
|
:conditions => ["repository_id = ? AND revision LIKE 'tmp%'", id]
|
||||||
each do |changeset|
|
).each do |changeset|
|
||||||
changeset.update_attribute :revision, next_revision_number
|
changeset.update_attribute :revision, next_revision_number
|
||||||
end
|
end
|
||||||
end # transaction
|
end # transaction
|
||||||
|
|||||||
@@ -191,8 +191,13 @@ class Repository::Git < Repository
|
|||||||
offset = 0
|
offset = 0
|
||||||
revisions_copy = revisions.clone # revisions will change
|
revisions_copy = revisions.clone # revisions will change
|
||||||
while offset < revisions_copy.size
|
while offset < revisions_copy.size
|
||||||
scmids = revisions_copy.slice(offset, limit).map{|x| x.scmid}
|
recent_changesets_slice = changesets.find(
|
||||||
recent_changesets_slice = changesets.where(:scmid => scmids).all
|
:all,
|
||||||
|
:conditions => [
|
||||||
|
'scmid IN (?)',
|
||||||
|
revisions_copy.slice(offset, limit).map{|x| x.scmid}
|
||||||
|
]
|
||||||
|
)
|
||||||
# Subtract revisions that redmine already knows about
|
# Subtract revisions that redmine already knows about
|
||||||
recent_revisions = recent_changesets_slice.map{|c| c.scmid}
|
recent_revisions = recent_changesets_slice.map{|c| c.scmid}
|
||||||
revisions.reject!{|r| recent_revisions.include?(r.scmid)}
|
revisions.reject!{|r| recent_revisions.include?(r.scmid)}
|
||||||
@@ -241,7 +246,13 @@ class Repository::Git < Repository
|
|||||||
revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false)
|
revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false)
|
||||||
return [] if revisions.nil? || revisions.empty?
|
return [] if revisions.nil? || revisions.empty?
|
||||||
|
|
||||||
changesets.where(:scmid => revisions.map {|c| c.scmid}).all
|
changesets.find(
|
||||||
|
:all,
|
||||||
|
:conditions => [
|
||||||
|
"scmid IN (?)",
|
||||||
|
revisions.map!{|c| c.scmid}
|
||||||
|
]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_extra_info_of_changesets
|
def clear_extra_info_of_changesets
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ require 'redmine/scm/adapters/subversion_adapter'
|
|||||||
class Repository::Subversion < Repository
|
class Repository::Subversion < Repository
|
||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
validates_format_of :url, :with => %r{\A(http|https|svn(\+[^\s:\/\\]+)?|file):\/\/.+}i
|
validates_format_of :url, :with => /\A(http|https|svn(\+[^\s:\/\\]+)?|file):\/\/.+/i
|
||||||
|
|
||||||
def self.scm_adapter_class
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::SubversionAdapter
|
Redmine::Scm::Adapters::SubversionAdapter
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ class Role < ActiveRecord::Base
|
|||||||
WorkflowRule.copy(nil, source_role, nil, proxy_association.owner)
|
WorkflowRule.copy(nil, source_role, nil, proxy_association.owner)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
has_and_belongs_to_many :custom_fields, :join_table => "#{table_name_prefix}custom_fields_roles#{table_name_suffix}", :foreign_key => "role_id"
|
|
||||||
|
|
||||||
has_many :member_roles, :dependent => :destroy
|
has_many :member_roles, :dependent => :destroy
|
||||||
has_many :members, :through => :member_roles
|
has_many :members, :through => :member_roles
|
||||||
|
|||||||
+1
-73
@@ -132,87 +132,15 @@ class Setting < ActiveRecord::Base
|
|||||||
def self.#{name}=(value)
|
def self.#{name}=(value)
|
||||||
self[:#{name}] = value
|
self[:#{name}] = value
|
||||||
end
|
end
|
||||||
END_SRC
|
END_SRC
|
||||||
class_eval src, __FILE__, __LINE__
|
class_eval src, __FILE__, __LINE__
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets a setting value from params
|
|
||||||
def self.set_from_params(name, params)
|
|
||||||
params = params.dup
|
|
||||||
params.delete_if {|v| v.blank? } if params.is_a?(Array)
|
|
||||||
|
|
||||||
m = "#{name}_from_params"
|
|
||||||
if respond_to? m
|
|
||||||
self[name.to_sym] = send m, params
|
|
||||||
else
|
|
||||||
self[name.to_sym] = params
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a hash suitable for commit_update_keywords setting
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# params = {:keywords => ['fixes', 'closes'], :status_id => ["3", "5"], :done_ratio => ["", "100"]}
|
|
||||||
# Setting.commit_update_keywords_from_params(params)
|
|
||||||
# # => [{'keywords => 'fixes', 'status_id' => "3"}, {'keywords => 'closes', 'status_id' => "5", 'done_ratio' => "100"}]
|
|
||||||
def self.commit_update_keywords_from_params(params)
|
|
||||||
s = []
|
|
||||||
if params.is_a?(Hash) && params.key?(:keywords) && params.values.all? {|v| v.is_a? Array}
|
|
||||||
attributes = params.except(:keywords).keys
|
|
||||||
params[:keywords].each_with_index do |keywords, i|
|
|
||||||
next if keywords.blank?
|
|
||||||
s << attributes.inject({}) {|h, a|
|
|
||||||
value = params[a][i].to_s
|
|
||||||
h[a.to_s] = value if value.present?
|
|
||||||
h
|
|
||||||
}.merge('keywords' => keywords)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
s
|
|
||||||
end
|
|
||||||
|
|
||||||
# Helper that returns an array based on per_page_options setting
|
# Helper that returns an array based on per_page_options setting
|
||||||
def self.per_page_options_array
|
def self.per_page_options_array
|
||||||
per_page_options.split(%r{[\s,]}).collect(&:to_i).select {|n| n > 0}.sort
|
per_page_options.split(%r{[\s,]}).collect(&:to_i).select {|n| n > 0}.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
# Helper that returns a Hash with single update keywords as keys
|
|
||||||
def self.commit_update_keywords_array
|
|
||||||
a = []
|
|
||||||
if commit_update_keywords.is_a?(Array)
|
|
||||||
commit_update_keywords.each do |rule|
|
|
||||||
next unless rule.is_a?(Hash)
|
|
||||||
rule = rule.dup
|
|
||||||
rule.delete_if {|k, v| v.blank?}
|
|
||||||
keywords = rule['keywords'].to_s.downcase.split(",").map(&:strip).reject(&:blank?)
|
|
||||||
next if keywords.empty?
|
|
||||||
a << rule.merge('keywords' => keywords)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
a
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.commit_fix_keywords
|
|
||||||
ActiveSupport::Deprecation.warn "Setting.commit_fix_keywords is deprecated and will be removed in Redmine 3"
|
|
||||||
if commit_update_keywords.is_a?(Array)
|
|
||||||
commit_update_keywords.first && commit_update_keywords.first['keywords']
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.commit_fix_status_id
|
|
||||||
ActiveSupport::Deprecation.warn "Setting.commit_fix_status_id is deprecated and will be removed in Redmine 3"
|
|
||||||
if commit_update_keywords.is_a?(Array)
|
|
||||||
commit_update_keywords.first && commit_update_keywords.first['status_id']
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.commit_fix_done_ratio
|
|
||||||
ActiveSupport::Deprecation.warn "Setting.commit_fix_done_ratio is deprecated and will be removed in Redmine 3"
|
|
||||||
if commit_update_keywords.is_a?(Array)
|
|
||||||
commit_update_keywords.first && commit_update_keywords.first['done_ratio']
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.openid?
|
def self.openid?
|
||||||
Object.const_defined?(:OpenID) && self[:openid].to_i > 0
|
Object.const_defined?(:OpenID) && self[:openid].to_i > 0
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -84,15 +84,15 @@ class TimeEntryQuery < Query
|
|||||||
add_available_filter "comments", :type => :text
|
add_available_filter "comments", :type => :text
|
||||||
add_available_filter "hours", :type => :float
|
add_available_filter "hours", :type => :float
|
||||||
|
|
||||||
add_custom_fields_filters(TimeEntryCustomField)
|
add_custom_fields_filters(TimeEntryCustomField.where(:is_filter => true).all)
|
||||||
add_associations_custom_fields_filters :project, :issue, :user
|
add_associations_custom_fields_filters :project, :issue, :user
|
||||||
end
|
end
|
||||||
|
|
||||||
def available_columns
|
def available_columns
|
||||||
return @available_columns if @available_columns
|
return @available_columns if @available_columns
|
||||||
@available_columns = self.class.available_columns.dup
|
@available_columns = self.class.available_columns.dup
|
||||||
@available_columns += TimeEntryCustomField.visible.all.map {|cf| QueryCustomFieldColumn.new(cf) }
|
@available_columns += TimeEntryCustomField.all.map {|cf| QueryCustomFieldColumn.new(cf) }
|
||||||
@available_columns += IssueCustomField.visible.all.map {|cf| QueryAssociationCustomFieldColumn.new(:issue, cf) }
|
@available_columns += IssueCustomField.all.map {|cf| QueryAssociationCustomFieldColumn.new(:issue, cf) }
|
||||||
@available_columns
|
@available_columns
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+28
-64
@@ -81,7 +81,7 @@ class User < Principal
|
|||||||
|
|
||||||
acts_as_customizable
|
acts_as_customizable
|
||||||
|
|
||||||
attr_accessor :password, :password_confirmation, :generate_password
|
attr_accessor :password, :password_confirmation
|
||||||
attr_accessor :last_before_login_on
|
attr_accessor :last_before_login_on
|
||||||
# Prevents unauthorized assignments
|
# Prevents unauthorized assignments
|
||||||
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
|
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
|
||||||
@@ -103,9 +103,8 @@ class User < Principal
|
|||||||
validate :validate_password_length
|
validate :validate_password_length
|
||||||
|
|
||||||
before_create :set_mail_notification
|
before_create :set_mail_notification
|
||||||
before_save :generate_password_if_needed, :update_hashed_password
|
before_save :update_hashed_password
|
||||||
before_destroy :remove_references_before_destroy
|
before_destroy :remove_references_before_destroy
|
||||||
after_save :update_notified_project_ids
|
|
||||||
|
|
||||||
scope :in_group, lambda {|group|
|
scope :in_group, lambda {|group|
|
||||||
group_id = group.is_a?(Group) ? group.id : group.to_i
|
group_id = group.is_a?(Group) ? group.id : group.to_i
|
||||||
@@ -134,9 +133,6 @@ class User < Principal
|
|||||||
@name = nil
|
@name = nil
|
||||||
@projects_by_role = nil
|
@projects_by_role = nil
|
||||||
@membership_by_project_id = nil
|
@membership_by_project_id = nil
|
||||||
@notified_projects_ids = nil
|
|
||||||
@notified_projects_ids_changed = false
|
|
||||||
@builtin_role = nil
|
|
||||||
base_reload(*args)
|
base_reload(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -158,7 +154,7 @@ class User < Principal
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Returns the user that matches provided login and password, or nil
|
# Returns the user that matches provided login and password, or nil
|
||||||
def self.try_to_login(login, password, active_only=true)
|
def self.try_to_login(login, password)
|
||||||
login = login.to_s
|
login = login.to_s
|
||||||
password = password.to_s
|
password = password.to_s
|
||||||
|
|
||||||
@@ -167,8 +163,8 @@ class User < Principal
|
|||||||
user = find_by_login(login)
|
user = find_by_login(login)
|
||||||
if user
|
if user
|
||||||
# user is already in local database
|
# user is already in local database
|
||||||
|
return nil unless user.active?
|
||||||
return nil unless user.check_password?(password)
|
return nil unless user.check_password?(password)
|
||||||
return nil if !user.active? && active_only
|
|
||||||
else
|
else
|
||||||
# user is not yet registered, try to authenticate with available sources
|
# user is not yet registered, try to authenticate with available sources
|
||||||
attrs = AuthSource.authenticate(login, password)
|
attrs = AuthSource.authenticate(login, password)
|
||||||
@@ -182,7 +178,7 @@ class User < Principal
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
user.update_column(:last_login_on, Time.now) if user && !user.new_record? && user.active?
|
user.update_column(:last_login_on, Time.now) if user && !user.new_record?
|
||||||
user
|
user
|
||||||
rescue => text
|
rescue => text
|
||||||
raise text
|
raise text
|
||||||
@@ -280,20 +276,13 @@ class User < Principal
|
|||||||
return auth_source.allow_password_changes?
|
return auth_source.allow_password_changes?
|
||||||
end
|
end
|
||||||
|
|
||||||
def must_change_password?
|
# Generate and set a random password. Useful for automated user creation
|
||||||
must_change_passwd? && change_password_allowed?
|
# Based on Token#generate_token_value
|
||||||
end
|
#
|
||||||
|
def random_password
|
||||||
def generate_password?
|
|
||||||
generate_password == '1' || generate_password == true
|
|
||||||
end
|
|
||||||
|
|
||||||
# Generate and set a random password on given length
|
|
||||||
def random_password(length=40)
|
|
||||||
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
||||||
chars -= %w(0 O 1 l)
|
|
||||||
password = ''
|
password = ''
|
||||||
length.times {|i| password << chars[SecureRandom.random_number(chars.size)] }
|
40.times { |i| password << chars[rand(chars.size-1)] }
|
||||||
self.password = password
|
self.password = password
|
||||||
self.password_confirmation = password
|
self.password_confirmation = password
|
||||||
self
|
self
|
||||||
@@ -333,20 +322,12 @@ class User < Principal
|
|||||||
end
|
end
|
||||||
|
|
||||||
def notified_project_ids=(ids)
|
def notified_project_ids=(ids)
|
||||||
@notified_projects_ids_changed = true
|
Member.update_all("mail_notification = #{connection.quoted_false}", ['user_id = ?', id])
|
||||||
@notified_projects_ids = ids
|
Member.update_all("mail_notification = #{connection.quoted_true}", ['user_id = ? AND project_id IN (?)', id, ids]) if ids && !ids.empty?
|
||||||
|
@notified_projects_ids = nil
|
||||||
|
notified_projects_ids
|
||||||
end
|
end
|
||||||
|
|
||||||
# Updates per project notifications (after_save callback)
|
|
||||||
def update_notified_project_ids
|
|
||||||
if @notified_projects_ids_changed
|
|
||||||
ids = (mail_notification == 'selected' ? Array.wrap(notified_projects_ids).reject(&:blank?) : [])
|
|
||||||
members.update_all(:mail_notification => false)
|
|
||||||
members.where(:project_id => ids).update_all(:mail_notification => true) if ids.any?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
private :update_notified_project_ids
|
|
||||||
|
|
||||||
def valid_notification_options
|
def valid_notification_options
|
||||||
self.class.valid_notification_options(self)
|
self.class.valid_notification_options(self)
|
||||||
end
|
end
|
||||||
@@ -447,20 +428,23 @@ class User < Principal
|
|||||||
@membership_by_project_id[project_id]
|
@membership_by_project_id[project_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the user's bult-in role
|
|
||||||
def builtin_role
|
|
||||||
@builtin_role ||= Role.non_member
|
|
||||||
end
|
|
||||||
|
|
||||||
# Return user's roles for project
|
# Return user's roles for project
|
||||||
def roles_for_project(project)
|
def roles_for_project(project)
|
||||||
roles = []
|
roles = []
|
||||||
# No role on archived projects
|
# No role on archived projects
|
||||||
return roles if project.nil? || project.archived?
|
return roles if project.nil? || project.archived?
|
||||||
if membership = membership(project)
|
if logged?
|
||||||
roles = membership.roles
|
# Find project membership
|
||||||
|
membership = membership(project)
|
||||||
|
if membership
|
||||||
|
roles = membership.roles
|
||||||
|
else
|
||||||
|
@role_non_member ||= Role.non_member
|
||||||
|
roles << @role_non_member
|
||||||
|
end
|
||||||
else
|
else
|
||||||
roles << builtin_role
|
@role_anonymous ||= Role.anonymous
|
||||||
|
roles << @role_anonymous
|
||||||
end
|
end
|
||||||
roles
|
roles
|
||||||
end
|
end
|
||||||
@@ -552,7 +536,7 @@ class User < Principal
|
|||||||
allowed_to?(action, nil, options.reverse_merge(:global => true), &block)
|
allowed_to?(action, nil, options.reverse_merge(:global => true), &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if the user is allowed to delete the user's own account
|
# Returns true if the user is allowed to delete his own account
|
||||||
def own_account_deletable?
|
def own_account_deletable?
|
||||||
Setting.unsubscribe? &&
|
Setting.unsubscribe? &&
|
||||||
(!admin? || User.active.where("admin = ? AND id <> ?", true, id).exists?)
|
(!admin? || User.active.where("admin = ? AND id <> ?", true, id).exists?)
|
||||||
@@ -563,7 +547,6 @@ class User < Principal
|
|||||||
'lastname',
|
'lastname',
|
||||||
'mail',
|
'mail',
|
||||||
'mail_notification',
|
'mail_notification',
|
||||||
'notified_project_ids',
|
|
||||||
'language',
|
'language',
|
||||||
'custom_field_values',
|
'custom_field_values',
|
||||||
'custom_fields',
|
'custom_fields',
|
||||||
@@ -571,8 +554,6 @@ class User < Principal
|
|||||||
|
|
||||||
safe_attributes 'status',
|
safe_attributes 'status',
|
||||||
'auth_source_id',
|
'auth_source_id',
|
||||||
'generate_password',
|
|
||||||
'must_change_passwd',
|
|
||||||
:if => lambda {|user, current_user| current_user.admin?}
|
:if => lambda {|user, current_user| current_user.admin?}
|
||||||
|
|
||||||
safe_attributes 'group_ids',
|
safe_attributes 'group_ids',
|
||||||
@@ -642,7 +623,6 @@ class User < Principal
|
|||||||
protected
|
protected
|
||||||
|
|
||||||
def validate_password_length
|
def validate_password_length
|
||||||
return if password.blank? && generate_password?
|
|
||||||
# Password length validation based on setting
|
# Password length validation based on setting
|
||||||
if !password.nil? && password.size < Setting.password_min_length.to_i
|
if !password.nil? && password.size < Setting.password_min_length.to_i
|
||||||
errors.add(:password, :too_short, :count => Setting.password_min_length.to_i)
|
errors.add(:password, :too_short, :count => Setting.password_min_length.to_i)
|
||||||
@@ -651,13 +631,6 @@ class User < Principal
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_password_if_needed
|
|
||||||
if generate_password? && auth_source.nil?
|
|
||||||
length = [Setting.password_min_length.to_i + 2, 10].max
|
|
||||||
random_password(length)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Removes references that are not handled by associations
|
# Removes references that are not handled by associations
|
||||||
# Things that are not deleted are reassociated with the anonymous user
|
# Things that are not deleted are reassociated with the anonymous user
|
||||||
def remove_references_before_destroy
|
def remove_references_before_destroy
|
||||||
@@ -674,7 +647,7 @@ class User < Principal
|
|||||||
Message.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
|
Message.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
|
||||||
News.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
|
News.update_all ['author_id = ?', substitute.id], ['author_id = ?', id]
|
||||||
# Remove private queries and keep public ones
|
# Remove private queries and keep public ones
|
||||||
::Query.delete_all ['user_id = ? AND visibility = ?', id, ::Query::VISIBILITY_PRIVATE]
|
::Query.delete_all ['user_id = ? AND is_public = ?', id, false]
|
||||||
::Query.update_all ['user_id = ?', substitute.id], ['user_id = ?', id]
|
::Query.update_all ['user_id = ?', substitute.id], ['user_id = ?', id]
|
||||||
TimeEntry.update_all ['user_id = ?', substitute.id], ['user_id = ?', id]
|
TimeEntry.update_all ['user_id = ?', substitute.id], ['user_id = ?', id]
|
||||||
Token.delete_all ['user_id = ?', id]
|
Token.delete_all ['user_id = ?', id]
|
||||||
@@ -719,16 +692,7 @@ class AnonymousUser < User
|
|||||||
UserPreference.new(:user => self)
|
UserPreference.new(:user => self)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the user's bult-in role
|
def member_of?(project)
|
||||||
def builtin_role
|
|
||||||
@builtin_role ||= Role.anonymous
|
|
||||||
end
|
|
||||||
|
|
||||||
def membership(*args)
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def member_of?(*args)
|
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -23,19 +23,6 @@ class Watcher < ActiveRecord::Base
|
|||||||
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
|
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
|
||||||
validate :validate_user
|
validate :validate_user
|
||||||
|
|
||||||
# Returns true if at least one object among objects is watched by user
|
|
||||||
def self.any_watched?(objects, user)
|
|
||||||
objects = objects.reject(&:new_record?)
|
|
||||||
if objects.any?
|
|
||||||
objects.group_by {|object| object.class.base_class}.each do |base_class, objects|
|
|
||||||
if Watcher.where(:watchable_type => base_class.name, :watchable_id => objects.map(&:id), :user_id => user.id).exists?
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
# Unwatch things that users are no longer allowed to view
|
# Unwatch things that users are no longer allowed to view
|
||||||
def self.prune(options={})
|
def self.prune(options={})
|
||||||
if options.has_key?(:user)
|
if options.has_key?(:user)
|
||||||
|
|||||||
+2
-2
@@ -50,10 +50,10 @@ class Wiki < ActiveRecord::Base
|
|||||||
@page_found_with_redirect = false
|
@page_found_with_redirect = false
|
||||||
title = start_page if title.blank?
|
title = start_page if title.blank?
|
||||||
title = Wiki.titleize(title)
|
title = Wiki.titleize(title)
|
||||||
page = pages.where("LOWER(title) = LOWER(?)", title).first
|
page = pages.first(:conditions => ["LOWER(title) = LOWER(?)", title])
|
||||||
if !page && !(options[:with_redirect] == false)
|
if !page && !(options[:with_redirect] == false)
|
||||||
# search for a redirect
|
# search for a redirect
|
||||||
redirect = redirects.where("LOWER(title) = LOWER(?)", title).first
|
redirect = redirects.first(:conditions => ["LOWER(title) = LOWER(?)", title])
|
||||||
if redirect
|
if redirect
|
||||||
page = find_page(redirect.redirects_to, :with_redirect => false)
|
page = find_page(redirect.redirects_to, :with_redirect => false)
|
||||||
@page_found_with_redirect = true
|
@page_found_with_redirect = true
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ class WikiContent < ActiveRecord::Base
|
|||||||
|
|
||||||
acts_as_versioned
|
acts_as_versioned
|
||||||
|
|
||||||
after_save :send_notification
|
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
page.visible?(user)
|
page.visible?(user)
|
||||||
end
|
end
|
||||||
@@ -147,19 +145,4 @@ class WikiContent < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def send_notification
|
|
||||||
# new_record? returns false in after_save callbacks
|
|
||||||
if id_changed?
|
|
||||||
if Setting.notified_events.include?('wiki_content_added')
|
|
||||||
Mailer.wiki_content_added(self).deliver
|
|
||||||
end
|
|
||||||
elsif text_changed?
|
|
||||||
if Setting.notified_events.include?('wiki_content_updated')
|
|
||||||
Mailer.wiki_content_updated(self).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
+6
-21
@@ -15,29 +15,14 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require File.expand_path('../../../test_helper', __FILE__)
|
class WikiContentObserver < ActiveRecord::Observer
|
||||||
|
def after_create(wiki_content)
|
||||||
class Redmine::ApiTest::CustomFieldsTest < Redmine::ApiTest::Base
|
Mailer.wiki_content_added(wiki_content).deliver if Setting.notified_events.include?('wiki_content_added')
|
||||||
fixtures :users, :custom_fields
|
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "GET /custom_fields.xml should return custom fields" do
|
def after_update(wiki_content)
|
||||||
get '/custom_fields.xml', {}, credentials('admin')
|
if wiki_content.text_changed?
|
||||||
assert_response :success
|
Mailer.wiki_content_updated(wiki_content).deliver if Setting.notified_events.include?('wiki_content_updated')
|
||||||
assert_equal 'application/xml', response.content_type
|
|
||||||
|
|
||||||
assert_select 'custom_fields' do
|
|
||||||
assert_select 'custom_field' do
|
|
||||||
assert_select 'name', :text => 'Database'
|
|
||||||
assert_select 'id', :text => '2'
|
|
||||||
assert_select 'customized_type', :text => 'issue'
|
|
||||||
assert_select 'possible_values[type=array]' do
|
|
||||||
assert_select 'possible_value>value', :text => 'PostgreSQL'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -175,10 +175,9 @@ class WikiPage < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Saves the page and its content if text was changed
|
# Saves the page and its content if text was changed
|
||||||
def save_with_content(content)
|
def save_with_content
|
||||||
ret = nil
|
ret = nil
|
||||||
transaction do
|
transaction do
|
||||||
self.content = content
|
|
||||||
if new_record?
|
if new_record?
|
||||||
# Rails automatically saves associated content
|
# Rails automatically saves associated content
|
||||||
ret = save
|
ret = save
|
||||||
|
|||||||
@@ -43,17 +43,11 @@
|
|||||||
<% content_for :sidebar do %>
|
<% content_for :sidebar do %>
|
||||||
<%= form_tag({}, :method => :get) do %>
|
<%= form_tag({}, :method => :get) do %>
|
||||||
<h3><%= l(:label_activity) %></h3>
|
<h3><%= l(:label_activity) %></h3>
|
||||||
<ul>
|
<p><% @activity.event_types.each do |t| %>
|
||||||
<% @activity.event_types.each do |t| %>
|
<%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
|
||||||
<li>
|
<label for="show_<%=t%>"><%= link_to(l("label_#{t.singularize}_plural"), {"show_#{t}" => 1, :user_id => params[:user_id], :from => params[:from]})%></label>
|
||||||
<%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
|
<br />
|
||||||
<label for="show_<%=t%>">
|
<% end %></p>
|
||||||
<%= link_to(l("label_#{t.singularize}_plural"),
|
|
||||||
{"show_#{t}" => 1, :user_id => params[:user_id], :from => params[:from]})%>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
<% if @project && @project.descendants.active.any? %>
|
<% if @project && @project.descendants.active.any? %>
|
||||||
<%= hidden_field_tag 'with_subprojects', 0 %>
|
<%= hidden_field_tag 'with_subprojects', 0 %>
|
||||||
<p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
|
<p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= title l(:label_plugins) %>
|
<h2><%= l(:label_plugins) %></h2>
|
||||||
|
|
||||||
<% if @plugins.any? %>
|
<% if @plugins.any? %>
|
||||||
<table class="list plugins">
|
<table class="list plugins">
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
|
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= title l(:label_project_plural) %>
|
<h2><%=l(:label_project_plural)%></h2>
|
||||||
|
|
||||||
<%= form_tag({}, :method => :get) do %>
|
<%= form_tag({}, :method => :get) do %>
|
||||||
<fieldset><legend><%= l(:label_filter_plural) %></legend>
|
<fieldset><legend><%= l(:label_filter_plural) %></legend>
|
||||||
@@ -41,3 +41,5 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% html_title(l(:label_project_plural)) -%>
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
var fileSpan = $('#attachments_<%= j params[:attachment_id] %>');
|
var fileSpan = $('#attachments_<%= j params[:attachment_id] %>');
|
||||||
<% if @attachment.new_record? %>
|
|
||||||
fileSpan.hide();
|
|
||||||
alert("<%= escape_javascript @attachment.errors.full_messages.join(', ') %>");
|
|
||||||
<% else %>
|
|
||||||
$('<input>', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan);
|
$('<input>', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan);
|
||||||
fileSpan.find('a.remove-upload')
|
fileSpan.find('a.remove-upload')
|
||||||
.attr({
|
.attr({
|
||||||
@@ -11,4 +7,3 @@ fileSpan.find('a.remove-upload')
|
|||||||
href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>'
|
href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>'
|
||||||
})
|
})
|
||||||
.off('click');
|
.off('click');
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= title [l(:label_auth_source_plural), auth_sources_path], @auth_source.name %>
|
<h2><%=l(:label_auth_source)%> (<%= h(@auth_source.auth_method_name) %>)</h2>
|
||||||
|
|
||||||
<%= labelled_form_for @auth_source, :as => :auth_source, :url => auth_source_path(@auth_source), :html => {:id => 'auth_source_form'} do |f| %>
|
<%= labelled_form_for @auth_source, :as => :auth_source, :url => auth_source_path(@auth_source), :html => {:id => 'auth_source_form'} do |f| %>
|
||||||
<%= render :partial => auth_source_partial_name(@auth_source), :locals => { :f => f } %>
|
<%= render :partial => auth_source_partial_name(@auth_source), :locals => { :f => f } %>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<%= link_to l(:label_auth_source_new), {:action => 'new'}, :class => 'icon icon-add' %>
|
<%= link_to l(:label_auth_source_new), {:action => 'new'}, :class => 'icon icon-add' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= title l(:label_auth_source_plural) %>
|
<h2><%=l(:label_auth_source_plural)%></h2>
|
||||||
|
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= title [l(:label_auth_source_plural), auth_sources_path], "#{l(:label_auth_source_new)} (#{@auth_source.auth_method_name})" %>
|
<h2><%=l(:label_auth_source_new)%> (<%= h(@auth_source.auth_method_name) %>)</h2>
|
||||||
|
|
||||||
<%= labelled_form_for @auth_source, :as => :auth_source, :url => auth_sources_path, :html => {:id => 'auth_source_form'} do |f| %>
|
<%= labelled_form_for @auth_source, :as => :auth_source, :url => auth_sources_path, :html => {:id => 'auth_source_form'} do |f| %>
|
||||||
<%= hidden_field_tag 'type', @auth_source.type %>
|
<%= hidden_field_tag 'type', @auth_source.type %>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% line_num = 1 %>
|
<% line_num = 1 %>
|
||||||
<% syntax_highlight_lines(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each do |line| %>
|
<% syntax_highlight_lines(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each do |line| %>
|
||||||
<tr id="L<%= line_num %>">
|
<tr>
|
||||||
<th class="line-num">
|
<th class="line-num" id="L<%= line_num %>">
|
||||||
<a href="#L<%= line_num %>"><%= line_num %></a>
|
<a href="#L<%= line_num %>"><%= line_num %></a>
|
||||||
</th>
|
</th>
|
||||||
<td class="line-code">
|
<td class="line-code">
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<li><%= link_to l(tab[:label]), { :tab => tab[:name] },
|
<li><%= link_to l(tab[:label]), { :tab => tab[:name] },
|
||||||
:id => "tab-#{tab[:name]}",
|
:id => "tab-#{tab[:name]}",
|
||||||
:class => (tab[:name] != selected_tab ? nil : 'selected'),
|
:class => (tab[:name] != selected_tab ? nil : 'selected'),
|
||||||
:onclick => "showTab('#{tab[:name]}', this.href); this.blur(); return false;" %></li>
|
:onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tabs-buttons" style="display:none;">
|
<div class="tabs-buttons" style="display:none;">
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
<%= error_messages_for 'custom_field' %>
|
<%= error_messages_for 'custom_field' %>
|
||||||
|
|
||||||
<% if @custom_field.is_a?(IssueCustomField) %>
|
|
||||||
<div class="splitcontentleft">
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<p><%= f.text_field :name, :required => true %></p>
|
<p><%= f.text_field :name, :required => true %></p>
|
||||||
<p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :disabled => !@custom_field.new_record? %></p>
|
<p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :disabled => !@custom_field.new_record? %></p>
|
||||||
@@ -50,28 +46,24 @@
|
|||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<% case @custom_field.class.name
|
<% case @custom_field.class.name
|
||||||
when "IssueCustomField" %>
|
when "IssueCustomField" %>
|
||||||
|
|
||||||
|
<fieldset><legend><%=l(:label_tracker_plural)%></legend>
|
||||||
|
<% Tracker.sorted.all.each do |tracker| %>
|
||||||
|
<%= check_box_tag "custom_field[tracker_ids][]",
|
||||||
|
tracker.id,
|
||||||
|
(@custom_field.trackers.include? tracker),
|
||||||
|
:id => "custom_field_tracker_ids_#{tracker.id}" %>
|
||||||
|
<label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>">
|
||||||
|
<%= h(tracker.name) %>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
<%= hidden_field_tag "custom_field[tracker_ids][]", '' %>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<p><%= f.check_box :is_required %></p>
|
<p><%= f.check_box :is_required %></p>
|
||||||
<p><%= f.check_box :is_for_all %></p>
|
<p><%= f.check_box :is_for_all %></p>
|
||||||
<p><%= f.check_box :is_filter %></p>
|
<p><%= f.check_box :is_filter %></p>
|
||||||
<p><%= f.check_box :searchable %></p>
|
<p><%= f.check_box :searchable %></p>
|
||||||
<p>
|
|
||||||
<label><%= l(:field_visible) %></label>
|
|
||||||
<label class="block">
|
|
||||||
<%= radio_button_tag 'custom_field[visible]', 1, @custom_field.visible?, :id => 'custom_field_visible_on' %>
|
|
||||||
<%= l(:label_visibility_public) %>
|
|
||||||
</label>
|
|
||||||
<label class="block">
|
|
||||||
<%= radio_button_tag 'custom_field[visible]', 0, !@custom_field.visible?, :id => 'custom_field_visible_off' %>
|
|
||||||
<%= l(:label_visibility_roles) %>:
|
|
||||||
</label>
|
|
||||||
<% Role.givable.sorted.each do |role| %>
|
|
||||||
<label class="block custom_field_role" style="padding-left:2em;">
|
|
||||||
<%= check_box_tag 'custom_field[role_ids][]', role.id, @custom_field.roles.include?(role) %>
|
|
||||||
<%= role.name %>
|
|
||||||
</label>
|
|
||||||
<% end %>
|
|
||||||
<%= hidden_field_tag 'custom_field[role_ids][]', '' %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<% when "UserCustomField" %>
|
<% when "UserCustomField" %>
|
||||||
<p><%= f.check_box :is_required %></p>
|
<p><%= f.check_box :is_required %></p>
|
||||||
@@ -103,45 +95,5 @@ when "IssueCustomField" %>
|
|||||||
<% end %>
|
<% end %>
|
||||||
<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
|
<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
|
||||||
</div>
|
</div>
|
||||||
<%= submit_tag l(:button_save) %>
|
|
||||||
|
|
||||||
<% if @custom_field.is_a?(IssueCustomField) %>
|
|
||||||
</div>
|
|
||||||
<div class="splitcontentright">
|
|
||||||
<fieldset class="box"><legend><%=l(:label_tracker_plural)%></legend>
|
|
||||||
<% Tracker.sorted.all.each do |tracker| %>
|
|
||||||
<%= check_box_tag "custom_field[tracker_ids][]",
|
|
||||||
tracker.id,
|
|
||||||
(@custom_field.trackers.include? tracker),
|
|
||||||
:id => "custom_field_tracker_ids_#{tracker.id}" %>
|
|
||||||
<label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>">
|
|
||||||
<%= h(tracker.name) %>
|
|
||||||
</label>
|
|
||||||
<% end %>
|
|
||||||
<%= hidden_field_tag "custom_field[tracker_ids][]", '' %>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<fieldset class="box" id="custom_field_project_ids"><legend><%= l(:label_project_plural) %></legend>
|
|
||||||
<%= render_project_nested_lists(Project.all) do |p|
|
|
||||||
content_tag('label', check_box_tag('custom_field[project_ids][]', p.id, @custom_field.projects.to_a.include?(p), :id => nil) + ' ' + h(p))
|
|
||||||
end %>
|
|
||||||
<%= hidden_field_tag('custom_field[project_ids][]', '', :id => nil) %>
|
|
||||||
<p><%= check_all_links 'custom_field_project_ids' %></p>
|
|
||||||
</fieldset>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% include_calendar_headers_tags %>
|
<% include_calendar_headers_tags %>
|
||||||
|
|
||||||
<%= javascript_tag do %>
|
|
||||||
function toggleCustomFieldRoles(){
|
|
||||||
var checked = $("#custom_field_visible_on").is(':checked');
|
|
||||||
$('.custom_field_role input').attr('disabled', checked);
|
|
||||||
}
|
|
||||||
$("#custom_field_visible_on, #custom_field_visible_off").change(toggleCustomFieldRoles);
|
|
||||||
$(document).ready(toggleCustomFieldRoles);
|
|
||||||
|
|
||||||
$("#custom_field_is_for_all").change(function(){
|
|
||||||
$("#custom_field_project_ids input").attr("disabled", $(this).is(":checked"));
|
|
||||||
}).trigger('change');
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<%= title [l(:label_custom_field_plural), custom_fields_path],
|
<h2><%= link_to l(:label_custom_field_plural), :controller => 'custom_fields', :action => 'index' %>
|
||||||
[l(@custom_field.type_name), custom_fields_path(:tab => @custom_field.class.name)],
|
» <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.name %>
|
||||||
@custom_field.name %>
|
» <%=h @custom_field.name %></h2>
|
||||||
|
|
||||||
<%= labelled_form_for :custom_field, @custom_field, :url => custom_field_path(@custom_field), :html => {:method => :put, :id => 'custom_field_form'} do |f| %>
|
<%= labelled_form_for :custom_field, @custom_field, :url => custom_field_path(@custom_field), :html => {:method => :put, :id => 'custom_field_form'} do |f| %>
|
||||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||||
|
<%= submit_tag l(:button_save) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
api.array :custom_fields do
|
|
||||||
@custom_fields.each do |field|
|
|
||||||
api.custom_field do
|
|
||||||
api.id field.id
|
|
||||||
api.name field.name
|
|
||||||
api.customized_type field.class.customized_class.name.underscore if field.class.customized_class
|
|
||||||
api.field_format field.field_format
|
|
||||||
api.regexp field.regexp
|
|
||||||
api.min_length (field.min_length == 0 ? nil : field.min_length)
|
|
||||||
api.max_length (field.max_length == 0 ? nil : field.max_length)
|
|
||||||
api.is_required field.is_required?
|
|
||||||
api.is_filter field.is_filter?
|
|
||||||
api.searchable field.searchable
|
|
||||||
api.multiple field.multiple?
|
|
||||||
api.default_value field.default_value
|
|
||||||
api.visible field.visible?
|
|
||||||
|
|
||||||
if field.field_format == 'list'
|
|
||||||
api.array :possible_values do
|
|
||||||
field.possible_values.each do |v|
|
|
||||||
api.possible_value do
|
|
||||||
api.value v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if field.is_a?(IssueCustomField)
|
|
||||||
api.trackers do
|
|
||||||
field.trackers.each do |tracker|
|
|
||||||
api.tracker :id => tracker.id, :name => tracker.name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
api.roles do
|
|
||||||
field.roles.each do |role|
|
|
||||||
api.role :id => role.id, :name => role.name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
<%= title l(:label_custom_field_plural) %>
|
<h2><%=l(:label_custom_field_plural)%></h2>
|
||||||
|
|
||||||
<%= render_tabs custom_fields_tabs %>
|
<%= render_tabs custom_fields_tabs %>
|
||||||
|
|
||||||
|
<% html_title(l(:label_custom_field_plural)) -%>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<%= title [l(:label_custom_field_plural), custom_fields_path],
|
<h2><%= link_to l(:label_custom_field_plural), :controller => 'custom_fields', :action => 'index' %>
|
||||||
[l(@custom_field.type_name), custom_fields_path(:tab => @custom_field.class.name)],
|
» <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.name %>
|
||||||
l(:label_custom_field_new) %>
|
» <%= l(:label_custom_field_new) %></h2>
|
||||||
|
|
||||||
<%= labelled_form_for :custom_field, @custom_field, :url => custom_fields_path, :html => {:id => 'custom_field_form'} do |f| %>
|
<%= labelled_form_for :custom_field, @custom_field, :url => custom_fields_path, :html => {:id => 'custom_field_form'} do |f| %>
|
||||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||||
<%= hidden_field_tag 'type', @custom_field.type %>
|
<%= hidden_field_tag 'type', @custom_field.type %>
|
||||||
|
<%= submit_tag l(:button_save) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= javascript_tag do %>
|
<%= javascript_tag do %>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<%= labelled_form_for @document, :url => project_documents_path(@project), :html => {:multipart => true} do |f| %>
|
<%= labelled_form_for @document, :url => project_documents_path(@project), :html => {:multipart => true} do |f| %>
|
||||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||||
<p>
|
<p>
|
||||||
<%= submit_tag l(:button_create) %>
|
<%= submit_tag l(:button_create) %>
|
||||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-document").hide(); return false;' %>
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-document").hide(); return false;' %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -25,16 +25,10 @@
|
|||||||
|
|
||||||
<% content_for :sidebar do %>
|
<% content_for :sidebar do %>
|
||||||
<h3><%= l(:label_sort_by, '') %></h3>
|
<h3><%= l(:label_sort_by, '') %></h3>
|
||||||
<ul>
|
<%= link_to l(:field_category), {:sort_by => 'category'}, :class => (@sort_by == 'category' ? 'selected' :nil) %><br />
|
||||||
<li><%= link_to(l(:field_category), {:sort_by => 'category'},
|
<%= link_to l(:label_date), {:sort_by => 'date'}, :class => (@sort_by == 'date' ? 'selected' :nil) %><br />
|
||||||
:class => (@sort_by == 'category' ? 'selected' :nil)) %></li>
|
<%= link_to l(:field_title), {:sort_by => 'title'}, :class => (@sort_by == 'title' ? 'selected' :nil) %><br />
|
||||||
<li><%= link_to(l(:label_date), {:sort_by => 'date'},
|
<%= link_to l(:field_author), {:sort_by => 'author'}, :class => (@sort_by == 'author' ? 'selected' :nil) %>
|
||||||
:class => (@sort_by == 'date' ? 'selected' :nil)) %></li>
|
|
||||||
<li><%= link_to(l(:field_title), {:sort_by => 'title'},
|
|
||||||
:class => (@sort_by == 'title' ? 'selected' :nil)) %></li>
|
|
||||||
<li><%= link_to(l(:field_author), {:sort_by => 'author'},
|
|
||||||
:class => (@sort_by == 'author' ? 'selected' :nil)) %></li>
|
|
||||||
</ul>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% html_title(l(:label_document_plural)) -%>
|
<% html_title(l(:label_document_plural)) -%>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= title [l(@enumeration.option_name), enumerations_path], @enumeration.name %>
|
<h2><%= l(@enumeration.option_name) %>: <%=h @enumeration %></h2>
|
||||||
|
|
||||||
<%= form_tag({}, :method => :delete) do %>
|
<%= form_tag({}, :method => :delete) do %>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= title [l(@enumeration.option_name), enumerations_path], @enumeration.name %>
|
<h2><%= link_to l(@enumeration.option_name), enumerations_path %> » <%=h @enumeration %></h2>
|
||||||
|
|
||||||
<%= labelled_form_for :enumeration, @enumeration, :url => enumeration_path(@enumeration), :html => {:method => :put} do |f| %>
|
<%= labelled_form_for :enumeration, @enumeration, :url => enumeration_path(@enumeration), :html => {:method => :put} do |f| %>
|
||||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<th><%= l(:field_name) %></th>
|
<th><%= l(:field_name) %></th>
|
||||||
<th style="width:15%;"><%= l(:field_is_default) %></th>
|
<th style="width:15%;"><%= l(:field_is_default) %></th>
|
||||||
<th style="width:15%;"><%= l(:field_active) %></th>
|
<th style="width:15%;"><%= l(:field_active) %></th>
|
||||||
<th style="width:15%;"><%=l(:button_sort)%></th>
|
<th style="width:15%;"></th>
|
||||||
<th align="center" style="width:10%;"> </th>
|
<th align="center" style="width:10%;"> </th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<% enumerations.each do |enumeration| %>
|
<% enumerations.each do |enumeration| %>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<td><%= link_to h(enumeration), edit_enumeration_path(enumeration) %></td>
|
<td><%= link_to h(enumeration), edit_enumeration_path(enumeration) %></td>
|
||||||
<td class="center" style="width:15%;"><%= checked_image enumeration.is_default? %></td>
|
<td class="center" style="width:15%;"><%= checked_image enumeration.is_default? %></td>
|
||||||
<td class="center" style="width:15%;"><%= checked_image enumeration.active? %></td>
|
<td class="center" style="width:15%;"><%= checked_image enumeration.active? %></td>
|
||||||
<td align="center" style="width:15%;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}, :put) %></td>
|
<td style="width:15%;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}, :put) %></td>
|
||||||
<td class="buttons">
|
<td class="buttons">
|
||||||
<%= delete_link enumeration_path(enumeration) %>
|
<%= delete_link enumeration_path(enumeration) %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= title [l(@enumeration.option_name), enumerations_path], l(:label_enumeration_new) %>
|
<h2><%= link_to l(@enumeration.option_name), enumerations_path %> » <%=l(:label_enumeration_new)%></h2>
|
||||||
|
|
||||||
<%= labelled_form_for :enumeration, @enumeration, :url => enumerations_path do |f| %>
|
<%= labelled_form_for :enumeration, @enumeration, :url => enumerations_path do |f| %>
|
||||||
<%= f.hidden_field :type %>
|
<%= f.hidden_field :type %>
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
<% @gantt.view = self %>
|
<% @gantt.view = self %>
|
||||||
<div class="contextual">
|
|
||||||
<% if !@query.new_record? && @query.editable_by?(User.current) %>
|
|
||||||
<%= link_to l(:button_edit), edit_query_path(@query, :gantt => 1), :class => 'icon icon-edit' %>
|
|
||||||
<%= delete_link query_path(@query, :gantt => 1) %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
|
<h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
|
||||||
|
|
||||||
<%= form_tag({:controller => 'gantts', :action => 'show',
|
<%= form_tag({:controller => 'gantts', :action => 'show',
|
||||||
@@ -13,7 +6,6 @@
|
|||||||
:year => params[:year], :months => params[:months]},
|
:year => params[:year], :months => params[:months]},
|
||||||
:method => :get, :id => 'query_form') do %>
|
:method => :get, :id => 'query_form') do %>
|
||||||
<%= hidden_field_tag 'set_filter', '1' %>
|
<%= hidden_field_tag 'set_filter', '1' %>
|
||||||
<%= hidden_field_tag 'gantt', '1' %>
|
|
||||||
<fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
|
<fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
|
||||||
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
|
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
|
||||||
<div style="<%= @query.new_record? ? "" : "display: none;" %>">
|
<div style="<%= @query.new_record? ? "" : "display: none;" %>">
|
||||||
@@ -28,8 +20,8 @@
|
|||||||
<td>
|
<td>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><%= l(:label_related_issues) %></legend>
|
<legend><%= l(:label_related_issues) %></legend>
|
||||||
<label for="draw_relations">
|
<label>
|
||||||
<%= check_box 'query', 'draw_relations', :id => 'draw_relations' %>
|
<%= check_box_tag "draw_rels", params["draw_rels"], params[:set_filter].blank? || params[:draw_rels] %>
|
||||||
<% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %>
|
<% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %>
|
||||||
<% rels.each do |rel| %>
|
<% rels.each do |rel| %>
|
||||||
<% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %>
|
<% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %>
|
||||||
@@ -43,8 +35,8 @@
|
|||||||
<td>
|
<td>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><%= l(:label_gantt_progress_line) %></legend>
|
<legend><%= l(:label_gantt_progress_line) %></legend>
|
||||||
<label for="draw_progress_line">
|
<label>
|
||||||
<%= check_box 'query', 'draw_progress_line', :id => 'draw_progress_line' %>
|
<%= check_box_tag "draw_progress_line", params[:draw_progress_line], params[:draw_progress_line] %>
|
||||||
<%= l(:label_display) %>
|
<%= l(:label_display) %>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -70,11 +62,6 @@
|
|||||||
:class => 'icon icon-checked' %>
|
:class => 'icon icon-checked' %>
|
||||||
<%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
|
<%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
|
||||||
:class => 'icon icon-reload' %>
|
:class => 'icon icon-reload' %>
|
||||||
<% if @query.new_record? && User.current.allowed_to?(:save_queries, @project, :global => true) %>
|
|
||||||
<%= link_to_function l(:button_save),
|
|
||||||
"$('#query_form').attr('action', '#{ @project ? new_project_query_path(@project) : new_query_path }').submit();",
|
|
||||||
:class => 'icon icon-save' %>
|
|
||||||
<% end %>
|
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -326,7 +313,7 @@
|
|||||||
$(document).ready(drawGanttHandler);
|
$(document).ready(drawGanttHandler);
|
||||||
$(window).resize(drawGanttHandler);
|
$(window).resize(drawGanttHandler);
|
||||||
$(function() {
|
$(function() {
|
||||||
$("#draw_relations").change(drawGanttHandler);
|
$("#draw_rels").change(drawGanttHandler);
|
||||||
$("#draw_progress_line").change(drawGanttHandler);
|
$("#draw_progress_line").change(drawGanttHandler);
|
||||||
});
|
});
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
<%= title [l(:label_group_plural), groups_path], @group.name %>
|
<h2><%= link_to l(:label_group_plural), groups_path %> » <%= h(@group) %></h2>
|
||||||
|
|
||||||
<%= render_tabs group_settings_tabs %>
|
<%= render_tabs group_settings_tabs %>
|
||||||
|
|
||||||
|
<% html_title(l(:label_group), @group, l(:label_administration)) -%>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<%= link_to l(:label_group_new), new_group_path, :class => 'icon icon-add' %>
|
<%= link_to l(:label_group_new), new_group_path, :class => 'icon icon-add' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= title l(:label_group_plural) %>
|
<h2><%= l(:label_group_plural) %></h2>
|
||||||
|
|
||||||
<% if @groups.any? %>
|
<% if @groups.any? %>
|
||||||
<table class="list groups">
|
<table class="list groups">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= title [l(:label_group_plural), groups_path], l(:label_group_new) %>
|
<h2><%= link_to l(:label_group_plural), groups_path %> » <%= l(:label_group_new) %></h2>
|
||||||
|
|
||||||
<%= labelled_form_for @group do |f| %>
|
<%= labelled_form_for @group do |f| %>
|
||||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= title [l(:label_group_plural), groups_path], @group.name %>
|
<h2><%= link_to l(:label_group_plural), groups_path %> » <%=h @group %></h2>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<% @group.users.each do |user| %>
|
<% @group.users.each do |user| %>
|
||||||
|
|||||||
@@ -4,4 +4,3 @@ $('#relations').html('<%= escape_javascript(render :partial => 'issues/relations
|
|||||||
$('#relation_issue_to_id').val('');
|
$('#relation_issue_to_id').val('');
|
||||||
$('#relation_issue_to_id').focus();
|
$('#relation_issue_to_id').focus();
|
||||||
<% end %>
|
<% end %>
|
||||||
$('#new-relation-form').show();
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= title [l(:label_issue_status_plural), issue_statuses_path], @issue_status.name %>
|
<h2><%= link_to l(:label_issue_status_plural), issue_statuses_path %> » <%=h @issue_status %></h2>
|
||||||
|
|
||||||
<%= labelled_form_for @issue_status do |f| %>
|
<%= labelled_form_for @issue_status do |f| %>
|
||||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= title [l(:label_issue_status_plural), issue_statuses_path], l(:label_issue_status_new) %>
|
<h2><%= link_to l(:label_issue_status_plural), issue_statuses_path %> » <%=l(:label_issue_status_new)%></h2>
|
||||||
|
|
||||||
<%= labelled_form_for @issue_status do |f| %>
|
<%= labelled_form_for @issue_status do |f| %>
|
||||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||||
|
|||||||
@@ -47,19 +47,11 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @issue.safe_attribute? 'start_date' %>
|
<% if @issue.safe_attribute? 'start_date' %>
|
||||||
<p id="start_date_area">
|
<p><%= f.text_field :start_date, :size => 10, :disabled => !@issue.leaf?, :required => @issue.required_attribute?('start_date') %><%= calendar_for('issue_start_date') if @issue.leaf? %></p>
|
||||||
<%= f.text_field(:start_date, :size => 10, :disabled => !@issue.leaf?,
|
|
||||||
:required => @issue.required_attribute?('start_date')) %>
|
|
||||||
<%= calendar_for('issue_start_date') if @issue.leaf? %>
|
|
||||||
</p>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @issue.safe_attribute? 'due_date' %>
|
<% if @issue.safe_attribute? 'due_date' %>
|
||||||
<p id="due_date_area">
|
<p><%= f.text_field :due_date, :size => 10, :disabled => !@issue.leaf?, :required => @issue.required_attribute?('due_date') %><%= calendar_for('issue_due_date') if @issue.leaf? %></p>
|
||||||
<%= f.text_field(:due_date, :size => 10, :disabled => !@issue.leaf?,
|
|
||||||
:required => @issue.required_attribute?('due_date')) %>
|
|
||||||
<%= calendar_for('issue_due_date') if @issue.leaf? %>
|
|
||||||
</p>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @issue.safe_attribute? 'estimated_hours' %>
|
<% if @issue.safe_attribute? 'estimated_hours' %>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<% if journal.details.any? %>
|
<% if journal.details.any? %>
|
||||||
<ul class="details">
|
<ul class="details">
|
||||||
<% details_to_strings(journal.visible_details).each do |string| %>
|
<% details_to_strings(journal.details).each do |string| %>
|
||||||
<li><%= string %></li>
|
<li><%= string %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
:as => :relation, :remote => true,
|
:as => :relation, :remote => true,
|
||||||
:url => issue_relations_path(@issue),
|
:url => issue_relations_path(@issue),
|
||||||
:method => :post,
|
:method => :post,
|
||||||
:html => {:id => 'new-relation-form', :style => 'display: none;'}
|
:html => {:id => 'new-relation-form', :style => (@relation ? '' : 'display: none;')}
|
||||||
} do |f| %>
|
} do |f| %>
|
||||||
<%= render :partial => 'issue_relations/form', :locals => {:f => f}%>
|
<%= render :partial => 'issue_relations/form', :locals => {:f => f}%>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
<h3><%= l(:label_issue_plural) %></h3>
|
<h3><%= l(:label_issue_plural) %></h3>
|
||||||
|
<%= link_to l(:label_issue_view_all), _project_issues_path(@project, :set_filter => 1) %><br />
|
||||||
<ul>
|
|
||||||
<li><%= link_to l(:label_issue_view_all), _project_issues_path(@project, :set_filter => 1) %></li>
|
|
||||||
<% if @project %>
|
<% if @project %>
|
||||||
<li><%= link_to l(:field_summary), project_issues_report_path(@project) %></li>
|
<%= link_to l(:field_summary), project_issues_report_path(@project) %><br />
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= call_hook(:view_issues_sidebar_issues_bottom) %>
|
||||||
|
|
||||||
<% if User.current.allowed_to?(:view_calendar, @project, :global => true) %>
|
<% if User.current.allowed_to?(:view_calendar, @project, :global => true) %>
|
||||||
<li><%= link_to l(:label_calendar), _project_calendar_path(@project) %></li>
|
<%= link_to l(:label_calendar), _project_calendar_path(@project) %><br />
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if User.current.allowed_to?(:view_gantt, @project, :global => true) %>
|
<% if User.current.allowed_to?(:view_gantt, @project, :global => true) %>
|
||||||
<li><%= link_to l(:label_gantt), _project_gantt_path(@project) %></li>
|
<%= link_to l(:label_gantt), _project_gantt_path(@project) %><br />
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
|
||||||
|
|
||||||
<%= call_hook(:view_issues_sidebar_issues_bottom) %>
|
|
||||||
<%= call_hook(:view_issues_sidebar_planning_bottom) %>
|
<%= call_hook(:view_issues_sidebar_planning_bottom) %>
|
||||||
|
|
||||||
<%= render_sidebar_queries %>
|
<%= render_sidebar_queries %>
|
||||||
|
|||||||
@@ -1,21 +1,5 @@
|
|||||||
<h2><%= @copy ? l(:button_copy) : l(:label_bulk_edit_selected_issues) %></h2>
|
<h2><%= @copy ? l(:button_copy) : l(:label_bulk_edit_selected_issues) %></h2>
|
||||||
|
|
||||||
<% if @saved_issues && @unsaved_issues.present? %>
|
|
||||||
<div id="errorExplanation">
|
|
||||||
<span>
|
|
||||||
<%= l(:notice_failed_to_save_issues,
|
|
||||||
:count => @unsaved_issues.size,
|
|
||||||
:total => @saved_issues.size,
|
|
||||||
:ids => @unsaved_issues.map {|i| "##{i.id}"}.join(', ')) %>
|
|
||||||
</span>
|
|
||||||
<ul>
|
|
||||||
<% bulk_edit_error_messages(@unsaved_issues).each do |message| %>
|
|
||||||
<li><%= message %></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<ul id="bulk-selection">
|
<ul id="bulk-selection">
|
||||||
<% @issues.each do |issue| %>
|
<% @issues.each do |issue| %>
|
||||||
<%= content_tag 'li', link_to_issue(issue) %>
|
<%= content_tag 'li', link_to_issue(issue) %>
|
||||||
@@ -32,43 +16,34 @@
|
|||||||
<% if @allowed_projects.present? %>
|
<% if @allowed_projects.present? %>
|
||||||
<p>
|
<p>
|
||||||
<label for="issue_project_id"><%= l(:field_project) %></label>
|
<label for="issue_project_id"><%= l(:field_project) %></label>
|
||||||
<%= select_tag('issue[project_id]',
|
<%= select_tag('issue[project_id]', content_tag('option', l(:label_no_change_option), :value => '') + project_tree_options_for_select(@allowed_projects, :selected => @target_project),
|
||||||
content_tag('option', l(:label_no_change_option), :value => '') +
|
|
||||||
project_tree_options_for_select(@allowed_projects, :selected => @target_project),
|
|
||||||
:onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %>
|
:onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p>
|
<p>
|
||||||
<label for="issue_tracker_id"><%= l(:field_tracker) %></label>
|
<label for="issue_tracker_id"><%= l(:field_tracker) %></label>
|
||||||
<%= select_tag('issue[tracker_id]',
|
<%= select_tag('issue[tracker_id]', content_tag('option', l(:label_no_change_option), :value => '') + options_from_collection_for_select(@trackers, :id, :name)) %>
|
||||||
content_tag('option', l(:label_no_change_option), :value => '') +
|
|
||||||
options_from_collection_for_select(@trackers, :id, :name, @issue_params[:tracker_id])) %>
|
|
||||||
</p>
|
</p>
|
||||||
<% if @available_statuses.any? %>
|
<% if @available_statuses.any? %>
|
||||||
<p>
|
<p>
|
||||||
<label for='issue_status_id'><%= l(:field_status) %></label>
|
<label for='issue_status_id'><%= l(:field_status) %></label>
|
||||||
<%= select_tag('issue[status_id]',
|
<%= select_tag('issue[status_id]',content_tag('option', l(:label_no_change_option), :value => '') + options_from_collection_for_select(@available_statuses, :id, :name)) %>
|
||||||
content_tag('option', l(:label_no_change_option), :value => '') +
|
|
||||||
options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id])) %>
|
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @safe_attributes.include?('priority_id') -%>
|
<% if @safe_attributes.include?('priority_id') -%>
|
||||||
<p>
|
<p>
|
||||||
<label for='issue_priority_id'><%= l(:field_priority) %></label>
|
<label for='issue_priority_id'><%= l(:field_priority) %></label>
|
||||||
<%= select_tag('issue[priority_id]',
|
<%= select_tag('issue[priority_id]', content_tag('option', l(:label_no_change_option), :value => '') + options_from_collection_for_select(IssuePriority.active, :id, :name)) %>
|
||||||
content_tag('option', l(:label_no_change_option), :value => '') +
|
|
||||||
options_from_collection_for_select(IssuePriority.active, :id, :name, @issue_params[:priority_id])) %>
|
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @safe_attributes.include?('assigned_to_id') -%>
|
<% if @safe_attributes.include?('assigned_to_id') -%>
|
||||||
<p>
|
<p>
|
||||||
<label for='issue_assigned_to_id'><%= l(:field_assigned_to) %></label>
|
<label for='issue_assigned_to_id'><%= l(:field_assigned_to) %></label>
|
||||||
<%= select_tag('issue[assigned_to_id]',
|
<%= select_tag('issue[assigned_to_id]', content_tag('option', l(:label_no_change_option), :value => '') +
|
||||||
content_tag('option', l(:label_no_change_option), :value => '') +
|
content_tag('option', l(:label_nobody), :value => 'none') +
|
||||||
content_tag('option', l(:label_nobody), :value => 'none', :selected => (@issue_params[:assigned_to_id] == 'none')) +
|
principals_options_for_select(@assignables)) %>
|
||||||
principals_options_for_select(@assignables, @issue_params[:assigned_to_id])) %>
|
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -76,8 +51,8 @@
|
|||||||
<p>
|
<p>
|
||||||
<label for='issue_category_id'><%= l(:field_category) %></label>
|
<label for='issue_category_id'><%= l(:field_category) %></label>
|
||||||
<%= select_tag('issue[category_id]', content_tag('option', l(:label_no_change_option), :value => '') +
|
<%= select_tag('issue[category_id]', content_tag('option', l(:label_no_change_option), :value => '') +
|
||||||
content_tag('option', l(:label_none), :value => 'none', :selected => (@issue_params[:category_id] == 'none')) +
|
content_tag('option', l(:label_none), :value => 'none') +
|
||||||
options_from_collection_for_select(@categories, :id, :name, @issue_params[:category_id])) %>
|
options_from_collection_for_select(@categories, :id, :name)) %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -85,31 +60,26 @@
|
|||||||
<p>
|
<p>
|
||||||
<label for='issue_fixed_version_id'><%= l(:field_fixed_version) %></label>
|
<label for='issue_fixed_version_id'><%= l(:field_fixed_version) %></label>
|
||||||
<%= select_tag('issue[fixed_version_id]', content_tag('option', l(:label_no_change_option), :value => '') +
|
<%= select_tag('issue[fixed_version_id]', content_tag('option', l(:label_no_change_option), :value => '') +
|
||||||
content_tag('option', l(:label_none), :value => 'none', :selected => (@issue_params[:fixed_version_id] == 'none')) +
|
content_tag('option', l(:label_none), :value => 'none') +
|
||||||
version_options_for_select(@versions.sort, @issue_params[:fixed_version_id])) %>
|
version_options_for_select(@versions.sort)) %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% @custom_fields.each do |custom_field| %>
|
<% @custom_fields.each do |custom_field| %>
|
||||||
<p>
|
<p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('issue', custom_field, @projects) %></p>
|
||||||
<label><%= h(custom_field.name) %></label>
|
|
||||||
<%= custom_field_tag_for_bulk_edit('issue', custom_field, @projects, @issue_params[:custom_field_values][custom_field.id.to_s]) %>
|
|
||||||
</p>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @copy && @attachments_present %>
|
<% if @copy && @attachments_present %>
|
||||||
<%= hidden_field_tag 'copy_attachments', '0' %>
|
|
||||||
<p>
|
<p>
|
||||||
<label for='copy_attachments'><%= l(:label_copy_attachments) %></label>
|
<label for='copy_attachments'><%= l(:label_copy_attachments) %></label>
|
||||||
<%= check_box_tag 'copy_attachments', '1', params[:copy_attachments] != '0' %>
|
<%= check_box_tag 'copy_attachments', '1', true %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @copy && @subtasks_present %>
|
<% if @copy && @subtasks_present %>
|
||||||
<%= hidden_field_tag 'copy_subtasks', '0' %>
|
|
||||||
<p>
|
<p>
|
||||||
<label for='copy_subtasks'><%= l(:label_copy_subtasks) %></label>
|
<label for='copy_subtasks'><%= l(:label_copy_subtasks) %></label>
|
||||||
<%= check_box_tag 'copy_subtasks', '1', params[:copy_subtasks] != '0' %>
|
<%= check_box_tag 'copy_subtasks', '1', true %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -121,16 +91,15 @@
|
|||||||
<p>
|
<p>
|
||||||
<label for='issue_is_private'><%= l(:field_is_private) %></label>
|
<label for='issue_is_private'><%= l(:field_is_private) %></label>
|
||||||
<%= select_tag('issue[is_private]', content_tag('option', l(:label_no_change_option), :value => '') +
|
<%= select_tag('issue[is_private]', content_tag('option', l(:label_no_change_option), :value => '') +
|
||||||
content_tag('option', l(:general_text_Yes), :value => '1', :selected => (@issue_params[:is_private] == '1')) +
|
content_tag('option', l(:general_text_Yes), :value => '1') +
|
||||||
content_tag('option', l(:general_text_No), :value => '0', :selected => (@issue_params[:is_private] == '0'))) %>
|
content_tag('option', l(:general_text_No), :value => '0')) %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @safe_attributes.include?('parent_issue_id') && @project %>
|
<% if @safe_attributes.include?('parent_issue_id') && @project %>
|
||||||
<p>
|
<p>
|
||||||
<label for='issue_parent_issue_id'><%= l(:field_parent_issue) %></label>
|
<label for='issue_parent_issue_id'><%= l(:field_parent_issue) %></label>
|
||||||
<%= text_field_tag 'issue[parent_issue_id]', '', :size => 10, :value => @issue_params[:parent_issue_id] %>
|
<%= text_field_tag 'issue[parent_issue_id]', '', :size => 10 %>
|
||||||
<label class="inline"><%= check_box_tag 'issue[parent_issue_id]', 'none', (@issue_params[:parent_issue_id] == 'none'), :id => nil, :data => {:disables => '#issue_parent_issue_id'} %><%= l(:button_clear) %></label>
|
|
||||||
</p>
|
</p>
|
||||||
<%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project)}')" %>
|
<%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project)}')" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -138,61 +107,44 @@
|
|||||||
<% if @safe_attributes.include?('start_date') %>
|
<% if @safe_attributes.include?('start_date') %>
|
||||||
<p>
|
<p>
|
||||||
<label for='issue_start_date'><%= l(:field_start_date) %></label>
|
<label for='issue_start_date'><%= l(:field_start_date) %></label>
|
||||||
<%= text_field_tag 'issue[start_date]', '', :value => @issue_params[:start_date], :size => 10 %><%= calendar_for('issue_start_date') %>
|
<%= text_field_tag 'issue[start_date]', '', :size => 10 %><%= calendar_for('issue_start_date') %>
|
||||||
<label class="inline"><%= check_box_tag 'issue[start_date]', 'none', (@issue_params[:start_date] == 'none'), :id => nil, :data => {:disables => '#issue_start_date'} %><%= l(:button_clear) %></label>
|
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @safe_attributes.include?('due_date') %>
|
<% if @safe_attributes.include?('due_date') %>
|
||||||
<p>
|
<p>
|
||||||
<label for='issue_due_date'><%= l(:field_due_date) %></label>
|
<label for='issue_due_date'><%= l(:field_due_date) %></label>
|
||||||
<%= text_field_tag 'issue[due_date]', '', :value => @issue_params[:due_date], :size => 10 %><%= calendar_for('issue_due_date') %>
|
<%= text_field_tag 'issue[due_date]', '', :size => 10 %><%= calendar_for('issue_due_date') %>
|
||||||
<label class="inline"><%= check_box_tag 'issue[due_date]', 'none', (@issue_params[:due_date] == 'none'), :id => nil, :data => {:disables => '#issue_due_date'} %><%= l(:button_clear) %></label>
|
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @safe_attributes.include?('done_ratio') && Issue.use_field_for_done_ratio? %>
|
<% if @safe_attributes.include?('done_ratio') && Issue.use_field_for_done_ratio? %>
|
||||||
<p>
|
<p>
|
||||||
<label for='issue_done_ratio'><%= l(:field_done_ratio) %></label>
|
<label for='issue_done_ratio'><%= l(:field_done_ratio) %></label>
|
||||||
<%= select_tag 'issue[done_ratio]', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }, @issue_params[:done_ratio]) %>
|
<%= select_tag 'issue[done_ratio]', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset><legend><%= l(:field_notes) %></legend>
|
||||||
<legend><%= l(:field_notes) %></legend>
|
|
||||||
<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
|
<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
|
||||||
<%= wikitoolbar_for 'notes' %>
|
<%= wikitoolbar_for 'notes' %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<% if @copy %>
|
<% if @copy %>
|
||||||
<%= hidden_field_tag 'copy', '1' %>
|
<%= hidden_field_tag 'copy', '1' %>
|
||||||
<%= submit_tag l(:button_copy) %>
|
<%= submit_tag l(:button_copy) %>
|
||||||
<%= submit_tag l(:button_copy_and_follow), :name => 'follow' %>
|
<%= submit_tag l(:button_copy_and_follow), :name => 'follow' %>
|
||||||
<% elsif @target_project %>
|
<% elsif @target_project %>
|
||||||
<%= submit_tag l(:button_move) %>
|
<%= submit_tag l(:button_move) %>
|
||||||
<%= submit_tag l(:button_move_and_follow), :name => 'follow' %>
|
<%= submit_tag l(:button_move_and_follow), :name => 'follow' %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= submit_tag l(:button_submit) %>
|
<%= submit_tag l(:button_submit) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= javascript_tag do %>
|
|
||||||
$(window).load(function(){
|
|
||||||
$(document).on('change', 'input[data-disables]', function(){
|
|
||||||
if ($(this).attr('checked')){
|
|
||||||
$($(this).data('disables')).attr('disabled', true).val('');
|
|
||||||
} else {
|
|
||||||
$($(this).data('disables')).attr('disabled', false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$(document).ready(function(){
|
|
||||||
$('input[data-disables]').trigger('change');
|
|
||||||
});
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user