Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c36f77657 | ||
|
|
45b297f3ae | ||
|
|
0dc0860226 | ||
|
|
1c0ef8a0c2 | ||
|
|
dd3bd9a708 | ||
|
|
9ab59b43b8 | ||
|
|
e56a1c98e3 | ||
|
|
4233589ee1 | ||
|
|
4d325a3b8a | ||
|
|
16e4bdbc8a | ||
|
|
2558ad0845 | ||
|
|
08ce7df5ea | ||
|
|
d9dfa7b2b6 | ||
|
|
e573b0455b | ||
|
|
df6da812e7 | ||
|
|
8810a4a343 | ||
|
|
cf6382b92f | ||
|
|
90c44e490e | ||
|
|
004a98df86 | ||
|
|
33bf6d60d8 | ||
|
|
004ec7a251 | ||
|
|
656a656697 | ||
|
|
37c7de41ce | ||
|
|
b2e095cb87 | ||
|
|
10706c5a11 | ||
|
|
568cce5b22 | ||
|
|
48e4facc3c | ||
|
|
d42a675668 | ||
|
|
7dde34460c | ||
|
|
873a5cda4f | ||
|
|
d006e357c0 | ||
|
|
004bc127b2 | ||
|
|
70d2f30e9f | ||
|
|
6488210ec1 | ||
|
|
3cc0730f54 | ||
|
|
4491d483f4 | ||
|
|
a6252e6c6f | ||
|
|
ba074d776b | ||
|
|
bf9aea9a15 | ||
|
|
7fe9dac8c5 | ||
|
|
711328d172 | ||
|
|
342b3302cf | ||
|
|
32e3d6e1b1 | ||
|
|
8d2d46bd8e | ||
|
|
7f03576b8d | ||
|
|
e757600b39 | ||
|
|
68560c13fe | ||
|
|
309f7b75fd | ||
|
|
dbb93692ff | ||
|
|
5f6289d6be | ||
|
|
081ee54bee | ||
|
|
1d0fb85179 | ||
|
|
887e7f8647 | ||
|
|
df05edff3d | ||
|
|
67057ea3e9 | ||
|
|
381e7156c2 | ||
|
|
f9ee57f2c1 | ||
|
|
fc13aef5bb | ||
|
|
4973350243 | ||
|
|
fcbb8acdb7 | ||
|
|
d79258f17f | ||
|
|
c4736ed42b | ||
|
|
47fb2eb998 | ||
|
|
e9813791cb | ||
|
|
5f23ebc31c | ||
|
|
b88c95b0fb | ||
|
|
93d8f99884 | ||
|
|
07edb10518 | ||
|
|
0512a30368 | ||
|
|
bc945d78a6 | ||
|
|
8cd0626075 | ||
|
|
035bd65a5a | ||
|
|
955d2b134d | ||
|
|
743b55a3f9 | ||
|
|
881595f7f0 | ||
|
|
7f51bab0fc | ||
|
|
84d5092508 | ||
|
|
352d177f7e | ||
|
|
821ea2a757 | ||
|
|
7cd7b1bd8b | ||
|
|
cf139e25a7 | ||
|
|
8b09f5d27d | ||
|
|
d138df5241 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,7 +19,6 @@
|
||||
/public/plugin_assets
|
||||
/tmp/*
|
||||
/tmp/cache/*
|
||||
/tmp/pdf/*
|
||||
/tmp/sessions/*
|
||||
/tmp/sockets/*
|
||||
/tmp/test/*
|
||||
|
||||
@@ -21,7 +21,6 @@ public/dispatch.*
|
||||
public/plugin_assets
|
||||
tmp/*
|
||||
tmp/cache/*
|
||||
tmp/pdf/*
|
||||
tmp/sessions/*
|
||||
tmp/sockets/*
|
||||
tmp/test/*
|
||||
|
||||
6
Gemfile
6
Gemfile
@@ -1,7 +1,7 @@
|
||||
source 'http://rubygems.org'
|
||||
|
||||
gem 'rails', '3.2.8'
|
||||
gem "jquery-rails", "~> 2.0.2"
|
||||
gem 'rails', '3.2.6'
|
||||
gem 'prototype-rails', '3.2.1'
|
||||
gem "i18n", "~> 0.6.0"
|
||||
gem "coderay", "~> 1.0.6"
|
||||
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
|
||||
@@ -41,7 +41,7 @@ end
|
||||
|
||||
platforms :mri_18, :mingw_18 do
|
||||
group :mysql do
|
||||
gem "mysql", "~> 2.8.1"
|
||||
gem "mysql"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -40,26 +40,19 @@ class AccountController < ApplicationController
|
||||
redirect_to home_url
|
||||
end
|
||||
|
||||
# Lets user choose a new password
|
||||
# Enable user to choose a new password
|
||||
def lost_password
|
||||
redirect_to(home_url) && return unless Setting.lost_password?
|
||||
if params[:token]
|
||||
@token = Token.find_by_action_and_value("recovery", params[:token].to_s)
|
||||
if @token.nil? || @token.expired?
|
||||
redirect_to home_url
|
||||
return
|
||||
end
|
||||
@token = Token.find_by_action_and_value("recovery", params[:token])
|
||||
redirect_to(home_url) && return unless @token and !@token.expired?
|
||||
@user = @token.user
|
||||
unless @user && @user.active?
|
||||
redirect_to home_url
|
||||
return
|
||||
end
|
||||
if request.post?
|
||||
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
||||
if @user.save
|
||||
@token.destroy
|
||||
flash[:notice] = l(:notice_account_password_updated)
|
||||
redirect_to signin_path
|
||||
redirect_to :action => 'login'
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -67,23 +60,17 @@ class AccountController < ApplicationController
|
||||
return
|
||||
else
|
||||
if request.post?
|
||||
user = User.find_by_mail(params[:mail].to_s)
|
||||
# user not found or not active
|
||||
unless user && user.active?
|
||||
flash.now[:error] = l(:notice_account_unknown_email)
|
||||
return
|
||||
end
|
||||
# user cannot change its password
|
||||
unless user.change_password_allowed?
|
||||
flash.now[:error] = l(:notice_can_t_change_password)
|
||||
return
|
||||
end
|
||||
user = User.find_by_mail(params[:mail])
|
||||
# user not found in db
|
||||
(flash.now[:error] = l(:notice_account_unknown_email); return) unless user
|
||||
# user uses an external authentification
|
||||
(flash.now[:error] = l(:notice_can_t_change_password); return) if user.auth_source_id
|
||||
# create a new token for password recovery
|
||||
token = Token.new(:user => user, :action => "recovery")
|
||||
if token.save
|
||||
Mailer.lost_password(token).deliver
|
||||
flash[:notice] = l(:notice_account_lost_email_sent)
|
||||
redirect_to signin_path
|
||||
redirect_to :action => 'login'
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -97,9 +84,8 @@ class AccountController < ApplicationController
|
||||
session[:auth_source_registration] = nil
|
||||
@user = User.new(:language => Setting.default_language)
|
||||
else
|
||||
user_params = params[:user] || {}
|
||||
@user = User.new
|
||||
@user.safe_attributes = user_params
|
||||
@user.safe_attributes = params[:user]
|
||||
@user.admin = false
|
||||
@user.register
|
||||
if session[:auth_source_registration]
|
||||
@@ -114,9 +100,7 @@ class AccountController < ApplicationController
|
||||
end
|
||||
else
|
||||
@user.login = params[:user][:login]
|
||||
unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank?
|
||||
@user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation]
|
||||
end
|
||||
@user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation]
|
||||
|
||||
case Setting.self_registration
|
||||
when '1'
|
||||
@@ -142,7 +126,7 @@ class AccountController < ApplicationController
|
||||
token.destroy
|
||||
flash[:notice] = l(:notice_account_activated)
|
||||
end
|
||||
redirect_to signin_path
|
||||
redirect_to :action => 'login'
|
||||
end
|
||||
|
||||
private
|
||||
@@ -210,7 +194,6 @@ class AccountController < ApplicationController
|
||||
end
|
||||
|
||||
def successful_authentication(user)
|
||||
logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}"
|
||||
# Valid user
|
||||
self.logged_user = user
|
||||
# generate a key and set cookie if autologin
|
||||
@@ -254,7 +237,7 @@ class AccountController < ApplicationController
|
||||
if user.save and token.save
|
||||
Mailer.register(token).deliver
|
||||
flash[:notice] = l(:notice_account_register_done)
|
||||
redirect_to signin_path
|
||||
redirect_to :action => 'login'
|
||||
else
|
||||
yield if block_given?
|
||||
end
|
||||
@@ -291,6 +274,6 @@ class AccountController < ApplicationController
|
||||
|
||||
def account_pending
|
||||
flash[:notice] = l(:notice_account_pending)
|
||||
redirect_to signin_path
|
||||
redirect_to :action => 'login'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ class ActivitiesController < ApplicationController
|
||||
|
||||
events = @activity.events(@date_from, @date_to)
|
||||
|
||||
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, events.size, User.current, current_language])
|
||||
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
||||
|
||||
@@ -35,95 +35,47 @@ class ApplicationController < ActionController::Base
|
||||
cookies.delete(:autologin)
|
||||
end
|
||||
|
||||
before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization
|
||||
before_filter :user_setup, :check_if_login_required, :set_localization
|
||||
|
||||
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
|
||||
rescue_from ::Unauthorized, :with => :deny_access
|
||||
rescue_from ::ActionView::MissingTemplate, :with => :missing_template
|
||||
|
||||
include Redmine::Search::Controller
|
||||
include Redmine::MenuManager::MenuController
|
||||
helper Redmine::MenuManager::MenuHelper
|
||||
|
||||
def session_expiration
|
||||
if session[:user_id]
|
||||
if session_expired? && !try_to_autologin
|
||||
reset_session
|
||||
flash[:error] = l(:error_session_expired)
|
||||
redirect_to signin_url
|
||||
else
|
||||
session[:atime] = Time.now.utc.to_i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def session_expired?
|
||||
if Setting.session_lifetime?
|
||||
unless session[:ctime] && (Time.now.utc.to_i - session[:ctime].to_i <= Setting.session_lifetime.to_i * 60)
|
||||
return true
|
||||
end
|
||||
end
|
||||
if Setting.session_timeout?
|
||||
unless session[:atime] && (Time.now.utc.to_i - session[:atime].to_i <= Setting.session_timeout.to_i * 60)
|
||||
return true
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def start_user_session(user)
|
||||
session[:user_id] = user.id
|
||||
session[:ctime] = Time.now.utc.to_i
|
||||
session[:atime] = Time.now.utc.to_i
|
||||
end
|
||||
|
||||
def user_setup
|
||||
# Check the settings cache for each request
|
||||
Setting.check_cache
|
||||
# Find the current user
|
||||
User.current = find_current_user
|
||||
logger.info(" Current user: " + (User.current.logged? ? "#{User.current.login} (id=#{User.current.id})" : "anonymous")) if logger
|
||||
end
|
||||
|
||||
# Returns the current user or nil if no user is logged in
|
||||
# and starts a session if needed
|
||||
def find_current_user
|
||||
user = nil
|
||||
unless api_request?
|
||||
if session[:user_id]
|
||||
# existing session
|
||||
user = (User.active.find(session[:user_id]) rescue nil)
|
||||
elsif autologin_user = try_to_autologin
|
||||
user = autologin_user
|
||||
elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?
|
||||
# RSS key authentication does not start a session
|
||||
user = User.find_by_rss_key(params[:key])
|
||||
end
|
||||
end
|
||||
if user.nil? && Setting.rest_api_enabled? && accept_api_auth?
|
||||
if session[:user_id]
|
||||
# existing session
|
||||
(User.active.find(session[:user_id]) rescue nil)
|
||||
elsif cookies[:autologin] && Setting.autologin?
|
||||
# auto-login feature starts a new session
|
||||
user = User.try_to_autologin(cookies[:autologin])
|
||||
session[:user_id] = user.id if user
|
||||
user
|
||||
elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?
|
||||
# RSS key authentication does not start a session
|
||||
User.find_by_rss_key(params[:key])
|
||||
elsif Setting.rest_api_enabled? && accept_api_auth?
|
||||
if (key = api_key_from_request)
|
||||
# Use API key
|
||||
user = User.find_by_api_key(key)
|
||||
User.find_by_api_key(key)
|
||||
else
|
||||
# HTTP Basic, either username/password or API key/random
|
||||
authenticate_with_http_basic do |username, password|
|
||||
user = User.try_to_login(username, password) || User.find_by_api_key(username)
|
||||
User.try_to_login(username, password) || User.find_by_api_key(username)
|
||||
end
|
||||
end
|
||||
end
|
||||
user
|
||||
end
|
||||
|
||||
def try_to_autologin
|
||||
if cookies[:autologin] && Setting.autologin?
|
||||
# auto-login feature starts a new session
|
||||
user = User.try_to_autologin(cookies[:autologin])
|
||||
if user
|
||||
reset_session
|
||||
start_user_session(user)
|
||||
end
|
||||
user
|
||||
end
|
||||
end
|
||||
|
||||
# Sets the logged in user
|
||||
@@ -131,7 +83,7 @@ class ApplicationController < ActionController::Base
|
||||
reset_session
|
||||
if user && user.is_a?(User)
|
||||
User.current = user
|
||||
start_user_session(user)
|
||||
session[:user_id] = user.id
|
||||
else
|
||||
User.current = User.anonymous
|
||||
end
|
||||
@@ -283,7 +235,7 @@ class ApplicationController < ActionController::Base
|
||||
# make sure that the user is a member of the project (or admin) if project is private
|
||||
# used as a before_filter for actions that do not require any particular permission on the project
|
||||
def check_project_privacy
|
||||
if @project && !@project.archived?
|
||||
if @project && @project.active?
|
||||
if @project.visible?
|
||||
true
|
||||
else
|
||||
@@ -297,16 +249,12 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def back_url
|
||||
url = params[:back_url]
|
||||
if url.nil? && referer = request.env['HTTP_REFERER']
|
||||
url = CGI.unescape(referer.to_s)
|
||||
end
|
||||
url
|
||||
params[:back_url] || request.env['HTTP_REFERER']
|
||||
end
|
||||
|
||||
def redirect_back_or_default(default)
|
||||
back_url = params[:back_url].to_s
|
||||
if back_url.present?
|
||||
back_url = CGI.unescape(params[:back_url].to_s)
|
||||
if !back_url.blank?
|
||||
begin
|
||||
uri = URI.parse(back_url)
|
||||
# do not redirect user to another host or to the login or register page
|
||||
@@ -315,7 +263,6 @@ class ApplicationController < ActionController::Base
|
||||
return
|
||||
end
|
||||
rescue URI::InvalidURIError
|
||||
logger.warn("Could not redirect to invalid URL #{back_url}")
|
||||
# redirect to default
|
||||
end
|
||||
end
|
||||
@@ -359,17 +306,13 @@ class ApplicationController < ActionController::Base
|
||||
format.html {
|
||||
render :template => 'common/error', :layout => use_layout, :status => @status
|
||||
}
|
||||
format.any { head @status }
|
||||
format.atom { head @status }
|
||||
format.xml { head @status }
|
||||
format.js { head @status }
|
||||
format.json { head @status }
|
||||
end
|
||||
end
|
||||
|
||||
# Handler for ActionView::MissingTemplate exception
|
||||
def missing_template
|
||||
logger.warn "Missing template, responding with 404"
|
||||
@project = nil
|
||||
render_404
|
||||
end
|
||||
|
||||
|
||||
# Filter for actions that provide an API response
|
||||
# but have no HTML representation for non admin users
|
||||
def require_admin_or_api_request
|
||||
@@ -536,12 +479,6 @@ class ApplicationController < ActionController::Base
|
||||
render_error "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator."
|
||||
end
|
||||
|
||||
# Renders a 200 response for successfull updates or deletions via the API
|
||||
def render_api_ok
|
||||
# head :ok would return a response body with one space
|
||||
render :text => '', :status => :ok, :layout => nil
|
||||
end
|
||||
|
||||
# Renders API response on validation failure
|
||||
def render_validation_errors(objects)
|
||||
if objects.is_a?(Array)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
class AttachmentsController < ApplicationController
|
||||
before_filter :find_project, :except => :upload
|
||||
before_filter :file_readable, :read_authorize, :only => [:show, :download, :thumbnail]
|
||||
before_filter :file_readable, :read_authorize, :only => [:show, :download]
|
||||
before_filter :delete_authorize, :only => :destroy
|
||||
before_filter :authorize_global, :only => :upload
|
||||
|
||||
@@ -52,26 +52,11 @@ class AttachmentsController < ApplicationController
|
||||
@attachment.increment_download
|
||||
end
|
||||
|
||||
if stale?(:etag => @attachment.digest)
|
||||
# images are sent inline
|
||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => detect_content_type(@attachment),
|
||||
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
||||
end
|
||||
end
|
||||
# images are sent inline
|
||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => detect_content_type(@attachment),
|
||||
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
||||
|
||||
def thumbnail
|
||||
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
|
||||
if stale?(:etag => thumbnail)
|
||||
send_file thumbnail,
|
||||
:filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => detect_content_type(@attachment),
|
||||
:disposition => 'inline'
|
||||
end
|
||||
else
|
||||
# No thumbnail for the attachment or thumbnail could not be created
|
||||
render :nothing => true, :status => 404
|
||||
end
|
||||
end
|
||||
|
||||
def upload
|
||||
|
||||
@@ -20,25 +20,25 @@ class AutoCompletesController < ApplicationController
|
||||
|
||||
def issues
|
||||
@issues = []
|
||||
q = (params[:q] || params[:term]).to_s.strip
|
||||
if q.present?
|
||||
scope = (params[:scope] == "all" || @project.nil? ? Issue : @project.issues).visible
|
||||
if q.match(/^\d+$/)
|
||||
@issues << scope.find_by_id(q.to_i)
|
||||
end
|
||||
@issues += scope.where("LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%").order("#{Issue.table_name}.id DESC").limit(10).all
|
||||
@issues.compact!
|
||||
q = params[:q].to_s
|
||||
query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues
|
||||
if q.match(/^\d+$/)
|
||||
@issues << query.visible.find_by_id(q.to_i)
|
||||
end
|
||||
unless q.blank?
|
||||
@issues += query.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
|
||||
end
|
||||
@issues.compact!
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_project
|
||||
if params[:project_id].present?
|
||||
@project = Project.find(params[:project_id])
|
||||
end
|
||||
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
|
||||
@project = Project.find(project_id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ class BoardsController < ApplicationController
|
||||
helper :watchers
|
||||
|
||||
def index
|
||||
@boards = @project.boards.includes(:last_message => :author).all
|
||||
@boards = @project.boards
|
||||
# show the board if there is only one
|
||||
if @boards.size == 1
|
||||
@board = @boards.first
|
||||
|
||||
@@ -24,7 +24,6 @@ class ContextMenusController < ApplicationController
|
||||
if (@issues.size == 1)
|
||||
@issue = @issues.first
|
||||
end
|
||||
@issue_ids = @issues.map(&:id).sort
|
||||
|
||||
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
||||
@projects = @issues.collect(&:project).compact.uniq
|
||||
@@ -49,7 +48,6 @@ class ContextMenusController < ApplicationController
|
||||
@assignables = @projects.map(&:assignable_users).reduce(:&)
|
||||
@trackers = @projects.map(&:trackers).reduce(:&)
|
||||
end
|
||||
@versions = @projects.map {|p| p.shared_versions.open}.reduce(:&)
|
||||
|
||||
@priorities = IssuePriority.active.reverse
|
||||
@back = back_url
|
||||
@@ -67,7 +65,6 @@ class ContextMenusController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
|
||||
@@ -19,34 +19,51 @@ class GroupsController < ApplicationController
|
||||
layout 'admin'
|
||||
|
||||
before_filter :require_admin
|
||||
before_filter :find_group, :except => [:index, :new, :create]
|
||||
accept_api_auth :index, :show, :create, :update, :destroy, :add_users, :remove_user
|
||||
|
||||
helper :custom_fields
|
||||
|
||||
# GET /groups
|
||||
# GET /groups.xml
|
||||
def index
|
||||
@groups = Group.sorted.all
|
||||
@groups = Group.find(:all, :order => 'lastname')
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.api
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @groups }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /groups/1
|
||||
# GET /groups/1.xml
|
||||
def show
|
||||
@group = Group.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.api
|
||||
format.html # show.html.erb
|
||||
format.xml { render :xml => @group }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /groups/new
|
||||
# GET /groups/new.xml
|
||||
def new
|
||||
@group = Group.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @group }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /groups/1/edit
|
||||
def edit
|
||||
@group = Group.find(params[:id], :include => :projects)
|
||||
end
|
||||
|
||||
# POST /groups
|
||||
# POST /groups.xml
|
||||
def create
|
||||
@group = Group.new
|
||||
@group.safe_attributes = params[:group]
|
||||
@group = Group.new(params[:group])
|
||||
|
||||
respond_to do |format|
|
||||
if @group.save
|
||||
@@ -54,87 +71,102 @@ class GroupsController < ApplicationController
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to(params[:continue] ? new_group_path : groups_path)
|
||||
}
|
||||
format.api { render :action => 'show', :status => :created, :location => group_url(@group) }
|
||||
format.xml { render :xml => @group, :status => :created, :location => @group }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.api { render_validation_errors(@group) }
|
||||
format.xml { render :xml => @group.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
# PUT /groups/1
|
||||
# PUT /groups/1.xml
|
||||
def update
|
||||
@group.safe_attributes = params[:group]
|
||||
@group = Group.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @group.save
|
||||
if @group.update_attributes(params[:group])
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
format.html { redirect_to(groups_path) }
|
||||
format.api { render_api_ok }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.api { render_validation_errors(@group) }
|
||||
format.xml { render :xml => @group.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /groups/1
|
||||
# DELETE /groups/1.xml
|
||||
def destroy
|
||||
@group = Group.find(params[:id])
|
||||
@group.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(groups_url) }
|
||||
format.api { render_api_ok }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
|
||||
def add_users
|
||||
@users = User.find_all_by_id(params[:user_id] || params[:user_ids])
|
||||
@group.users << @users if request.post?
|
||||
@group = Group.find(params[:id])
|
||||
users = User.find_all_by_id(params[:user_ids])
|
||||
@group.users << users if request.post?
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
|
||||
format.js
|
||||
format.api { render_api_ok }
|
||||
format.js {
|
||||
render(:update) {|page|
|
||||
page.replace_html "tab-content-users", :partial => 'groups/users'
|
||||
users.each {|user| page.visual_effect(:highlight, "user-#{user.id}") }
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def remove_user
|
||||
@group = Group.find(params[:id])
|
||||
@group.users.delete(User.find(params[:user_id])) if request.delete?
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
|
||||
format.js
|
||||
format.api { render_api_ok }
|
||||
format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} }
|
||||
end
|
||||
end
|
||||
|
||||
def autocomplete_for_user
|
||||
@group = Group.find(params[:id])
|
||||
@users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100)
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def edit_membership
|
||||
@group = Group.find(params[:id])
|
||||
@membership = Member.edit_membership(params[:membership_id], params[:membership], @group)
|
||||
@membership.save if request.post?
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
|
||||
format.js
|
||||
if @membership.valid?
|
||||
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
|
||||
format.js {
|
||||
render(:update) {|page|
|
||||
page.replace_html "tab-content-memberships", :partial => 'groups/memberships'
|
||||
page.visual_effect(:highlight, "member-#{@membership.id}")
|
||||
}
|
||||
}
|
||||
else
|
||||
format.js {
|
||||
render(:update) {|page|
|
||||
page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_membership
|
||||
@group = Group.find(params[:id])
|
||||
Member.find(params[:membership_id]).destroy if request.post?
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
|
||||
format.js
|
||||
format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'groups/memberships'} }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_group
|
||||
@group = Group.find(params[:id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,11 +41,6 @@ class IssueCategoriesController < ApplicationController
|
||||
def new
|
||||
@category = @project.issue_categories.build
|
||||
@category.safe_attributes = params[:issue_category]
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -57,13 +52,20 @@ class IssueCategoriesController < ApplicationController
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
|
||||
end
|
||||
format.js
|
||||
format.js do
|
||||
# IE doesn't support the replace_html rjs method for select box options
|
||||
render(:update) {|page| page.replace "issue_category_id",
|
||||
content_tag('select', content_tag('option') + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
|
||||
}
|
||||
end
|
||||
format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new'}
|
||||
format.js { render :action => 'new'}
|
||||
format.js do
|
||||
render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) }
|
||||
end
|
||||
format.api { render_validation_errors(@category) }
|
||||
end
|
||||
end
|
||||
@@ -80,7 +82,7 @@ class IssueCategoriesController < ApplicationController
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
format.api { head :ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
@@ -100,7 +102,7 @@ class IssueCategoriesController < ApplicationController
|
||||
@category.destroy(reassign_to)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' }
|
||||
format.api { render_api_ok }
|
||||
format.api { head :ok }
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -49,9 +49,16 @@ class IssueRelationsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
||||
format.js {
|
||||
format.js do
|
||||
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
|
||||
}
|
||||
render :update do |page|
|
||||
page.replace_html "relations", :partial => 'issues/relations'
|
||||
if @relation.errors.empty?
|
||||
page << "$('relation_delay').value = ''"
|
||||
page << "$('relation_issue_to_id').value = ''"
|
||||
end
|
||||
end
|
||||
end
|
||||
format.api {
|
||||
if saved
|
||||
render :action => 'show', :status => :created, :location => relation_url(@relation)
|
||||
@@ -68,8 +75,8 @@ class IssueRelationsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to issue_path } # TODO : does this really work since @issue is always nil? What is it useful to?
|
||||
format.js
|
||||
format.api { render_api_ok }
|
||||
format.js { render(:update) {|page| page.remove "relation-#{@relation.id}"} }
|
||||
format.api { head :ok }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ class IssuesController < ApplicationController
|
||||
include SortHelper
|
||||
include IssuesHelper
|
||||
helper :timelog
|
||||
helper :gantt
|
||||
include Redmine::Export::PDF
|
||||
|
||||
def index
|
||||
@@ -127,7 +128,17 @@ class IssuesController < ApplicationController
|
||||
def new
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new', :layout => !request.xhr? }
|
||||
format.js { render :partial => 'update_form' }
|
||||
format.js {
|
||||
render(:update) { |page|
|
||||
if params[:project_change]
|
||||
page.replace_html 'all_attributes', :partial => 'form'
|
||||
else
|
||||
page.replace_html 'attributes', :partial => 'attributes'
|
||||
end
|
||||
m = User.current.allowed_to?(:log_time, @issue.project) ? 'show' : 'hide'
|
||||
page << "if ($('log_time')) {Element.#{m}('log_time');}"
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -139,7 +150,7 @@ class IssuesController < ApplicationController
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render_attachment_warning_if_needed(@issue)
|
||||
flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject))
|
||||
flash[:notice] = l(:notice_issue_successful_create, :id => "<a href='#{issue_path(@issue)}'>##{@issue.id}</a>")
|
||||
redirect_to(params[:continue] ? { :action => 'new', :project_id => @issue.project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
|
||||
{ :action => 'show', :id => @issue })
|
||||
}
|
||||
@@ -172,7 +183,12 @@ class IssuesController < ApplicationController
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
@conflict = true
|
||||
if params[:last_journal_id]
|
||||
@conflict_journals = @issue.journals_after(params[:last_journal_id]).all
|
||||
if params[:last_journal_id].present?
|
||||
last_journal_id = params[:last_journal_id].to_i
|
||||
@conflict_journals = @issue.journals.all(:conditions => ["#{Journal.table_name}.id > ?", last_journal_id])
|
||||
else
|
||||
@conflict_journals = @issue.journals.all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -182,7 +198,7 @@ class IssuesController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_default({:action => 'show', :id => @issue}) }
|
||||
format.api { render_api_ok }
|
||||
format.api { head :ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
@@ -221,7 +237,6 @@ class IssuesController < ApplicationController
|
||||
@categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
|
||||
if @copy
|
||||
@attachments_present = @issues.detect {|i| i.attachments.any?}.present?
|
||||
@subtasks_present = @issues.detect {|i| !i.leaf?}.present?
|
||||
end
|
||||
|
||||
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
|
||||
@@ -235,20 +250,10 @@ class IssuesController < ApplicationController
|
||||
|
||||
unsaved_issue_ids = []
|
||||
moved_issues = []
|
||||
|
||||
if @copy && params[:copy_subtasks].present?
|
||||
# Descendant issues will be copied with the parent task
|
||||
# Don't copy them twice
|
||||
@issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
|
||||
end
|
||||
|
||||
@issues.each do |issue|
|
||||
issue.reload
|
||||
if @copy
|
||||
issue = issue.copy({},
|
||||
:attachments => params[:copy_attachments].present?,
|
||||
:subtasks => params[:copy_subtasks].present?
|
||||
)
|
||||
issue = issue.copy({}, :attachments => params[:copy_attachments].present?)
|
||||
end
|
||||
journal = issue.init_journal(User.current, params[:notes])
|
||||
issue.safe_attributes = attributes
|
||||
@@ -303,7 +308,7 @@ class IssuesController < ApplicationController
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
|
||||
format.api { render_api_ok }
|
||||
format.api { head :ok }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -385,8 +390,7 @@ private
|
||||
begin
|
||||
@copy_from = Issue.visible.find(params[:copy_from])
|
||||
@copy_attachments = params[:copy_attachments].present? || request.get?
|
||||
@copy_subtasks = params[:copy_subtasks].present? || request.get?
|
||||
@issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks)
|
||||
@issue.copy_from(@copy_from, :attachments => @copy_attachments)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
return
|
||||
@@ -398,7 +402,7 @@ private
|
||||
end
|
||||
|
||||
@issue.project = @project
|
||||
@issue.author ||= User.current
|
||||
@issue.author = User.current
|
||||
# Tracker must be set before custom field values
|
||||
@issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
|
||||
if @issue.tracker.nil?
|
||||
|
||||
@@ -67,8 +67,16 @@ class JournalsController < ApplicationController
|
||||
end
|
||||
# Replaces pre blocks with [...]
|
||||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
||||
@content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
||||
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
||||
content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
|
||||
render(:update) { |page|
|
||||
page.<< "$('notes').value = \"#{escape_javascript content}\";"
|
||||
page.show 'update'
|
||||
page << "Form.Element.focus('notes');"
|
||||
page << "Element.scrollTo('update');"
|
||||
page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
|
||||
}
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
@@ -63,16 +63,31 @@ class MembersController < ApplicationController
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
||||
format.js { @members = members }
|
||||
format.api {
|
||||
@member = members.first
|
||||
if @member.valid?
|
||||
if members.present? && members.all? {|m| m.valid? }
|
||||
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
||||
format.js {
|
||||
render(:update) {|page|
|
||||
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
|
||||
page << 'hideOnLoad()'
|
||||
members.each {|member| page.visual_effect(:highlight, "member-#{member.id}") }
|
||||
}
|
||||
}
|
||||
format.api {
|
||||
@member = members.first
|
||||
render :action => 'show', :status => :created, :location => membership_url(@member)
|
||||
else
|
||||
render_validation_errors(@member)
|
||||
end
|
||||
}
|
||||
}
|
||||
else
|
||||
format.js {
|
||||
render(:update) {|page|
|
||||
errors = members.collect {|m|
|
||||
m.errors.full_messages
|
||||
}.flatten.uniq
|
||||
|
||||
page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', ')))
|
||||
}
|
||||
}
|
||||
format.api { render_validation_errors(members.first) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -83,10 +98,16 @@ class MembersController < ApplicationController
|
||||
saved = @member.save
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
||||
format.js
|
||||
format.js {
|
||||
render(:update) {|page|
|
||||
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
|
||||
page << 'hideOnLoad()'
|
||||
page.visual_effect(:highlight, "member-#{@member.id}")
|
||||
}
|
||||
}
|
||||
format.api {
|
||||
if saved
|
||||
render_api_ok
|
||||
head :ok
|
||||
else
|
||||
render_validation_errors(@member)
|
||||
end
|
||||
@@ -100,10 +121,14 @@ class MembersController < ApplicationController
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
||||
format.js
|
||||
format.js { render(:update) {|page|
|
||||
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
|
||||
page << 'hideOnLoad()'
|
||||
}
|
||||
}
|
||||
format.api {
|
||||
if @member.destroyed?
|
||||
render_api_ok
|
||||
head :ok
|
||||
else
|
||||
head :unprocessable_entity
|
||||
end
|
||||
@@ -115,4 +140,5 @@ class MembersController < ApplicationController
|
||||
@principals = Principal.active.not_member_of(@project).like(params[:q]).all(:limit => 100)
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -22,7 +22,6 @@ class MessagesController < ApplicationController
|
||||
before_filter :find_message, :except => [:new, :preview]
|
||||
before_filter :authorize, :except => [:preview, :edit, :destroy]
|
||||
|
||||
helper :boards
|
||||
helper :watchers
|
||||
helper :attachments
|
||||
include AttachmentsHelper
|
||||
@@ -60,7 +59,7 @@ class MessagesController < ApplicationController
|
||||
if @message.save
|
||||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
||||
render_attachment_warning_if_needed(@message)
|
||||
redirect_to board_message_path(@board, @message)
|
||||
redirect_to :action => 'show', :id => @message
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -77,7 +76,7 @@ class MessagesController < ApplicationController
|
||||
attachments = Attachment.attach_files(@reply, params[:attachments])
|
||||
render_attachment_warning_if_needed(@reply)
|
||||
end
|
||||
redirect_to board_message_path(@board, @topic, :r => @reply)
|
||||
redirect_to :action => 'show', :id => @topic, :r => @reply
|
||||
end
|
||||
|
||||
# Edit a message
|
||||
@@ -89,7 +88,7 @@ class MessagesController < ApplicationController
|
||||
render_attachment_warning_if_needed(@message)
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
@message.reload
|
||||
redirect_to board_message_path(@message.board, @message.root, :r => (@message.parent_id && @message.id))
|
||||
redirect_to :action => 'show', :board_id => @message.board, :id => @message.root, :r => (@message.parent_id && @message.id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -98,26 +97,32 @@ class MessagesController < ApplicationController
|
||||
(render_403; return false) unless @message.destroyable_by?(User.current)
|
||||
r = @message.to_param
|
||||
@message.destroy
|
||||
if @message.parent
|
||||
redirect_to board_message_path(@board, @message.parent, :r => r)
|
||||
else
|
||||
redirect_to project_board_path(@project, @board)
|
||||
end
|
||||
redirect_to @message.parent.nil? ?
|
||||
{ :controller => 'boards', :action => 'show', :project_id => @project, :id => @board } :
|
||||
{ :action => 'show', :id => @message.parent, :r => r }
|
||||
end
|
||||
|
||||
def quote
|
||||
@subject = @message.subject
|
||||
@subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
|
||||
|
||||
@content = "#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
|
||||
@content << @message.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
user = @message.author
|
||||
text = @message.content
|
||||
subject = @message.subject.gsub('"', '\"')
|
||||
subject = "RE: #{subject}" unless subject.starts_with?('RE:')
|
||||
content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> "
|
||||
content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n"
|
||||
render(:update) { |page|
|
||||
page << "$('message_subject').value = \"#{subject}\";"
|
||||
page.<< "$('message_content').value = \"#{content}\";"
|
||||
page.show 'reply'
|
||||
page << "Form.Element.focus('message_content');"
|
||||
page << "Element.scrollTo('reply');"
|
||||
page << "$('message_content').scrollTop = $('message_content').scrollHeight - $('message_content').clientHeight;"
|
||||
}
|
||||
end
|
||||
|
||||
def preview
|
||||
message = @board.messages.find_by_id(params[:id])
|
||||
@attachements = message.attachments if message
|
||||
@text = (params[:message] || params[:reply])[:content]
|
||||
@previewed = message
|
||||
render :partial => 'common/preview'
|
||||
end
|
||||
|
||||
|
||||
@@ -135,11 +135,7 @@ class MyController < ApplicationController
|
||||
@user = User.current
|
||||
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup
|
||||
@block_options = []
|
||||
BLOCKS.each do |k, v|
|
||||
unless %w(top left right).detect {|f| (@blocks[f] ||= []).include?(k)}
|
||||
@block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize]
|
||||
end
|
||||
end
|
||||
BLOCKS.each {|k, v| @block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize]}
|
||||
end
|
||||
|
||||
# Add a block to user's page
|
||||
@@ -156,7 +152,7 @@ class MyController < ApplicationController
|
||||
layout['top'].unshift block
|
||||
@user.pref[:my_page_layout] = layout
|
||||
@user.pref.save
|
||||
redirect_to :action => 'page_layout'
|
||||
render :partial => "block", :locals => {:user => @user, :block_name => block}
|
||||
end
|
||||
|
||||
# Remove a block to user's page
|
||||
@@ -169,7 +165,7 @@ class MyController < ApplicationController
|
||||
%w(top left right).each {|f| (layout[f] ||= []).delete block }
|
||||
@user.pref[:my_page_layout] = layout
|
||||
@user.pref.save
|
||||
redirect_to :action => 'page_layout'
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
# Change blocks order on user's page
|
||||
@@ -179,8 +175,7 @@ class MyController < ApplicationController
|
||||
group = params[:group]
|
||||
@user = User.current
|
||||
if group.is_a?(String)
|
||||
group_items = (params["blocks"] || []).collect(&:underscore)
|
||||
group_items.each {|s| s.sub!(/^block_/, '')}
|
||||
group_items = (params["list-#{group}"] || []).collect(&:underscore)
|
||||
if group_items and group_items.is_a? Array
|
||||
layout = @user.pref[:my_page_layout] || {}
|
||||
# remove group blocks if they are presents in other groups
|
||||
|
||||
@@ -48,11 +48,7 @@ class ProjectsController < ApplicationController
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
scope = Project
|
||||
unless params[:closed]
|
||||
scope = scope.active
|
||||
end
|
||||
@projects = scope.visible.order('lft').all
|
||||
@projects = Project.visible.find(:all, :order => 'lft')
|
||||
}
|
||||
format.api {
|
||||
@offset, @limit = api_offset_and_limit
|
||||
@@ -69,14 +65,14 @@ class ProjectsController < ApplicationController
|
||||
|
||||
def new
|
||||
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||||
@trackers = Tracker.sorted.all
|
||||
@trackers = Tracker.all
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
end
|
||||
|
||||
def create
|
||||
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||||
@trackers = Tracker.sorted.all
|
||||
@trackers = Tracker.all
|
||||
@project = Project.new
|
||||
@project.safe_attributes = params[:project]
|
||||
|
||||
@@ -109,7 +105,7 @@ class ProjectsController < ApplicationController
|
||||
|
||||
def copy
|
||||
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||||
@trackers = Tracker.sorted.all
|
||||
@trackers = Tracker.all
|
||||
@root_projects = Project.find(:all,
|
||||
:conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
|
||||
:order => 'name')
|
||||
@@ -156,8 +152,12 @@ class ProjectsController < ApplicationController
|
||||
|
||||
cond = @project.project_condition(Setting.display_subprojects_issues?)
|
||||
|
||||
@open_issues_by_tracker = Issue.visible.open.where(cond).count(:group => :tracker)
|
||||
@total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker)
|
||||
@open_issues_by_tracker = Issue.visible.count(:group => :tracker,
|
||||
:include => [:project, :status, :tracker],
|
||||
:conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false])
|
||||
@total_issues_by_tracker = Issue.visible.count(:group => :tracker,
|
||||
:include => [:project, :status, :tracker],
|
||||
:conditions => cond)
|
||||
|
||||
if User.current.allowed_to?(:view_time_entries, @project)
|
||||
@total_hours = TimeEntry.visible.sum(:hours, :include => :project, :conditions => cond).to_f
|
||||
@@ -175,7 +175,7 @@ class ProjectsController < ApplicationController
|
||||
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||||
@issue_category ||= IssueCategory.new
|
||||
@member ||= @project.members.new
|
||||
@trackers = Tracker.sorted.all
|
||||
@trackers = Tracker.all
|
||||
@wiki ||= @project.wiki
|
||||
end
|
||||
|
||||
@@ -191,7 +191,7 @@ class ProjectsController < ApplicationController
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'settings', :id => @project
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
format.api { head :ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
@@ -224,16 +224,6 @@ class ProjectsController < ApplicationController
|
||||
redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status]))
|
||||
end
|
||||
|
||||
def close
|
||||
@project.close
|
||||
redirect_to project_path(@project)
|
||||
end
|
||||
|
||||
def reopen
|
||||
@project.reopen
|
||||
redirect_to project_path(@project)
|
||||
end
|
||||
|
||||
# Delete @project
|
||||
def destroy
|
||||
@project_to_destroy = @project
|
||||
@@ -241,7 +231,7 @@ class ProjectsController < ApplicationController
|
||||
@project_to_destroy.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'admin', :action => 'projects' }
|
||||
format.api { render_api_ok }
|
||||
format.api { head :ok }
|
||||
end
|
||||
end
|
||||
# hide project in layout
|
||||
|
||||
@@ -22,7 +22,7 @@ class ReportsController < ApplicationController
|
||||
def issue_report
|
||||
@trackers = @project.trackers
|
||||
@versions = @project.shared_versions.sort
|
||||
@priorities = IssuePriority.all.reverse
|
||||
@priorities = IssuePriority.all
|
||||
@categories = @project.issue_categories
|
||||
@assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort
|
||||
@authors = @project.users.sort
|
||||
@@ -53,7 +53,7 @@ class ReportsController < ApplicationController
|
||||
@report_title = l(:field_version)
|
||||
when "priority"
|
||||
@field = "priority_id"
|
||||
@rows = IssuePriority.all.reverse
|
||||
@rows = IssuePriority.all
|
||||
@data = Issue.by_priority(@project)
|
||||
@report_title = l(:field_priority)
|
||||
when "category"
|
||||
|
||||
@@ -42,12 +42,12 @@ class RepositoriesController < ApplicationController
|
||||
@repository = Repository.factory(scm)
|
||||
@repository.is_default = @project.repository.nil?
|
||||
@repository.project = @project
|
||||
render :layout => !request.xhr?
|
||||
end
|
||||
|
||||
def create
|
||||
attrs = pickup_extra_info
|
||||
@repository = Repository.factory(params[:repository_scm])
|
||||
@repository.safe_attributes = params[:repository]
|
||||
@repository = Repository.factory(params[:repository_scm], attrs[:attrs])
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
@@ -64,7 +64,7 @@ class RepositoriesController < ApplicationController
|
||||
|
||||
def update
|
||||
attrs = pickup_extra_info
|
||||
@repository.safe_attributes = attrs[:attrs]
|
||||
@repository.attributes = attrs[:attrs]
|
||||
if attrs[:attrs_extra].keys.any?
|
||||
@repository.merge_extra_info(attrs[:attrs_extra])
|
||||
end
|
||||
@@ -176,7 +176,6 @@ class RepositoriesController < ApplicationController
|
||||
send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
|
||||
send_type = Redmine::MimeType.of(@path)
|
||||
send_opt[:type] = send_type.to_s if send_type
|
||||
send_opt[:disposition] = (Redmine::MimeType.is_type?('image', @path) && !is_raw ? 'inline' : 'attachment')
|
||||
send_data @content, send_opt
|
||||
else
|
||||
# Prevent empty lines when displaying a file with Windows style eol
|
||||
@@ -235,6 +234,22 @@ class RepositoriesController < ApplicationController
|
||||
|
||||
if @issue
|
||||
@changeset.issues << @issue
|
||||
respond_to do |format|
|
||||
format.js {
|
||||
render :update do |page|
|
||||
page.replace_html "related-issues", :partial => "related_issues"
|
||||
page.visual_effect :highlight, "related-issue-#{@issue.id}"
|
||||
end
|
||||
}
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.js {
|
||||
render :update do |page|
|
||||
page.alert(l(:label_issue) + ' ' + l('activerecord.errors.messages.invalid'))
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -245,6 +260,14 @@ class RepositoriesController < ApplicationController
|
||||
if @issue
|
||||
@changeset.issues.delete(@issue)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js {
|
||||
render :update do |page|
|
||||
page.remove "related-issue-#{@issue.id}"
|
||||
end if @issue
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def diff
|
||||
@@ -431,3 +454,4 @@ class RepositoriesController < ApplicationController
|
||||
graph.burn
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -36,11 +36,8 @@ class RolesController < ApplicationController
|
||||
end
|
||||
|
||||
def new
|
||||
# Prefills the form with 'Non member' role permissions by default
|
||||
# Prefills the form with 'Non member' role permissions
|
||||
@role = Role.new(params[:role] || {:permissions => Role.non_member.permissions})
|
||||
if params[:copy].present? && @copy_from = Role.find_by_id(params[:copy])
|
||||
@role.copy_from(@copy_from)
|
||||
end
|
||||
@roles = Role.sorted.all
|
||||
end
|
||||
|
||||
@@ -49,7 +46,7 @@ class RolesController < ApplicationController
|
||||
if request.post? && @role.save
|
||||
# workflow copy
|
||||
if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
|
||||
@role.workflow_rules.copy(copy_from)
|
||||
@role.workflows.copy(copy_from)
|
||||
end
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :action => 'index'
|
||||
|
||||
@@ -171,7 +171,7 @@ class TimelogController < ApplicationController
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_back_or_default :action => 'index', :project_id => @time_entry.project
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
format.api { head :ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
@@ -223,7 +223,7 @@ class TimelogController < ApplicationController
|
||||
}
|
||||
format.api {
|
||||
if destroyed
|
||||
render_api_ok
|
||||
head :ok
|
||||
else
|
||||
render_validation_errors(@time_entries)
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ class TrackersController < ApplicationController
|
||||
render :action => "index", :layout => false if request.xhr?
|
||||
}
|
||||
format.api {
|
||||
@trackers = Tracker.sorted.all
|
||||
@trackers = Tracker.all
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -45,7 +45,7 @@ class TrackersController < ApplicationController
|
||||
if request.post? and @tracker.save
|
||||
# workflow copy
|
||||
if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
|
||||
@tracker.workflow_rules.copy(copy_from)
|
||||
@tracker.workflows.copy(copy_from)
|
||||
end
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :action => 'index'
|
||||
@@ -80,22 +80,4 @@ class TrackersController < ApplicationController
|
||||
end
|
||||
redirect_to :action => 'index'
|
||||
end
|
||||
|
||||
def fields
|
||||
if request.post? && params[:trackers]
|
||||
params[:trackers].each do |tracker_id, tracker_params|
|
||||
tracker = Tracker.find_by_id(tracker_id)
|
||||
if tracker
|
||||
tracker.core_fields = tracker_params[:core_fields]
|
||||
tracker.custom_field_ids = tracker_params[:custom_field_ids]
|
||||
tracker.save
|
||||
end
|
||||
end
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'fields'
|
||||
return
|
||||
end
|
||||
@trackers = Tracker.sorted.all
|
||||
@custom_fields = IssueCustomField.all.sort
|
||||
end
|
||||
end
|
||||
|
||||
@@ -103,7 +103,7 @@ class UsersController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_user_successful_create, :id => view_context.link_to(@user.login, user_path(@user)))
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to(params[:continue] ?
|
||||
{:controller => 'users', :action => 'new'} :
|
||||
{:controller => 'users', :action => 'edit', :id => @user}
|
||||
@@ -156,7 +156,7 @@ class UsersController < ApplicationController
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to_referer_or edit_user_path(@user)
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
format.api { head :ok }
|
||||
end
|
||||
else
|
||||
@auth_sources = AuthSource.find(:all)
|
||||
@@ -174,8 +174,8 @@ class UsersController < ApplicationController
|
||||
def destroy
|
||||
@user.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_default(users_url) }
|
||||
format.api { render_api_ok }
|
||||
format.html { redirect_to_referer_or(users_url) }
|
||||
format.api { head :ok }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -183,8 +183,21 @@ class UsersController < ApplicationController
|
||||
@membership = Member.edit_membership(params[:membership_id], params[:membership], @user)
|
||||
@membership.save
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
|
||||
format.js
|
||||
if @membership.valid?
|
||||
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
|
||||
format.js {
|
||||
render(:update) {|page|
|
||||
page.replace_html "tab-content-memberships", :partial => 'users/memberships'
|
||||
page.visual_effect(:highlight, "member-#{@membership.id}")
|
||||
}
|
||||
}
|
||||
else
|
||||
format.js {
|
||||
render(:update) {|page|
|
||||
page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -195,7 +208,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
|
||||
format.js
|
||||
format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'users/memberships'} }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -78,7 +78,13 @@ class VersionsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
format.js do
|
||||
render :update do |page|
|
||||
page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
|
||||
page << "showModal('ajax-modal', '600px');"
|
||||
page << "Form.Element.focus('version_name');"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -97,7 +103,14 @@ class VersionsController < ApplicationController
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||
end
|
||||
format.js
|
||||
format.js do
|
||||
render(:update) {|page|
|
||||
page << 'hideModal();'
|
||||
# IE doesn't support the replace_html rjs method for select box options
|
||||
page.replace "issue_fixed_version_id",
|
||||
content_tag('select', content_tag('option') + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]')
|
||||
}
|
||||
end
|
||||
format.api do
|
||||
render :action => 'show', :status => :created, :location => version_url(@version)
|
||||
end
|
||||
@@ -105,7 +118,12 @@ class VersionsController < ApplicationController
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new' }
|
||||
format.js { render :action => 'new' }
|
||||
format.js do
|
||||
render :update do |page|
|
||||
page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
|
||||
page << "Form.Element.focus('version_name');"
|
||||
end
|
||||
end
|
||||
format.api { render_validation_errors(@version) }
|
||||
end
|
||||
end
|
||||
@@ -126,7 +144,7 @@ class VersionsController < ApplicationController
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
format.api { head :ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
@@ -149,7 +167,7 @@ class VersionsController < ApplicationController
|
||||
@version.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project }
|
||||
format.api { render_api_ok }
|
||||
format.api { head :ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
@@ -165,7 +183,7 @@ class VersionsController < ApplicationController
|
||||
def status_by
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'show' }
|
||||
format.js
|
||||
format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -33,6 +33,15 @@ class WatchersController < ApplicationController
|
||||
end
|
||||
|
||||
def new
|
||||
respond_to do |format|
|
||||
format.js do
|
||||
render :update do |page|
|
||||
page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched}
|
||||
page << "showModal('ajax-modal', '400px');"
|
||||
page << "$('ajax-modal').addClassName('new-watcher');"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -44,14 +53,29 @@ class WatchersController < ApplicationController
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
|
||||
format.js
|
||||
format.js do
|
||||
render :update do |page|
|
||||
page.replace_html 'ajax-modal', :partial => 'watchers/new', :locals => {:watched => @watched}
|
||||
page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def append
|
||||
if params[:watcher].is_a?(Hash)
|
||||
user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]]
|
||||
@users = User.active.find_all_by_id(user_ids)
|
||||
users = User.active.find_all_by_id(user_ids)
|
||||
respond_to do |format|
|
||||
format.js do
|
||||
render :update do |page|
|
||||
users.each do |user|
|
||||
page << %|$$("#issue_watcher_user_ids_#{user.id}").each(function(el){el.remove();});|
|
||||
end
|
||||
page.insert_html :bottom, 'watchers_inputs', :text => watchers_checkboxes(nil, users, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -59,7 +83,11 @@ class WatchersController < ApplicationController
|
||||
@watched.set_watcher(User.find(params[:user_id]), false) if request.post?
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js
|
||||
format.js do
|
||||
render :update do |page|
|
||||
page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -89,7 +117,12 @@ private
|
||||
@watched.set_watcher(user, watching)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
||||
format.js { render :partial => 'set_watcher', :locals => {:user => user, :watched => @watched} }
|
||||
format.js do
|
||||
render(:update) do |page|
|
||||
c = watcher_css(@watched)
|
||||
page << %|$$(".#{c}").each(function(el){el.innerHTML="#{escape_javascript watcher_link(@watched, user)}"});|
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -109,7 +109,7 @@ class WikiController < ApplicationController
|
||||
|
||||
# To prevent StaleObjectError exception when reverting to a previous version
|
||||
@content.version = @page.content.version
|
||||
|
||||
|
||||
@text = @content.text
|
||||
if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
|
||||
@section = params[:section].to_i
|
||||
@@ -239,7 +239,7 @@ class WikiController < ApplicationController
|
||||
|
||||
# Export wiki to a single pdf or html file
|
||||
def export
|
||||
@pages = @wiki.pages.all(:order => 'title', :include => [:content, :attachments])
|
||||
@pages = @wiki.pages.all(:order => 'title', :include => [:content, :attachments], :limit => 75)
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
export = render_to_string :action => 'export_multiple', :layout => false
|
||||
|
||||
@@ -24,6 +24,7 @@ class WikisController < ApplicationController
|
||||
@wiki = @project.wiki || Wiki.new(:project => @project)
|
||||
@wiki.safe_attributes = params[:wiki]
|
||||
@wiki.save if request.post?
|
||||
render(:update) {|page| page.replace_html "tab-content-wiki", :partial => 'projects/settings/wiki'}
|
||||
end
|
||||
|
||||
# Delete a project's wiki
|
||||
|
||||
@@ -18,27 +18,30 @@
|
||||
class WorkflowsController < ApplicationController
|
||||
layout 'admin'
|
||||
|
||||
before_filter :require_admin, :find_roles, :find_trackers
|
||||
before_filter :require_admin
|
||||
before_filter :find_roles
|
||||
before_filter :find_trackers
|
||||
|
||||
def index
|
||||
@workflow_counts = WorkflowTransition.count_by_tracker_and_role
|
||||
@workflow_counts = Workflow.count_by_tracker_and_role
|
||||
end
|
||||
|
||||
def edit
|
||||
@role = Role.find_by_id(params[:role_id]) if params[:role_id]
|
||||
@tracker = Tracker.find_by_id(params[:tracker_id]) if params[:tracker_id]
|
||||
@role = Role.find_by_id(params[:role_id])
|
||||
@tracker = Tracker.find_by_id(params[:tracker_id])
|
||||
|
||||
if request.post?
|
||||
WorkflowTransition.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
|
||||
Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
|
||||
(params[:issue_status] || []).each { |status_id, transitions|
|
||||
transitions.each { |new_status_id, options|
|
||||
author = options.is_a?(Array) && options.include?('author') && !options.include?('always')
|
||||
assignee = options.is_a?(Array) && options.include?('assignee') && !options.include?('always')
|
||||
WorkflowTransition.create(:role_id => @role.id, :tracker_id => @tracker.id, :old_status_id => status_id, :new_status_id => new_status_id, :author => author, :assignee => assignee)
|
||||
@role.workflows.build(:tracker_id => @tracker.id, :old_status_id => status_id, :new_status_id => new_status_id, :author => author, :assignee => assignee)
|
||||
}
|
||||
}
|
||||
if @role.save
|
||||
redirect_to :action => 'edit', :role_id => @role, :tracker_id => @tracker, :used_statuses_only => params[:used_statuses_only]
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'edit', :role_id => @role, :tracker_id => @tracker
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -47,10 +50,10 @@ class WorkflowsController < ApplicationController
|
||||
if @tracker && @used_statuses_only && @tracker.issue_statuses.any?
|
||||
@statuses = @tracker.issue_statuses
|
||||
end
|
||||
@statuses ||= IssueStatus.sorted.all
|
||||
@statuses ||= IssueStatus.find(:all, :order => 'position')
|
||||
|
||||
if @tracker && @role && @statuses.any?
|
||||
workflows = WorkflowTransition.where(:role_id => @role.id, :tracker_id => @tracker.id).all
|
||||
workflows = Workflow.all(:conditions => {:role_id => @role.id, :tracker_id => @tracker.id})
|
||||
@workflows = {}
|
||||
@workflows['always'] = workflows.select {|w| !w.author && !w.assignee}
|
||||
@workflows['author'] = workflows.select {|w| w.author}
|
||||
@@ -58,35 +61,6 @@ class WorkflowsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def permissions
|
||||
@role = Role.find_by_id(params[:role_id]) if params[:role_id]
|
||||
@tracker = Tracker.find_by_id(params[:tracker_id]) if params[:tracker_id]
|
||||
|
||||
if request.post? && @role && @tracker
|
||||
WorkflowPermission.replace_permissions(@tracker, @role, params[:permissions] || {})
|
||||
redirect_to :action => 'permissions', :role_id => @role, :tracker_id => @tracker, :used_statuses_only => params[:used_statuses_only]
|
||||
return
|
||||
end
|
||||
|
||||
@used_statuses_only = (params[:used_statuses_only] == '0' ? false : true)
|
||||
if @tracker && @used_statuses_only && @tracker.issue_statuses.any?
|
||||
@statuses = @tracker.issue_statuses
|
||||
end
|
||||
@statuses ||= IssueStatus.sorted.all
|
||||
|
||||
if @role && @tracker
|
||||
@fields = (Tracker::CORE_FIELDS_ALL - @tracker.disabled_core_fields).map {|field| [field, l("field_"+field.sub(/_id$/, ''))]}
|
||||
@custom_fields = @tracker.custom_fields
|
||||
|
||||
@permissions = WorkflowPermission.where(:tracker_id => @tracker.id, :role_id => @role.id).all.inject({}) do |h, w|
|
||||
h[w.old_status_id] ||= {}
|
||||
h[w.old_status_id][w.field_name] = w.rule
|
||||
h
|
||||
end
|
||||
@statuses.each {|status| @permissions[status.id] ||= {}}
|
||||
end
|
||||
end
|
||||
|
||||
def copy
|
||||
|
||||
if params[:source_tracker_id].blank? || params[:source_tracker_id] == 'any'
|
||||
@@ -109,7 +83,7 @@ class WorkflowsController < ApplicationController
|
||||
elsif @target_trackers.nil? || @target_roles.nil?
|
||||
flash.now[:error] = l(:error_workflow_copy_target)
|
||||
else
|
||||
WorkflowRule.copy(@source_tracker, @source_role, @target_trackers, @target_roles)
|
||||
Workflow.copy(@source_tracker, @source_role, @target_trackers, @target_roles)
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'copy', :source_tracker_id => @source_tracker, :source_role_id => @source_role
|
||||
end
|
||||
@@ -119,10 +93,10 @@ class WorkflowsController < ApplicationController
|
||||
private
|
||||
|
||||
def find_roles
|
||||
@roles = Role.sorted.all
|
||||
@roles = Role.find(:all, :order => 'builtin, position')
|
||||
end
|
||||
|
||||
def find_trackers
|
||||
@trackers = Tracker.sorted.all
|
||||
@trackers = Tracker.find(:all, :order => 'position')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
module AdminHelper
|
||||
def project_status_options_for_select(selected)
|
||||
options_for_select([[l(:label_all), ''],
|
||||
[l(:project_status_active), '1'],
|
||||
[l(:project_status_closed), '5'],
|
||||
[l(:project_status_archived), '9']], selected.to_s)
|
||||
[l(:status_active), '1']], selected.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,6 +43,12 @@ module ApplicationHelper
|
||||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
|
||||
end
|
||||
|
||||
# Display a link to remote if user is authorized
|
||||
def link_to_remote_if_authorized(name, options = {}, html_options = nil)
|
||||
url = options[:url] || {}
|
||||
link_to_remote(name, options, html_options) if authorize_for(url[:controller] || params[:controller], url[:action])
|
||||
end
|
||||
|
||||
# Displays a link to user's account page if active
|
||||
def link_to_user(user, options={})
|
||||
if user.is_a?(User)
|
||||
@@ -122,7 +128,7 @@ module ApplicationHelper
|
||||
h(truncate(message.subject, :length => 60)),
|
||||
{ :controller => 'messages', :action => 'show',
|
||||
:board_id => message.board_id,
|
||||
:id => (message.parent_id || message.id),
|
||||
:id => message.root,
|
||||
:r => (message.parent_id && message.id),
|
||||
:anchor => (message.parent_id ? "message-#{message.id}" : nil)
|
||||
}.merge(options),
|
||||
@@ -139,23 +145,17 @@ module ApplicationHelper
|
||||
# link_to_project(project, {}, :class => "project") # => html options with default url (project overview)
|
||||
#
|
||||
def link_to_project(project, options={}, html_options = nil)
|
||||
if project.archived?
|
||||
h(project)
|
||||
else
|
||||
if project.active?
|
||||
url = {:controller => 'projects', :action => 'show', :id => project}.merge(options)
|
||||
link_to(h(project), url, html_options)
|
||||
else
|
||||
h(project)
|
||||
end
|
||||
end
|
||||
|
||||
def thumbnail_tag(attachment)
|
||||
link_to image_tag(url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment)),
|
||||
{:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename},
|
||||
:title => attachment.filename
|
||||
end
|
||||
|
||||
def toggle_link(name, id, options={})
|
||||
onclick = "$('##{id}').toggle(); "
|
||||
onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ")
|
||||
onclick = "Element.toggle('#{id}'); "
|
||||
onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
|
||||
onclick << "return false;"
|
||||
link_to(name, "#", :onclick => onclick)
|
||||
end
|
||||
@@ -168,6 +168,11 @@ module ApplicationHelper
|
||||
}))
|
||||
end
|
||||
|
||||
def prompt_to_remote(name, text, param, url, html_options = {})
|
||||
html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
|
||||
link_to name, {}, html_options
|
||||
end
|
||||
|
||||
def format_activity_title(text)
|
||||
h(truncate_single_line(text, :length => 100))
|
||||
end
|
||||
@@ -195,39 +200,6 @@ module ApplicationHelper
|
||||
end
|
||||
end
|
||||
|
||||
# Renders a tree of projects as a nested set of unordered lists
|
||||
# The given collection may be a subset of the whole project tree
|
||||
# (eg. some intermediate nodes are private and can not be seen)
|
||||
def render_project_nested_lists(projects)
|
||||
s = ''
|
||||
if projects.any?
|
||||
ancestors = []
|
||||
original_project = @project
|
||||
projects.sort_by(&:lft).each do |project|
|
||||
# set the project environment to please macros.
|
||||
@project = project
|
||||
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
|
||||
s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n"
|
||||
else
|
||||
ancestors.pop
|
||||
s << "</li>"
|
||||
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
||||
ancestors.pop
|
||||
s << "</ul></li>\n"
|
||||
end
|
||||
end
|
||||
classes = (ancestors.empty? ? 'root' : 'child')
|
||||
s << "<li class='#{classes}'><div class='#{classes}'>"
|
||||
s << h(block_given? ? yield(project) : project.name)
|
||||
s << "</div>\n"
|
||||
ancestors << project
|
||||
end
|
||||
s << ("</li></ul>\n" * ancestors.size)
|
||||
@project = original_project
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
def render_page_hierarchy(pages, node=nil, options={})
|
||||
content = ''
|
||||
if pages[node]
|
||||
@@ -265,24 +237,23 @@ module ApplicationHelper
|
||||
# Renders the project quick-jump box
|
||||
def render_project_jump_box
|
||||
return unless User.current.logged?
|
||||
projects = User.current.memberships.collect(&:project).compact.select(&:active?).uniq
|
||||
projects = User.current.memberships.collect(&:project).compact.uniq
|
||||
if projects.any?
|
||||
options =
|
||||
("<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
|
||||
'<option value="" disabled="disabled">---</option>').html_safe
|
||||
|
||||
options << project_tree_options_for_select(projects, :selected => @project) do |p|
|
||||
{ :value => project_path(:id => p, :jump => current_menu_item) }
|
||||
s = '<select onchange="if (this.value != \'\') { window.location = this.value; }">' +
|
||||
"<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
|
||||
'<option value="" disabled="disabled">---</option>'
|
||||
s << project_tree_options_for_select(projects, :selected => @project) do |p|
|
||||
{ :value => url_for(:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item) }
|
||||
end
|
||||
|
||||
select_tag('project_quick_jump_box', options, :onchange => 'if (this.value != \'\') { window.location = this.value; }')
|
||||
s << '</select>'
|
||||
s.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
def project_tree_options_for_select(projects, options = {})
|
||||
s = ''
|
||||
project_tree(projects) do |project, level|
|
||||
name_prefix = (level > 0 ? ' ' * 2 * level + '» ' : '').html_safe
|
||||
name_prefix = (level > 0 ? (' ' * 2 * level + '» ') : '').html_safe
|
||||
tag_options = {:value => project.id}
|
||||
if project == options[:selected] || (options[:selected].respond_to?(:include?) && options[:selected].include?(project))
|
||||
tag_options[:selected] = 'selected'
|
||||
@@ -302,6 +273,30 @@ module ApplicationHelper
|
||||
Project.project_tree(projects, &block)
|
||||
end
|
||||
|
||||
def project_nested_ul(projects, &block)
|
||||
s = ''
|
||||
if projects.any?
|
||||
ancestors = []
|
||||
projects.sort_by(&:lft).each do |project|
|
||||
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
|
||||
s << "<ul>\n"
|
||||
else
|
||||
ancestors.pop
|
||||
s << "</li>"
|
||||
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
||||
ancestors.pop
|
||||
s << "</ul></li>\n"
|
||||
end
|
||||
end
|
||||
s << "<li>"
|
||||
s << yield(project).to_s
|
||||
ancestors << project
|
||||
end
|
||||
s << ("</li></ul>\n" * ancestors.size)
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
def principals_check_box_tags(name, principals)
|
||||
s = ''
|
||||
principals.sort.each do |principal|
|
||||
@@ -314,7 +309,7 @@ module ApplicationHelper
|
||||
def principals_options_for_select(collection, selected=nil)
|
||||
s = ''
|
||||
if collection.include?(User.current)
|
||||
s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id)
|
||||
s << content_tag('option', "<< #{l(:label_me)} >>".html_safe, :value => User.current.id)
|
||||
end
|
||||
groups = ''
|
||||
collection.sort.each do |element|
|
||||
@@ -527,8 +522,6 @@ module ApplicationHelper
|
||||
project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
|
||||
only_path = options.delete(:only_path) == false ? false : true
|
||||
|
||||
text = text.dup
|
||||
macros = catch_macros(text)
|
||||
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr)
|
||||
|
||||
@parsed_headings = []
|
||||
@@ -536,8 +529,8 @@ module ApplicationHelper
|
||||
@current_section = 0 if options[:edit_section_links]
|
||||
|
||||
parse_sections(text, project, obj, attr, only_path, options)
|
||||
text = parse_non_pre_blocks(text, obj, macros) do |text|
|
||||
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name|
|
||||
text = parse_non_pre_blocks(text) do |text|
|
||||
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros].each do |method_name|
|
||||
send method_name, text, project, obj, attr, only_path, options
|
||||
end
|
||||
end
|
||||
@@ -550,7 +543,7 @@ module ApplicationHelper
|
||||
text.html_safe
|
||||
end
|
||||
|
||||
def parse_non_pre_blocks(text, obj, macros)
|
||||
def parse_non_pre_blocks(text)
|
||||
s = StringScanner.new(text)
|
||||
tags = []
|
||||
parsed = ''
|
||||
@@ -559,9 +552,6 @@ module ApplicationHelper
|
||||
text, full_tag, closing, tag = s[1], s[2], s[3], s[4]
|
||||
if tags.empty?
|
||||
yield text
|
||||
inject_macros(text, obj, macros) if macros.any?
|
||||
else
|
||||
inject_macros(text, obj, macros, false) if macros.any?
|
||||
end
|
||||
parsed << text
|
||||
if tag
|
||||
@@ -717,7 +707,7 @@ module ApplicationHelper
|
||||
oid = identifier.to_i
|
||||
case prefix
|
||||
when nil
|
||||
if oid.to_s == identifier && issue = Issue.visible.find_by_id(oid, :include => :status)
|
||||
if issue = Issue.visible.find_by_id(oid, :include => :status)
|
||||
anchor = comment_id ? "note-#{comment_id}" : nil
|
||||
link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
|
||||
:class => issue.css_classes,
|
||||
@@ -795,10 +785,11 @@ module ApplicationHelper
|
||||
if repository && User.current.allowed_to?(:browse_repository, project)
|
||||
name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$}
|
||||
path, rev, anchor = $1, $3, $5
|
||||
link = link_to h("#{project_prefix}#{prefix}:#{repo_prefix}#{name}"), {:controller => 'repositories', :action => (prefix == 'export' ? 'raw' : 'entry'), :id => project, :repository_id => repository.identifier_param,
|
||||
link = link_to h("#{project_prefix}#{prefix}:#{repo_prefix}#{name}"), {:controller => 'repositories', :action => 'entry', :id => project, :repository_id => repository.identifier_param,
|
||||
:path => to_path_param(path),
|
||||
:rev => rev,
|
||||
:anchor => anchor},
|
||||
:anchor => anchor,
|
||||
:format => (prefix == 'export' ? 'raw' : nil)},
|
||||
:class => (prefix == 'export' ? 'source download' : 'source')
|
||||
end
|
||||
end
|
||||
@@ -860,57 +851,31 @@ module ApplicationHelper
|
||||
end
|
||||
end
|
||||
|
||||
MACROS_RE = /(
|
||||
MACROS_RE = /
|
||||
(!)? # escaping
|
||||
(
|
||||
\{\{ # opening tag
|
||||
([\w]+) # macro name
|
||||
(\(([^\n\r]*?)\))? # optional arguments
|
||||
([\n\r].*?[\n\r])? # optional block of text
|
||||
(\(([^\}]*)\))? # optional arguments
|
||||
\}\} # closing tag
|
||||
)
|
||||
)/mx unless const_defined?(:MACROS_RE)
|
||||
/x unless const_defined?(:MACROS_RE)
|
||||
|
||||
MACRO_SUB_RE = /(
|
||||
\{\{
|
||||
macro\((\d+)\)
|
||||
\}\}
|
||||
)/x unless const_defined?(:MACRO_SUB_RE)
|
||||
|
||||
# Extracts macros from text
|
||||
def catch_macros(text)
|
||||
macros = {}
|
||||
# Macros substitution
|
||||
def parse_macros(text, project, obj, attr, only_path, options)
|
||||
text.gsub!(MACROS_RE) do
|
||||
all, macro = $1, $4.downcase
|
||||
if macro_exists?(macro) || all =~ MACRO_SUB_RE
|
||||
index = macros.size
|
||||
macros[index] = all
|
||||
"{{macro(#{index})}}"
|
||||
esc, all, macro = $1, $2, $3.downcase
|
||||
args = ($5 || '').split(',').each(&:strip)
|
||||
if esc.nil?
|
||||
begin
|
||||
exec_macro(macro, obj, args)
|
||||
rescue => e
|
||||
"<div class=\"flash error\">Error executing the <strong>#{macro}</strong> macro (#{e})</div>"
|
||||
end || all
|
||||
else
|
||||
all
|
||||
end
|
||||
end
|
||||
macros
|
||||
end
|
||||
|
||||
# Executes and replaces macros in text
|
||||
def inject_macros(text, obj, macros, execute=true)
|
||||
text.gsub!(MACRO_SUB_RE) do
|
||||
all, index = $1, $2.to_i
|
||||
orig = macros.delete(index)
|
||||
if execute && orig && orig =~ MACROS_RE
|
||||
esc, all, macro, args, block = $2, $3, $4.downcase, $6.to_s, $7.try(:strip)
|
||||
if esc.nil?
|
||||
h(exec_macro(macro, obj, args, block) || all)
|
||||
else
|
||||
h(all)
|
||||
end
|
||||
elsif orig
|
||||
h(orig)
|
||||
else
|
||||
h(all)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
TOC_RE = /<p>\{\{([<>]?)toc\}\}<\/p>/i unless const_defined?(:TOC_RE)
|
||||
@@ -967,6 +932,16 @@ module ApplicationHelper
|
||||
content_tag("label", label_text)
|
||||
end
|
||||
|
||||
def labelled_tabular_form_for(*args, &proc)
|
||||
ActiveSupport::Deprecation.warn "ApplicationHelper#labelled_tabular_form_for is deprecated and will be removed in Redmine 1.5. Use #labelled_form_for instead."
|
||||
args << {} unless args.last.is_a?(Hash)
|
||||
options = args.last
|
||||
options[:html] ||= {}
|
||||
options[:html][:class] = 'tabular' unless options[:html].has_key?(:class)
|
||||
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
|
||||
form_for(*args, &proc)
|
||||
end
|
||||
|
||||
def labelled_form_for(*args, &proc)
|
||||
args << {} unless args.last.is_a?(Hash)
|
||||
options = args.last
|
||||
@@ -985,7 +960,6 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def labelled_remote_form_for(*args, &proc)
|
||||
ActiveSupport::Deprecation.warn "ApplicationHelper#labelled_remote_form_for is deprecated and will be removed in Redmine 2.2."
|
||||
args << {} unless args.last.is_a?(Hash)
|
||||
options = args.last
|
||||
options.merge!({:builder => Redmine::Views::LabelledFormBuilder, :remote => true})
|
||||
@@ -1006,44 +980,10 @@ module ApplicationHelper
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
def delete_link(url, options={})
|
||||
options = {
|
||||
:method => :delete,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:class => 'icon icon-del'
|
||||
}.merge(options)
|
||||
|
||||
link_to l(:button_delete), url, options
|
||||
end
|
||||
|
||||
def preview_link(url, form, target='preview', options={})
|
||||
content_tag 'a', l(:label_preview), {
|
||||
:href => "#",
|
||||
:onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|,
|
||||
:accesskey => accesskey(:preview)
|
||||
}.merge(options)
|
||||
end
|
||||
|
||||
def link_to_function(name, function, html_options={})
|
||||
content_tag(:a, name, {:href => '#', :onclick => "#{function}; return false;"}.merge(html_options))
|
||||
end
|
||||
|
||||
# Helper to render JSON in views
|
||||
def raw_json(arg)
|
||||
arg.to_json.to_s.gsub('/', '\/').html_safe
|
||||
end
|
||||
|
||||
def back_url
|
||||
url = params[:back_url]
|
||||
if url.nil? && referer = request.env['HTTP_REFERER']
|
||||
url = CGI.unescape(referer.to_s)
|
||||
end
|
||||
url
|
||||
end
|
||||
|
||||
def back_url_hidden_field_tag
|
||||
url = back_url
|
||||
hidden_field_tag('back_url', url, :id => nil) unless url.blank?
|
||||
back_url = params[:back_url] || request.env['HTTP_REFERER']
|
||||
back_url = CGI.unescape(back_url.to_s)
|
||||
hidden_field_tag('back_url', CGI.escape(back_url), :id => nil) unless back_url.blank?
|
||||
end
|
||||
|
||||
def check_all_links(form_name)
|
||||
@@ -1087,34 +1027,35 @@ module ApplicationHelper
|
||||
end
|
||||
@context_menu_included = true
|
||||
end
|
||||
javascript_tag "contextMenuInit('#{ url_for(url) }')"
|
||||
javascript_tag "new ContextMenu('#{ url_for(url) }')"
|
||||
end
|
||||
|
||||
def calendar_for(field_id)
|
||||
include_calendar_headers_tags
|
||||
javascript_tag("$(function() { $('##{field_id}').datepicker(datepickerOptions); });")
|
||||
image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
|
||||
javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
|
||||
end
|
||||
|
||||
def include_calendar_headers_tags
|
||||
unless @calendar_headers_tags_included
|
||||
@calendar_headers_tags_included = true
|
||||
content_for :header_tags do
|
||||
start_of_week = Setting.start_of_week
|
||||
start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank?
|
||||
# Redmine uses 1..7 (monday..sunday) in settings and locales
|
||||
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
|
||||
start_of_week = start_of_week.to_i % 7
|
||||
|
||||
tags = javascript_tag(
|
||||
"var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
|
||||
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
|
||||
path_to_image('/images/calendar.png') +
|
||||
"', showButtonPanel: true};")
|
||||
jquery_locale = l('jquery.locale', :default => current_language.to_s)
|
||||
unless jquery_locale == 'en'
|
||||
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
|
||||
start_of_week = case Setting.start_of_week.to_i
|
||||
when 1
|
||||
'Calendar._FD = 1;' # Monday
|
||||
when 7
|
||||
'Calendar._FD = 0;' # Sunday
|
||||
when 6
|
||||
'Calendar._FD = 6;' # Saturday
|
||||
else
|
||||
'' # use language
|
||||
end
|
||||
tags
|
||||
|
||||
javascript_include_tag('calendar/calendar') +
|
||||
javascript_include_tag("calendar/lang/calendar-#{current_language.to_s.downcase}.js") +
|
||||
javascript_tag(start_of_week) +
|
||||
javascript_include_tag('calendar/calendar-setup') +
|
||||
stylesheet_link_tag('calendar')
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1212,19 +1153,14 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def sanitize_anchor_name(anchor)
|
||||
if ''.respond_to?(:encoding) || RUBY_PLATFORM == 'java'
|
||||
anchor.gsub(%r{[^\p{Word}\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
|
||||
else
|
||||
# TODO: remove when ruby1.8 is no longer supported
|
||||
anchor.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
|
||||
end
|
||||
anchor.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
|
||||
end
|
||||
|
||||
# Returns the javascript tags that are included in the html layout head
|
||||
def javascript_heads
|
||||
tags = javascript_include_tag('jquery-1.7.2-ui-1.8.21-ujs-2.0.3', 'application')
|
||||
tags = javascript_include_tag('prototype', 'effects', 'dragdrop', 'controls', 'rails', 'application')
|
||||
unless User.current.pref.warn_on_leaving_unsaved == '0'
|
||||
tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });")
|
||||
tags << "\n".html_safe + javascript_tag("Event.observe(window, 'load', function(){ new WarnLeavingUnsaved('#{escape_javascript( l(:text_warn_on_leaving_unsaved) )}'); });")
|
||||
end
|
||||
tags
|
||||
end
|
||||
|
||||
@@ -21,14 +21,12 @@ module AttachmentsHelper
|
||||
# Displays view/delete links to the attachments of the given object
|
||||
# Options:
|
||||
# :author -- author names are not displayed if set to false
|
||||
# :thumbails -- display thumbnails if enabled in settings
|
||||
def link_to_attachments(container, options = {})
|
||||
options.assert_valid_keys(:author, :thumbnails)
|
||||
options.assert_valid_keys(:author)
|
||||
|
||||
if container.attachments.any?
|
||||
options = {:deletable => container.attachments_deletable?, :author => true}.merge(options)
|
||||
render :partial => 'attachments/links',
|
||||
:locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)}
|
||||
render :partial => 'attachments/links', :locals => {:attachments => container.attachments, :options => options}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -18,24 +18,4 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module BoardsHelper
|
||||
def board_breadcrumb(item)
|
||||
board = item.is_a?(Message) ? item.board : item
|
||||
links = [link_to(l(:label_board_plural), project_boards_path(item.project))]
|
||||
boards = board.ancestors.reverse
|
||||
if item.is_a?(Message)
|
||||
boards << board
|
||||
end
|
||||
links += boards.map {|ancestor| link_to(h(ancestor.name), project_board_path(ancestor.project, ancestor))}
|
||||
breadcrumb links
|
||||
end
|
||||
|
||||
def boards_options_for_select(boards)
|
||||
options = []
|
||||
Board.board_tree(boards) do |board, level|
|
||||
label = (level > 0 ? ' ' * 2 * level + '» ' : '').html_safe
|
||||
label << board.name
|
||||
options << [label, board.id]
|
||||
end
|
||||
options
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,8 +26,8 @@ module ContextMenusHelper
|
||||
end
|
||||
if options.delete(:disabled)
|
||||
options.delete(:method)
|
||||
options.delete(:data)
|
||||
options[:onclick] = 'return false;'
|
||||
options.delete(:confirm)
|
||||
options.delete(:onclick)
|
||||
options[:class] << ' disabled'
|
||||
url = '#'
|
||||
end
|
||||
@@ -36,7 +36,7 @@ module ContextMenusHelper
|
||||
|
||||
def bulk_update_custom_field_context_menu_link(field, text, value)
|
||||
context_menu_link h(text),
|
||||
{:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'custom_field_values' => {field.id => value}}, :back_url => @back},
|
||||
{:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'custom_field_values' => {field.id => value}}, :back_url => @back},
|
||||
:method => :post,
|
||||
:selected => (@issue && @issue.custom_field_value(field) == value)
|
||||
end
|
||||
|
||||
@@ -73,17 +73,15 @@ module CustomFieldsHelper
|
||||
end
|
||||
|
||||
# Return custom field label tag
|
||||
def custom_field_label_tag(name, custom_value, options={})
|
||||
required = options[:required] || custom_value.custom_field.is_required?
|
||||
|
||||
def custom_field_label_tag(name, custom_value)
|
||||
content_tag "label", h(custom_value.custom_field.name) +
|
||||
(required ? " <span class=\"required\">*</span>".html_safe : ""),
|
||||
:for => "#{name}_custom_field_values_#{custom_value.custom_field.id}"
|
||||
(custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>".html_safe : ""),
|
||||
:for => "#{name}_custom_field_values_#{custom_value.custom_field.id}"
|
||||
end
|
||||
|
||||
# Return custom field tag with its label tag
|
||||
def custom_field_tag_with_label(name, custom_value, options={})
|
||||
custom_field_label_tag(name, custom_value, options) + custom_field_tag(name, custom_value)
|
||||
def custom_field_tag_with_label(name, custom_value)
|
||||
custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value)
|
||||
end
|
||||
|
||||
def custom_field_tag_for_bulk_edit(name, custom_field, projects=nil)
|
||||
|
||||
@@ -92,48 +92,6 @@ module IssuesHelper
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
class IssueFieldsRows
|
||||
include ActionView::Helpers::TagHelper
|
||||
|
||||
def initialize
|
||||
@left = []
|
||||
@right = []
|
||||
end
|
||||
|
||||
def left(*args)
|
||||
args.any? ? @left << cells(*args) : @left
|
||||
end
|
||||
|
||||
def right(*args)
|
||||
args.any? ? @right << cells(*args) : @right
|
||||
end
|
||||
|
||||
def size
|
||||
@left.size > @right.size ? @left.size : @right.size
|
||||
end
|
||||
|
||||
def to_html
|
||||
html = ''.html_safe
|
||||
blank = content_tag('th', '') + content_tag('td', '')
|
||||
size.times do |i|
|
||||
left = @left[i] || blank
|
||||
right = @right[i] || blank
|
||||
html << content_tag('tr', left + right)
|
||||
end
|
||||
html
|
||||
end
|
||||
|
||||
def cells(label, text, options={})
|
||||
content_tag('th', "#{label}:", options) + content_tag('td', text, options)
|
||||
end
|
||||
end
|
||||
|
||||
def issue_fields_rows
|
||||
r = IssueFieldsRows.new
|
||||
yield r
|
||||
r.to_html
|
||||
end
|
||||
|
||||
def render_custom_fields_rows(issue)
|
||||
return if issue.custom_field_values.empty?
|
||||
ordered_values = []
|
||||
@@ -290,7 +248,7 @@ module IssuesHelper
|
||||
unless no_html
|
||||
label = content_tag('strong', label)
|
||||
old_value = content_tag("i", h(old_value)) if detail.old_value
|
||||
old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank?
|
||||
old_value = content_tag("strike", old_value) if detail.old_value and detail.value.blank?
|
||||
if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key)
|
||||
# Link to the attachment if it has not been removed
|
||||
value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
|
||||
|
||||
@@ -23,13 +23,11 @@ module JournalsHelper
|
||||
editable = User.current.logged? && (User.current.allowed_to?(:edit_issue_notes, issue.project) || (journal.user == User.current && User.current.allowed_to?(:edit_own_issue_notes, issue.project)))
|
||||
links = []
|
||||
if !journal.notes.blank?
|
||||
links << link_to(image_tag('comment.png'),
|
||||
{:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal},
|
||||
:remote => true,
|
||||
:method => 'post',
|
||||
:title => l(:button_quote)) if options[:reply_links]
|
||||
links << link_to_remote(image_tag('comment.png'),
|
||||
{ :url => {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal} },
|
||||
:title => l(:button_quote)) if options[:reply_links]
|
||||
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
|
||||
{ :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' },
|
||||
{ :controller => 'journals', :action => 'edit', :id => journal },
|
||||
:title => l(:button_edit)) if editable
|
||||
end
|
||||
content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
|
||||
@@ -40,7 +38,7 @@ module JournalsHelper
|
||||
end
|
||||
|
||||
def link_to_in_place_notes_editor(text, field_id, url, options={})
|
||||
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
|
||||
onclick = "new Ajax.Request('#{url_for(url)}', {asynchronous:true, evalScripts:true, method:'get'}); return false;"
|
||||
link_to text, '#', options.merge(:onclick => onclick)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,15 +51,38 @@ module ProjectsHelper
|
||||
content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
|
||||
end
|
||||
|
||||
# Renders the projects index
|
||||
# Renders a tree of projects as a nested set of unordered lists
|
||||
# The given collection may be a subset of the whole project tree
|
||||
# (eg. some intermediate nodes are private and can not be seen)
|
||||
def render_project_hierarchy(projects)
|
||||
render_project_nested_lists(projects) do |project|
|
||||
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
|
||||
if project.description.present?
|
||||
s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
|
||||
s = ''
|
||||
if projects.any?
|
||||
ancestors = []
|
||||
original_project = @project
|
||||
projects.each do |project|
|
||||
# set the project environment to please macros.
|
||||
@project = project
|
||||
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
|
||||
s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n"
|
||||
else
|
||||
ancestors.pop
|
||||
s << "</li>"
|
||||
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
||||
ancestors.pop
|
||||
s << "</ul></li>\n"
|
||||
end
|
||||
end
|
||||
classes = (ancestors.empty? ? 'root' : 'child')
|
||||
s << "<li class='#{classes}'><div class='#{classes}'>" +
|
||||
link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
|
||||
s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank?
|
||||
s << "</div>\n"
|
||||
ancestors << project
|
||||
end
|
||||
s
|
||||
s << ("</li></ul>\n" * ancestors.size)
|
||||
@project = original_project
|
||||
end
|
||||
s.html_safe
|
||||
end
|
||||
|
||||
# Returns a set of options for a select field, grouped by project.
|
||||
@@ -68,6 +91,10 @@ module ProjectsHelper
|
||||
versions.each do |version|
|
||||
grouped[version.project.name] << [version.name, version.id]
|
||||
end
|
||||
# Add in the selected
|
||||
if selected && !versions.include?(selected)
|
||||
grouped[selected.project.name] << [selected.name, selected.id]
|
||||
end
|
||||
|
||||
if grouped.keys.size > 1
|
||||
grouped_options_for_select(grouped, selected && selected.id)
|
||||
|
||||
@@ -18,12 +18,9 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module QueriesHelper
|
||||
def filters_options_for_select(query)
|
||||
options = [[]]
|
||||
options += query.available_filters.sort {|a,b| a[1][:order] <=> b[1][:order]}.map do |field, field_options|
|
||||
[field_options[:name], field]
|
||||
end
|
||||
options_for_select(options)
|
||||
|
||||
def operators_for_select(filter_type)
|
||||
Query.operators_by_filter_type[filter_type].collect {|o| [l(Query.operators[o]), o]}
|
||||
end
|
||||
|
||||
def column_header(column)
|
||||
|
||||
@@ -141,7 +141,12 @@ module RepositoriesHelper
|
||||
select_tag('repository_scm',
|
||||
options_for_select(scm_options, repository.class.name.demodulize),
|
||||
:disabled => (repository && !repository.new_record?),
|
||||
:data => {:remote => true, :method => 'get'})
|
||||
:onchange => remote_function(
|
||||
:url => new_project_repository_path(@project),
|
||||
:method => :get,
|
||||
:update => 'content',
|
||||
:with => "Form.serialize(this.form)")
|
||||
)
|
||||
end
|
||||
|
||||
def with_leading_slash(path)
|
||||
@@ -154,7 +159,7 @@ module RepositoriesHelper
|
||||
|
||||
def subversion_field_tags(form, repository)
|
||||
content_tag('p', form.text_field(:url, :size => 60, :required => true,
|
||||
:disabled => !repository.safe_attribute?('url')) +
|
||||
:disabled => (repository && !repository.root_url.blank?)) +
|
||||
'<br />'.html_safe +
|
||||
'(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') +
|
||||
content_tag('p', form.text_field(:login, :size => 30)) +
|
||||
@@ -169,7 +174,7 @@ module RepositoriesHelper
|
||||
content_tag('p', form.text_field(
|
||||
:url, :label => l(:field_path_to_repository),
|
||||
:size => 60, :required => true,
|
||||
:disabled => !repository.safe_attribute?('url'))) +
|
||||
:disabled => (repository && !repository.new_record?))) +
|
||||
content_tag('p', form.select(
|
||||
:log_encoding, [nil] + Setting::ENCODINGS,
|
||||
:label => l(:field_commit_logs_encoding), :required => true))
|
||||
@@ -179,7 +184,7 @@ module RepositoriesHelper
|
||||
content_tag('p', form.text_field(
|
||||
:url, :label => l(:field_path_to_repository),
|
||||
:size => 60, :required => true,
|
||||
:disabled => !repository.safe_attribute?('url')
|
||||
:disabled => (repository && !repository.root_url.blank?)
|
||||
) +
|
||||
'<br />'.html_safe + l(:text_mercurial_repository_note)) +
|
||||
content_tag('p', form.select(
|
||||
@@ -193,7 +198,7 @@ module RepositoriesHelper
|
||||
content_tag('p', form.text_field(
|
||||
:url, :label => l(:field_path_to_repository),
|
||||
:size => 60, :required => true,
|
||||
:disabled => !repository.safe_attribute?('url')
|
||||
:disabled => (repository && !repository.root_url.blank?)
|
||||
) +
|
||||
'<br />'.html_safe +
|
||||
l(:text_git_repository_note)) +
|
||||
@@ -213,12 +218,12 @@ module RepositoriesHelper
|
||||
:root_url,
|
||||
:label => l(:field_cvsroot),
|
||||
:size => 60, :required => true,
|
||||
:disabled => !repository.safe_attribute?('root_url'))) +
|
||||
:disabled => !repository.new_record?)) +
|
||||
content_tag('p', form.text_field(
|
||||
:url,
|
||||
:label => l(:field_cvs_module),
|
||||
:size => 30, :required => true,
|
||||
:disabled => !repository.safe_attribute?('url'))) +
|
||||
:disabled => !repository.new_record?)) +
|
||||
content_tag('p', form.select(
|
||||
:log_encoding, [nil] + Setting::ENCODINGS,
|
||||
:label => l(:field_commit_logs_encoding), :required => true)) +
|
||||
@@ -233,7 +238,7 @@ module RepositoriesHelper
|
||||
content_tag('p', form.text_field(
|
||||
:url, :label => l(:field_path_to_repository),
|
||||
:size => 60, :required => true,
|
||||
:disabled => !repository.safe_attribute?('url'))) +
|
||||
:disabled => (repository && !repository.new_record?))) +
|
||||
content_tag('p', form.select(
|
||||
:log_encoding, [nil] + Setting::ENCODINGS,
|
||||
:label => l(:field_commit_logs_encoding), :required => true))
|
||||
@@ -243,7 +248,7 @@ module RepositoriesHelper
|
||||
content_tag('p', form.text_field(
|
||||
:url, :label => l(:field_root_directory),
|
||||
:size => 60, :required => true,
|
||||
:disabled => !repository.safe_attribute?('url'))) +
|
||||
:disabled => (repository && !repository.root_url.blank?))) +
|
||||
content_tag('p', form.select(
|
||||
:path_encoding, [nil] + Setting::ENCODINGS,
|
||||
:label => l(:field_scm_path_encoding)
|
||||
|
||||
@@ -44,7 +44,7 @@ module SettingsHelper
|
||||
setting_values = Setting.send(setting)
|
||||
setting_values = [] unless setting_values.is_a?(Array)
|
||||
|
||||
content_tag("label", l(options[:label] || "setting_#{setting}")) +
|
||||
setting_label(setting, options).html_safe +
|
||||
hidden_field_tag("settings[#{setting}][]", '').html_safe +
|
||||
choices.collect do |choice|
|
||||
text, value = (choice.is_a?(Array) ? choice : [choice, choice])
|
||||
@@ -53,8 +53,7 @@ module SettingsHelper
|
||||
check_box_tag(
|
||||
"settings[#{setting}][]",
|
||||
value,
|
||||
Setting.send(setting).include?(value),
|
||||
:id => nil
|
||||
Setting.send(setting).include?(value)
|
||||
) + text.to_s,
|
||||
:class => 'block'
|
||||
)
|
||||
@@ -73,13 +72,13 @@ module SettingsHelper
|
||||
|
||||
def setting_check_box(setting, options={})
|
||||
setting_label(setting, options).html_safe +
|
||||
hidden_field_tag("settings[#{setting}]", 0, :id => nil).html_safe +
|
||||
hidden_field_tag("settings[#{setting}]", 0).html_safe +
|
||||
check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe
|
||||
end
|
||||
|
||||
def setting_label(setting, options={})
|
||||
label = options.delete(:label)
|
||||
label != false ? label_tag("settings_#{setting}", l(label || "setting_#{setting}")).html_safe : ''
|
||||
label != false ? content_tag("label", l(label || "setting_#{setting}")).html_safe : ''
|
||||
end
|
||||
|
||||
# Renders a notification field for a Redmine::Notifiable option
|
||||
@@ -87,7 +86,7 @@ module SettingsHelper
|
||||
return content_tag(:label,
|
||||
check_box_tag('settings[notified_events][]',
|
||||
notifiable.name,
|
||||
Setting.notified_events.include?(notifiable.name), :id => nil).html_safe +
|
||||
Setting.notified_events.include?(notifiable.name)).html_safe +
|
||||
l_or_humanize(notifiable.name, :prefix => 'label_').html_safe,
|
||||
:class => notifiable.parent.present? ? "parent" : '').html_safe
|
||||
end
|
||||
|
||||
@@ -19,18 +19,10 @@
|
||||
|
||||
module VersionsHelper
|
||||
|
||||
def version_anchor(version)
|
||||
if @project == version.project
|
||||
anchor version.name
|
||||
else
|
||||
anchor "#{version.project.try(:identifier)}-#{version.name}"
|
||||
end
|
||||
end
|
||||
|
||||
STATUS_BY_CRITERIAS = %w(tracker status priority author assigned_to category)
|
||||
STATUS_BY_CRITERIAS = %w(category tracker status priority author assigned_to)
|
||||
|
||||
def render_issue_status_by(version, criteria)
|
||||
criteria = 'tracker' unless STATUS_BY_CRITERIAS.include?(criteria)
|
||||
criteria = 'category' unless STATUS_BY_CRITERIAS.include?(criteria)
|
||||
|
||||
h = Hash.new {|k,v| k[v] = [0, 0]}
|
||||
begin
|
||||
|
||||
@@ -30,8 +30,10 @@ module WatchersHelper
|
||||
:action => (watched ? 'unwatch' : 'watch'),
|
||||
:object_type => object.class.to_s.underscore,
|
||||
:object_id => object.id}
|
||||
link_to((watched ? l(:button_unwatch) : l(:button_watch)), url,
|
||||
:remote => true, :method => 'post', :class => (watched ? 'icon icon-fav' : 'icon icon-fav-off'))
|
||||
link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)),
|
||||
{:url => url},
|
||||
:href => url_for(url),
|
||||
:class => (watched ? 'icon icon-fav' : 'icon icon-fav-off'))
|
||||
|
||||
end
|
||||
|
||||
@@ -55,8 +57,11 @@ module WatchersHelper
|
||||
:object_id => object.id,
|
||||
:user_id => user}
|
||||
s << ' '
|
||||
s << link_to(image_tag('delete.png'), url,
|
||||
:remote => true, :method => 'post', :style => "vertical-align: middle", :class => "delete")
|
||||
s << link_to_remote(image_tag('delete.png'),
|
||||
{:url => url},
|
||||
:href => url_for(url),
|
||||
:style => "vertical-align: middle",
|
||||
:class => "delete")
|
||||
end
|
||||
content << content_tag('li', s)
|
||||
end
|
||||
|
||||
@@ -18,15 +18,4 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module WorkflowsHelper
|
||||
def field_required?(field)
|
||||
field.is_a?(CustomField) ? field.is_required? : %w(project_id tracker_id subject priority_id is_private).include?(field)
|
||||
end
|
||||
|
||||
def field_permission_tag(permissions, status, field)
|
||||
name = field.is_a?(CustomField) ? field.id.to_s : field
|
||||
options = [["", ""], [l(:label_readonly), "readonly"]]
|
||||
options << [l(:label_required), "required"] unless field_required?(field)
|
||||
|
||||
select_tag("permissions[#{name}][#{status.id}]", options_for_select(options, permissions[status.id][name]))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,9 +47,6 @@ class Attachment < ActiveRecord::Base
|
||||
cattr_accessor :storage_path
|
||||
@@storage_path = Redmine::Configuration['attachments_storage_path'] || File.join(Rails.root, "files")
|
||||
|
||||
cattr_accessor :thumbnails_storage_path
|
||||
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
||||
|
||||
before_save :files_to_final_location
|
||||
after_destroy :delete_from_disk
|
||||
|
||||
@@ -127,7 +124,7 @@ class Attachment < ActiveRecord::Base
|
||||
|
||||
# Deletes the file from the file system if it's not referenced by other attachments
|
||||
def delete_from_disk
|
||||
if Attachment.where("disk_filename = ? AND id <> ?", disk_filename, id).empty?
|
||||
if Attachment.first(:conditions => ["disk_filename = ? AND id <> ?", disk_filename, id]).nil?
|
||||
delete_from_disk!
|
||||
end
|
||||
end
|
||||
@@ -137,14 +134,6 @@ class Attachment < ActiveRecord::Base
|
||||
File.join(self.class.storage_path, disk_filename.to_s)
|
||||
end
|
||||
|
||||
def title
|
||||
title = filename.to_s
|
||||
if description.present?
|
||||
title << " (#{description})"
|
||||
end
|
||||
title
|
||||
end
|
||||
|
||||
def increment_download
|
||||
increment!(:downloads)
|
||||
end
|
||||
@@ -162,43 +151,7 @@ class Attachment < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def image?
|
||||
!!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png)$/i)
|
||||
end
|
||||
|
||||
def thumbnailable?
|
||||
image?
|
||||
end
|
||||
|
||||
# Returns the full path the attachment thumbnail, or nil
|
||||
# if the thumbnail cannot be generated.
|
||||
def thumbnail(options={})
|
||||
if thumbnailable? && readable?
|
||||
size = options[:size].to_i
|
||||
if size > 0
|
||||
# Limit the number of thumbnails per image
|
||||
size = (size / 50) * 50
|
||||
# Maximum thumbnail size
|
||||
size = 800 if size > 800
|
||||
else
|
||||
size = Setting.thumbnails_size.to_i
|
||||
end
|
||||
size = 100 unless size > 0
|
||||
target = File.join(self.class.thumbnails_storage_path, "#{id}_#{digest}_#{size}.thumb")
|
||||
|
||||
begin
|
||||
Redmine::Thumbnail.generate(self.diskfile, target, size)
|
||||
rescue => e
|
||||
logger.error "An error occured while generating thumbnail for #{disk_filename} to #{target}\nException was: #{e.message}" if logger
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Deletes all thumbnails
|
||||
def self.clear_thumbnails
|
||||
Dir.glob(File.join(thumbnails_storage_path, "*.thumb")).each do |file|
|
||||
File.delete file
|
||||
end
|
||||
self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png)$/i
|
||||
end
|
||||
|
||||
def is_text?
|
||||
@@ -223,7 +176,7 @@ class Attachment < ActiveRecord::Base
|
||||
def self.find_by_token(token)
|
||||
if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/
|
||||
attachment_id, attachment_digest = $1, $2
|
||||
attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first
|
||||
attachment = Attachment.first(:conditions => {:id => attachment_id, :digest => attachment_digest})
|
||||
if attachment && attachment.container.nil?
|
||||
attachment
|
||||
end
|
||||
@@ -248,7 +201,8 @@ class Attachment < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.prune(age=1.day)
|
||||
Attachment.where("created_on < ? AND (container_type IS NULL OR container_type = '')", Time.now - age).destroy_all
|
||||
attachments = Attachment.all(:conditions => ["created_on < ? AND (container_type IS NULL OR container_type = '')", Time.now - age])
|
||||
attachments.each(&:destroy)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
# Generic exception for when the AuthSource can not be reached
|
||||
# (eg. can not connect to the LDAP)
|
||||
class AuthSourceException < Exception; end
|
||||
class AuthSourceTimeoutException < AuthSourceException; end
|
||||
|
||||
class AuthSource < ActiveRecord::Base
|
||||
include Redmine::SubclassFactory
|
||||
@@ -59,7 +58,7 @@ class AuthSource < ActiveRecord::Base
|
||||
|
||||
# Try to authenticate a user not yet registered against available sources
|
||||
def self.authenticate(login, password)
|
||||
AuthSource.where(:onthefly_register => true).all.each do |source|
|
||||
AuthSource.find(:all, :conditions => ["onthefly_register=?", true]).each do |source|
|
||||
begin
|
||||
logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug?
|
||||
attrs = source.authenticate(login, password)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
require 'iconv'
|
||||
require 'net/ldap'
|
||||
require 'net/ldap/dn'
|
||||
require 'timeout'
|
||||
|
||||
class AuthSourceLdap < AuthSource
|
||||
validates_presence_of :host, :port, :attr_login
|
||||
@@ -26,11 +25,18 @@ class AuthSourceLdap < AuthSource
|
||||
validates_length_of :account, :account_password, :base_dn, :filter, :maximum => 255, :allow_blank => true
|
||||
validates_length_of :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :maximum => 30, :allow_nil => true
|
||||
validates_numericality_of :port, :only_integer => true
|
||||
validates_numericality_of :timeout, :only_integer => true, :allow_blank => true
|
||||
validate :validate_filter
|
||||
|
||||
before_validation :strip_ldap_attributes
|
||||
|
||||
def self.human_attribute_name(attribute_key_name, *args)
|
||||
attr_name = attribute_key_name.to_s
|
||||
if attr_name == "filter"
|
||||
attr_name = "ldap_filter"
|
||||
end
|
||||
super(attr_name, *args)
|
||||
end
|
||||
|
||||
def initialize(attributes=nil, *args)
|
||||
super
|
||||
self.port = 389 if self.port == 0
|
||||
@@ -38,26 +44,22 @@ class AuthSourceLdap < AuthSource
|
||||
|
||||
def authenticate(login, password)
|
||||
return nil if login.blank? || password.blank?
|
||||
attrs = get_user_dn(login, password)
|
||||
|
||||
with_timeout do
|
||||
attrs = get_user_dn(login, password)
|
||||
if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password)
|
||||
logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
|
||||
return attrs.except(:dn)
|
||||
end
|
||||
if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password)
|
||||
logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
|
||||
return attrs.except(:dn)
|
||||
end
|
||||
rescue Net::LDAP::LdapError => e
|
||||
rescue Net::LDAP::LdapError => e
|
||||
raise AuthSourceException.new(e.message)
|
||||
end
|
||||
|
||||
# test the connection to the LDAP
|
||||
def test_connection
|
||||
with_timeout do
|
||||
ldap_con = initialize_ldap_con(self.account, self.account_password)
|
||||
ldap_con.open { }
|
||||
end
|
||||
rescue Net::LDAP::LdapError => e
|
||||
raise AuthSourceException.new(e.message)
|
||||
ldap_con = initialize_ldap_con(self.account, self.account_password)
|
||||
ldap_con.open { }
|
||||
rescue Net::LDAP::LdapError => e
|
||||
raise "LdapError: " + e.message
|
||||
end
|
||||
|
||||
def auth_method_name
|
||||
@@ -66,16 +68,6 @@ class AuthSourceLdap < AuthSource
|
||||
|
||||
private
|
||||
|
||||
def with_timeout(&block)
|
||||
timeout = self.timeout
|
||||
timeout = 20 unless timeout && timeout > 0
|
||||
Timeout.timeout(timeout) do
|
||||
return yield
|
||||
end
|
||||
rescue Timeout::Error => e
|
||||
raise AuthSourceTimeoutException.new(e.message)
|
||||
end
|
||||
|
||||
def ldap_filter
|
||||
if filter.present?
|
||||
Net::LDAP::Filter.construct(filter)
|
||||
|
||||
@@ -21,37 +21,26 @@ class Board < ActiveRecord::Base
|
||||
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
|
||||
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
|
||||
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
|
||||
acts_as_tree :dependent => :nullify
|
||||
acts_as_list :scope => '(project_id = #{project_id} AND parent_id #{parent_id ? "= #{parent_id}" : "IS NULL"})'
|
||||
acts_as_list :scope => :project_id
|
||||
acts_as_watchable
|
||||
|
||||
validates_presence_of :name, :description
|
||||
validates_length_of :name, :maximum => 30
|
||||
validates_length_of :description, :maximum => 255
|
||||
validate :validate_board
|
||||
|
||||
scope :visible, lambda {|*args| { :include => :project,
|
||||
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
|
||||
|
||||
safe_attributes 'name', 'description', 'parent_id', 'move_to'
|
||||
safe_attributes 'name', 'description', 'move_to'
|
||||
|
||||
def visible?(user=User.current)
|
||||
!user.nil? && user.allowed_to?(:view_messages, project)
|
||||
end
|
||||
|
||||
def reload(*args)
|
||||
@valid_parents = nil
|
||||
super
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
def valid_parents
|
||||
@valid_parents ||= project.boards - self_and_descendants
|
||||
end
|
||||
|
||||
def reset_counters!
|
||||
self.class.reset_counters!(id)
|
||||
end
|
||||
@@ -64,26 +53,4 @@ class Board < ActiveRecord::Base
|
||||
" last_message_id = (SELECT MAX(id) FROM #{Message.table_name} WHERE board_id=#{board_id})",
|
||||
["id = ?", board_id])
|
||||
end
|
||||
|
||||
def self.board_tree(boards, parent_id=nil, level=0)
|
||||
tree = []
|
||||
boards.select {|board| board.parent_id == parent_id}.sort_by(&:position).each do |board|
|
||||
tree << [board, level]
|
||||
tree += board_tree(boards, board.id, level+1)
|
||||
end
|
||||
if block_given?
|
||||
tree.each do |board, level|
|
||||
yield board, level
|
||||
end
|
||||
end
|
||||
tree
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def validate_board
|
||||
if parent_id && parent_id_changed?
|
||||
errors.add(:parent_id, :invalid) unless valid_parents.include?(parent)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -162,7 +162,7 @@ class Changeset < ActiveRecord::Base
|
||||
tag = "#{repository.identifier}|#{tag}"
|
||||
end
|
||||
if ref_project && project && ref_project != project
|
||||
tag = "#{project.identifier}:#{tag}"
|
||||
tag = "#{project.identifier}:#{tag}"
|
||||
end
|
||||
tag
|
||||
end
|
||||
@@ -176,12 +176,18 @@ class Changeset < ActiveRecord::Base
|
||||
|
||||
# Returns the previous changeset
|
||||
def previous
|
||||
@previous ||= Changeset.where(["id < ? AND repository_id = ?", id, repository_id]).order('id DESC').first
|
||||
@previous ||= Changeset.find(:first,
|
||||
:conditions => ['id < ? AND repository_id = ?',
|
||||
self.id, self.repository_id],
|
||||
:order => 'id DESC')
|
||||
end
|
||||
|
||||
# Returns the next changeset
|
||||
def next
|
||||
@next ||= Changeset.where(["id > ? AND repository_id = ?", id, repository_id]).order('id ASC').first
|
||||
@next ||= Changeset.find(:first,
|
||||
:conditions => ['id > ? AND repository_id = ?',
|
||||
self.id, self.repository_id],
|
||||
:order => 'id ASC')
|
||||
end
|
||||
|
||||
# Creates a new Change from it's common parameters
|
||||
|
||||
@@ -30,6 +30,11 @@ class CustomField < ActiveRecord::Base
|
||||
validate :validate_custom_field
|
||||
before_validation :set_searchable
|
||||
|
||||
def initialize(attributes=nil, *args)
|
||||
super
|
||||
self.possible_values ||= []
|
||||
end
|
||||
|
||||
def set_searchable
|
||||
# make sure these fields are not searchable
|
||||
self.searchable = false if %w(int float date bool).include?(field_format)
|
||||
@@ -92,7 +97,7 @@ class CustomField < ActiveRecord::Base
|
||||
value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
|
||||
end
|
||||
end
|
||||
values || []
|
||||
values
|
||||
end
|
||||
end
|
||||
|
||||
@@ -126,26 +131,16 @@ class CustomField < ActiveRecord::Base
|
||||
casted
|
||||
end
|
||||
|
||||
def value_from_keyword(keyword, customized)
|
||||
possible_values_options = possible_values_options(customized)
|
||||
if possible_values_options.present?
|
||||
keyword = keyword.to_s.downcase
|
||||
possible_values_options.detect {|text, id| text.downcase == keyword}.try(:last)
|
||||
else
|
||||
keyword
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a ORDER BY clause that can used to sort customized
|
||||
# objects by their value of the custom field.
|
||||
# Returns nil if the custom field can not be used for sorting.
|
||||
# Returns false, if the custom field can not be used for sorting.
|
||||
def order_statement
|
||||
return nil if multiple?
|
||||
case field_format
|
||||
when 'string', 'text', 'list', 'date', 'bool'
|
||||
# COALESCE is here to make sure that blank and NULL values are sorted equally
|
||||
"COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" +
|
||||
" WHERE cv_sort.customized_type='#{self.class.customized_class.base_class.name}'" +
|
||||
" WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
|
||||
" AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
|
||||
" AND cv_sort.custom_field_id=#{id} LIMIT 1), '')"
|
||||
when 'int', 'float'
|
||||
@@ -153,74 +148,18 @@ class CustomField < ActiveRecord::Base
|
||||
# Postgresql will raise an error if a value can not be casted!
|
||||
# CustomValue validations should ensure that it doesn't occur
|
||||
"(SELECT CAST(cv_sort.value AS decimal(60,3)) FROM #{CustomValue.table_name} cv_sort" +
|
||||
" WHERE cv_sort.customized_type='#{self.class.customized_class.base_class.name}'" +
|
||||
" WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
|
||||
" AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
|
||||
" AND cv_sort.custom_field_id=#{id} AND cv_sort.value <> '' AND cv_sort.value IS NOT NULL LIMIT 1)"
|
||||
when 'user', 'version'
|
||||
value_class.fields_for_order_statement(value_join_alias)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a GROUP BY clause that can used to group by custom value
|
||||
# Returns nil if the custom field can not be used for grouping.
|
||||
def group_statement
|
||||
return nil if multiple?
|
||||
case field_format
|
||||
when 'list', 'date', 'bool', 'int'
|
||||
order_statement
|
||||
when 'user', 'version'
|
||||
"COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" +
|
||||
" WHERE cv_sort.customized_type='#{self.class.customized_class.base_class.name}'" +
|
||||
" AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
|
||||
" AND cv_sort.custom_field_id=#{id} LIMIT 1), '')"
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def join_for_order_statement
|
||||
case field_format
|
||||
when 'user', 'version'
|
||||
"LEFT OUTER JOIN #{CustomValue.table_name} #{join_alias}" +
|
||||
" ON #{join_alias}.customized_type = '#{self.class.customized_class.base_class.name}'" +
|
||||
" AND #{join_alias}.customized_id = #{self.class.customized_class.table_name}.id" +
|
||||
" AND #{join_alias}.custom_field_id = #{id}" +
|
||||
" AND #{join_alias}.value <> ''" +
|
||||
" AND #{join_alias}.id = (SELECT max(#{join_alias}_2.id) FROM #{CustomValue.table_name} #{join_alias}_2" +
|
||||
" WHERE #{join_alias}_2.customized_type = #{join_alias}.customized_type" +
|
||||
" AND #{join_alias}_2.customized_id = #{join_alias}.customized_id" +
|
||||
" AND #{join_alias}_2.custom_field_id = #{join_alias}.custom_field_id)" +
|
||||
" LEFT OUTER JOIN #{value_class.table_name} #{value_join_alias}" +
|
||||
" ON CAST(#{join_alias}.value as decimal(60,0)) = #{value_join_alias}.id"
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def join_alias
|
||||
"cf_#{id}"
|
||||
end
|
||||
|
||||
def value_join_alias
|
||||
join_alias + "_" + field_format
|
||||
end
|
||||
|
||||
def <=>(field)
|
||||
position <=> field.position
|
||||
end
|
||||
|
||||
# Returns the class that values represent
|
||||
def value_class
|
||||
case field_format
|
||||
when 'user', 'version'
|
||||
field_format.classify.constantize
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def self.customized_class
|
||||
self.name =~ /^(.+)CustomField$/
|
||||
begin; $1.constantize; rescue nil; end
|
||||
@@ -261,10 +200,6 @@ class CustomField < ActiveRecord::Base
|
||||
validate_field_value(value).empty?
|
||||
end
|
||||
|
||||
def format_in?(*args)
|
||||
args.include?(field_format)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Returns the error message for the given value regarding its format
|
||||
|
||||
@@ -31,10 +31,4 @@ class DocumentCategory < Enumeration
|
||||
def transfer_relations(to)
|
||||
documents.update_all("category_id = #{to.id}")
|
||||
end
|
||||
|
||||
def self.default
|
||||
d = super
|
||||
d = first if d.nil?
|
||||
d
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,19 +35,19 @@ class Enumeration < ActiveRecord::Base
|
||||
validates_uniqueness_of :name, :scope => [:type, :project_id]
|
||||
validates_length_of :name, :maximum => 30
|
||||
|
||||
scope :shared, where(:project_id => nil)
|
||||
scope :active, where(:active => true)
|
||||
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
|
||||
scope :shared, :conditions => { :project_id => nil }
|
||||
scope :active, :conditions => { :active => true }
|
||||
scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
||||
|
||||
def self.default
|
||||
# Creates a fake default scope so Enumeration.default will check
|
||||
# it's type. STI subclasses will automatically add their own
|
||||
# types to the finder.
|
||||
if self.descends_from_active_record?
|
||||
where(:is_default => true, :type => 'Enumeration').first
|
||||
find(:first, :conditions => { :is_default => true, :type => 'Enumeration' })
|
||||
else
|
||||
# STI classes are
|
||||
where(:is_default => true).first
|
||||
find(:first, :conditions => { :is_default => true })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -58,7 +58,7 @@ class Enumeration < ActiveRecord::Base
|
||||
|
||||
def check_default
|
||||
if is_default? && is_default_changed?
|
||||
Enumeration.update_all({:is_default => false}, {:type => type})
|
||||
Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class Group < Principal
|
||||
include Redmine::SafeAttributes
|
||||
|
||||
has_and_belongs_to_many :users, :after_add => :user_added,
|
||||
:after_remove => :user_removed
|
||||
|
||||
@@ -29,25 +27,11 @@ class Group < Principal
|
||||
|
||||
before_destroy :remove_references_before_destroy
|
||||
|
||||
scope :sorted, order("#{table_name}.lastname ASC")
|
||||
|
||||
safe_attributes 'name',
|
||||
'user_ids',
|
||||
'custom_field_values',
|
||||
'custom_fields',
|
||||
:if => lambda {|group, user| user.admin?}
|
||||
|
||||
def to_s
|
||||
lastname.to_s
|
||||
end
|
||||
|
||||
def name
|
||||
lastname
|
||||
end
|
||||
|
||||
def name=(arg)
|
||||
self.lastname = arg
|
||||
end
|
||||
alias :name :to_s
|
||||
|
||||
def user_added(user)
|
||||
members.each do |member|
|
||||
|
||||
@@ -58,7 +58,7 @@ class Issue < ActiveRecord::Base
|
||||
validates_length_of :subject, :maximum => 255
|
||||
validates_inclusion_of :done_ratio, :in => 0..100
|
||||
validates_numericality_of :estimated_hours, :allow_nil => true
|
||||
validate :validate_issue, :validate_required_fields
|
||||
validate :validate_issue
|
||||
|
||||
scope :visible,
|
||||
lambda {|*args| { :include => :project,
|
||||
@@ -70,6 +70,7 @@ class Issue < ActiveRecord::Base
|
||||
}
|
||||
|
||||
scope :recently_updated, :order => "#{Issue.table_name}.updated_on DESC"
|
||||
scope :with_limit, lambda { |limit| { :limit => limit} }
|
||||
scope :on_active_project, :include => [:status, :project, :tracker],
|
||||
:conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
|
||||
|
||||
@@ -77,28 +78,22 @@ class Issue < ActiveRecord::Base
|
||||
before_save :close_duplicates, :update_done_ratio_from_issue_status, :force_updated_on_change
|
||||
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, :update_parent_attributes, :create_journal
|
||||
# Should be after_create but would be called before previous after_save callbacks
|
||||
after_save :after_create_from_copy
|
||||
after_destroy :update_parent_attributes
|
||||
|
||||
# Returns a SQL conditions string used to find all issues visible by the specified user
|
||||
def self.visible_condition(user, options={})
|
||||
Project.allowed_to_condition(user, :view_issues, options) do |role, user|
|
||||
if user.logged?
|
||||
case role.issues_visibility
|
||||
when 'all'
|
||||
nil
|
||||
when 'default'
|
||||
user_ids = [user.id] + user.groups.map(&:id)
|
||||
"(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||||
when 'own'
|
||||
user_ids = [user.id] + user.groups.map(&:id)
|
||||
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||||
else
|
||||
'1=0'
|
||||
end
|
||||
case role.issues_visibility
|
||||
when 'all'
|
||||
nil
|
||||
when 'default'
|
||||
user_ids = [user.id] + user.groups.map(&:id)
|
||||
"(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||||
when 'own'
|
||||
user_ids = [user.id] + user.groups.map(&:id)
|
||||
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
|
||||
else
|
||||
"(#{table_name}.is_private = #{connection.quoted_false})"
|
||||
'1=0'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -106,19 +101,15 @@ class Issue < ActiveRecord::Base
|
||||
# Returns true if usr or current user is allowed to view the issue
|
||||
def visible?(usr=nil)
|
||||
(usr || User.current).allowed_to?(:view_issues, self.project) do |role, user|
|
||||
if user.logged?
|
||||
case role.issues_visibility
|
||||
when 'all'
|
||||
true
|
||||
when 'default'
|
||||
!self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
|
||||
when 'own'
|
||||
self.author == user || user.is_or_belongs_to?(assigned_to)
|
||||
else
|
||||
false
|
||||
end
|
||||
case role.issues_visibility
|
||||
when 'all'
|
||||
true
|
||||
when 'default'
|
||||
!self.is_private? || self.author == user || user.is_or_belongs_to?(assigned_to)
|
||||
when 'own'
|
||||
self.author == user || user.is_or_belongs_to?(assigned_to)
|
||||
else
|
||||
!self.is_private?
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -155,12 +146,6 @@ class Issue < ActiveRecord::Base
|
||||
super
|
||||
end
|
||||
|
||||
def reload(*args)
|
||||
@workflow_rule_by_attribute = nil
|
||||
@assignable_versions = nil
|
||||
super
|
||||
end
|
||||
|
||||
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
||||
def available_custom_fields
|
||||
(project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : []
|
||||
@@ -179,7 +164,6 @@ class Issue < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
@copied_from = issue
|
||||
@copy_options = options
|
||||
self
|
||||
end
|
||||
|
||||
@@ -224,9 +208,7 @@ class Issue < ActiveRecord::Base
|
||||
|
||||
def status_id=(sid)
|
||||
self.status = nil
|
||||
result = write_attribute(:status_id, sid)
|
||||
@workflow_rule_by_attribute = nil
|
||||
result
|
||||
write_attribute(:status_id, sid)
|
||||
end
|
||||
|
||||
def priority_id=(pid)
|
||||
@@ -248,7 +230,6 @@ class Issue < ActiveRecord::Base
|
||||
self.tracker = nil
|
||||
result = write_attribute(:tracker_id, tid)
|
||||
@custom_field_values = nil
|
||||
@workflow_rule_by_attribute = nil
|
||||
result
|
||||
end
|
||||
|
||||
@@ -263,8 +244,6 @@ class Issue < ActiveRecord::Base
|
||||
write_attribute(:project_id, project ? project.id : nil)
|
||||
association_instance_set('project', project)
|
||||
if project_was && project && project_was != project
|
||||
@assignable_versions = nil
|
||||
|
||||
unless keep_tracker || project.trackers.include?(tracker)
|
||||
self.tracker = project.trackers.first
|
||||
end
|
||||
@@ -357,13 +336,6 @@ class Issue < ActiveRecord::Base
|
||||
:if => lambda {|issue, user| (issue.new_record? || user.allowed_to?(:edit_issues, issue.project)) &&
|
||||
user.allowed_to?(:manage_subtasks, issue.project)}
|
||||
|
||||
def safe_attribute_names(user=nil)
|
||||
names = super
|
||||
names -= disabled_core_fields
|
||||
names -= read_only_attribute_names(user)
|
||||
names
|
||||
end
|
||||
|
||||
# Safely sets attributes
|
||||
# Should be called from controllers instead of #attributes=
|
||||
# attr_accessible is too rough because we still want things like
|
||||
@@ -371,28 +343,27 @@ class Issue < ActiveRecord::Base
|
||||
def safe_attributes=(attrs, user=User.current)
|
||||
return unless attrs.is_a?(Hash)
|
||||
|
||||
attrs = attrs.dup
|
||||
# User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
|
||||
attrs = delete_unsafe_attributes(attrs, user)
|
||||
return if attrs.empty?
|
||||
|
||||
# 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')
|
||||
if allowed_target_projects(user).collect(&:id).include?(p.to_i)
|
||||
self.project_id = p
|
||||
end
|
||||
end
|
||||
|
||||
if (t = attrs.delete('tracker_id')) && safe_attribute?('tracker_id')
|
||||
if t = attrs.delete('tracker_id')
|
||||
self.tracker_id = t
|
||||
end
|
||||
|
||||
if (s = attrs.delete('status_id')) && safe_attribute?('status_id')
|
||||
if new_statuses_allowed_to(user).collect(&:id).include?(s.to_i)
|
||||
self.status_id = s
|
||||
if attrs['status_id']
|
||||
unless new_statuses_allowed_to(user).collect(&:id).include?(attrs['status_id'].to_i)
|
||||
attrs.delete('status_id')
|
||||
end
|
||||
end
|
||||
|
||||
attrs = delete_unsafe_attributes(attrs, user)
|
||||
return if attrs.empty?
|
||||
|
||||
unless leaf?
|
||||
attrs.reject! {|k,v| %w(priority_id done_ratio start_date due_date estimated_hours).include?(k)}
|
||||
end
|
||||
@@ -401,92 +372,10 @@ class Issue < ActiveRecord::Base
|
||||
attrs.delete('parent_issue_id') unless Issue.visible(user).exists?(attrs['parent_issue_id'].to_i)
|
||||
end
|
||||
|
||||
if attrs['custom_field_values'].present?
|
||||
attrs['custom_field_values'] = attrs['custom_field_values'].reject {|k, v| read_only_attribute_names(user).include? k.to_s}
|
||||
end
|
||||
|
||||
if attrs['custom_fields'].present?
|
||||
attrs['custom_fields'] = attrs['custom_fields'].reject {|c| read_only_attribute_names(user).include? c['id'].to_s}
|
||||
end
|
||||
|
||||
# mass-assignment security bypass
|
||||
assign_attributes attrs, :without_protection => true
|
||||
end
|
||||
|
||||
def disabled_core_fields
|
||||
tracker ? tracker.disabled_core_fields : []
|
||||
end
|
||||
|
||||
# Returns the custom_field_values that can be edited by the given user
|
||||
def editable_custom_field_values(user=nil)
|
||||
custom_field_values.reject do |value|
|
||||
read_only_attribute_names(user).include?(value.custom_field_id.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the names of attributes that are read-only for user or the current user
|
||||
# For users with multiple roles, the read-only fields are the intersection of
|
||||
# read-only fields of each role
|
||||
# The result is an array of strings where sustom fields are represented with their ids
|
||||
#
|
||||
# Examples:
|
||||
# issue.read_only_attribute_names # => ['due_date', '2']
|
||||
# issue.read_only_attribute_names(user) # => []
|
||||
def read_only_attribute_names(user=nil)
|
||||
workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'readonly'}.keys
|
||||
end
|
||||
|
||||
# Returns the names of required attributes for user or the current user
|
||||
# For users with multiple roles, the required fields are the intersection of
|
||||
# required fields of each role
|
||||
# The result is an array of strings where sustom fields are represented with their ids
|
||||
#
|
||||
# Examples:
|
||||
# issue.required_attribute_names # => ['due_date', '2']
|
||||
# issue.required_attribute_names(user) # => []
|
||||
def required_attribute_names(user=nil)
|
||||
workflow_rule_by_attribute(user).reject {|attr, rule| rule != 'required'}.keys
|
||||
end
|
||||
|
||||
# Returns true if the attribute is required for user
|
||||
def required_attribute?(name, user=nil)
|
||||
required_attribute_names(user).include?(name.to_s)
|
||||
end
|
||||
|
||||
# Returns a hash of the workflow rule by attribute for the given user
|
||||
#
|
||||
# Examples:
|
||||
# issue.workflow_rule_by_attribute # => {'due_date' => 'required', 'start_date' => 'readonly'}
|
||||
def workflow_rule_by_attribute(user=nil)
|
||||
return @workflow_rule_by_attribute if @workflow_rule_by_attribute && user.nil?
|
||||
|
||||
user_real = user || User.current
|
||||
roles = user_real.admin ? Role.all : user_real.roles_for_project(project)
|
||||
return {} if roles.empty?
|
||||
|
||||
result = {}
|
||||
workflow_permissions = WorkflowPermission.where(:tracker_id => tracker_id, :old_status_id => status_id, :role_id => roles.map(&:id)).all
|
||||
if workflow_permissions.any?
|
||||
workflow_rules = workflow_permissions.inject({}) do |h, wp|
|
||||
h[wp.field_name] ||= []
|
||||
h[wp.field_name] << wp.rule
|
||||
h
|
||||
end
|
||||
workflow_rules.each do |attr, rules|
|
||||
next if rules.size < roles.size
|
||||
uniq_rules = rules.uniq
|
||||
if uniq_rules.size == 1
|
||||
result[attr] = uniq_rules.first
|
||||
else
|
||||
result[attr] = 'required'
|
||||
end
|
||||
end
|
||||
end
|
||||
@workflow_rule_by_attribute = result if user.nil?
|
||||
result
|
||||
end
|
||||
private :workflow_rule_by_attribute
|
||||
|
||||
def done_ratio
|
||||
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio
|
||||
status.default_done_ratio
|
||||
@@ -548,25 +437,6 @@ class Issue < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# Validates the issue against additional workflow requirements
|
||||
def validate_required_fields
|
||||
user = new_record? ? author : current_journal.try(:user)
|
||||
|
||||
required_attribute_names(user).each do |attribute|
|
||||
if attribute =~ /^\d+$/
|
||||
attribute = attribute.to_i
|
||||
v = custom_field_values.detect {|v| v.custom_field_id == attribute }
|
||||
if v && v.value.blank?
|
||||
errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
|
||||
end
|
||||
else
|
||||
if respond_to?(attribute) && send(attribute).blank?
|
||||
errors.add attribute, :blank
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Set the done_ratio using the status if that setting is set. This will keep the done_ratios
|
||||
# even if the user turns off the setting later
|
||||
def update_done_ratio_from_issue_status
|
||||
@@ -592,19 +462,10 @@ class Issue < ActiveRecord::Base
|
||||
if new_record?
|
||||
nil
|
||||
else
|
||||
journals.maximum(:id)
|
||||
journals.first(:order => "#{Journal.table_name}.id DESC").try(:id)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a scope for journals that have an id greater than journal_id
|
||||
def journals_after(journal_id)
|
||||
scope = journals.reorder("#{Journal.table_name}.id ASC")
|
||||
if journal_id.present?
|
||||
scope = scope.where("#{Journal.table_name}.id > ?", journal_id.to_i)
|
||||
end
|
||||
scope
|
||||
end
|
||||
|
||||
# Return true if the issue is closed, otherwise false
|
||||
def closed?
|
||||
self.status.is_closed?
|
||||
@@ -661,21 +522,7 @@ class Issue < ActiveRecord::Base
|
||||
|
||||
# Versions that the issue can be assigned to
|
||||
def assignable_versions
|
||||
return @assignable_versions if @assignable_versions
|
||||
|
||||
versions = project.shared_versions.open.all
|
||||
if fixed_version
|
||||
if fixed_version_id_changed?
|
||||
# nothing to do
|
||||
elsif project_id_changed?
|
||||
if project.shared_versions.include?(fixed_version)
|
||||
versions << fixed_version
|
||||
end
|
||||
else
|
||||
versions << fixed_version
|
||||
end
|
||||
end
|
||||
@assignable_versions = versions.uniq.sort
|
||||
@assignable_versions ||= (project.shared_versions.open + [Version.find_by_id(fixed_version_id_was)]).compact.uniq.sort
|
||||
end
|
||||
|
||||
# Returns true if this issue is blocked by another issue that is still open
|
||||
@@ -855,7 +702,7 @@ class Issue < ActiveRecord::Base
|
||||
|
||||
# Returns a string of css classes that apply to the issue
|
||||
def css_classes
|
||||
s = "issue status-#{status_id} priority-#{priority_id}"
|
||||
s = "issue status-#{status.position} priority-#{priority.position}"
|
||||
s << ' closed' if closed?
|
||||
s << ' overdue' if overdue?
|
||||
s << ' child' if child?
|
||||
@@ -1011,30 +858,6 @@ class Issue < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# Copies subtasks from the copied issue
|
||||
def after_create_from_copy
|
||||
return unless copy?
|
||||
|
||||
unless @copied_from.leaf? || @copy_options[:subtasks] == false || @subtasks_copied
|
||||
@copied_from.children.each do |child|
|
||||
unless child.visible?
|
||||
# Do not copy subtasks that are not visible to avoid potential disclosure of private data
|
||||
logger.error "Subtask ##{child.id} was not copied during ##{@copied_from.id} copy because it is not visible to the current user" if logger
|
||||
next
|
||||
end
|
||||
copy = Issue.new.copy_from(child, @copy_options)
|
||||
copy.author = author
|
||||
copy.project = project
|
||||
copy.parent_issue_id = id
|
||||
# Children subtasks are copied recursively
|
||||
unless copy.save
|
||||
logger.error "Could not copy subtask ##{child.id} while copying ##{@copied_from.id} to ##{id} due to validation errors: #{copy.errors.full_messages.join(', ')}" if logger
|
||||
end
|
||||
end
|
||||
@subtasks_copied = true
|
||||
end
|
||||
end
|
||||
|
||||
def update_nested_set_attributes
|
||||
if root_id.nil?
|
||||
# issue was just created
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
class IssueStatus < ActiveRecord::Base
|
||||
before_destroy :check_integrity
|
||||
has_many :workflows, :class_name => 'WorkflowTransition', :foreign_key => "old_status_id"
|
||||
has_many :workflows, :foreign_key => "old_status_id"
|
||||
acts_as_list
|
||||
|
||||
before_destroy :delete_workflow_rules
|
||||
before_destroy :delete_workflows
|
||||
after_save :update_default
|
||||
|
||||
validates_presence_of :name
|
||||
@@ -28,23 +28,23 @@ class IssueStatus < ActiveRecord::Base
|
||||
validates_length_of :name, :maximum => 30
|
||||
validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
|
||||
|
||||
scope :sorted, order("#{table_name}.position ASC")
|
||||
scope :named, lambda {|arg| where(["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip])}
|
||||
scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
||||
|
||||
def update_default
|
||||
IssueStatus.update_all({:is_default => false}, ['id <> ?', id]) if self.is_default?
|
||||
IssueStatus.update_all("is_default=#{connection.quoted_false}", ['id <> ?', id]) if self.is_default?
|
||||
end
|
||||
|
||||
# Returns the default status for new issues
|
||||
def self.default
|
||||
where(:is_default => true).first
|
||||
find(:first, :conditions =>["is_default=?", true])
|
||||
end
|
||||
|
||||
# Update all the +Issues+ setting their done_ratio to the value of their +IssueStatus+
|
||||
def self.update_issue_done_ratios
|
||||
if Issue.use_status_for_done_ratio?
|
||||
IssueStatus.where("default_done_ratio >= 0").all.each do |status|
|
||||
Issue.update_all({:done_ratio => status.default_done_ratio}, {:status_id => status.id})
|
||||
IssueStatus.find(:all, :conditions => ["default_done_ratio >= 0"]).each do |status|
|
||||
Issue.update_all(["done_ratio = ?", status.default_done_ratio],
|
||||
["status_id = ?", status.id])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ class IssueStatus < ActiveRecord::Base
|
||||
w.tracker_id == tracker.id &&
|
||||
((!w.author && !w.assignee) || (author && w.author) || (assignee && w.assignee))
|
||||
end
|
||||
transitions.map(&:new_status).compact.sort
|
||||
transitions.collect{|w| w.new_status}.compact.sort
|
||||
else
|
||||
[]
|
||||
end
|
||||
@@ -75,12 +75,12 @@ class IssueStatus < ActiveRecord::Base
|
||||
conditions << " OR author = :true" if author
|
||||
conditions << " OR assignee = :true" if assignee
|
||||
|
||||
workflows.
|
||||
includes(:new_status).
|
||||
where(["role_id IN (:role_ids) AND tracker_id = :tracker_id AND (#{conditions})",
|
||||
workflows.find(:all,
|
||||
:include => :new_status,
|
||||
:conditions => ["role_id IN (:role_ids) AND tracker_id = :tracker_id AND (#{conditions})",
|
||||
{:role_ids => roles.collect(&:id), :tracker_id => tracker.id, :true => true, :false => false}
|
||||
]).all.
|
||||
map(&:new_status).compact.sort
|
||||
]
|
||||
).collect{|w| w.new_status}.compact.sort
|
||||
else
|
||||
[]
|
||||
end
|
||||
@@ -92,14 +92,13 @@ class IssueStatus < ActiveRecord::Base
|
||||
|
||||
def to_s; name end
|
||||
|
||||
private
|
||||
|
||||
private
|
||||
def check_integrity
|
||||
raise "Can't delete status" if Issue.where(:status_id => id).any?
|
||||
raise "Can't delete status" if Issue.find(:first, :conditions => ["status_id=?", self.id])
|
||||
end
|
||||
|
||||
# Deletes associated workflows
|
||||
def delete_workflow_rules
|
||||
WorkflowRule.delete_all(["old_status_id = :id OR new_status_id = :id", {:id => id}])
|
||||
def delete_workflows
|
||||
Workflow.delete_all(["old_status_id = :id OR new_status_id = :id", {:id => id}])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -124,7 +124,6 @@ class MailHandler < ActionMailer::Base
|
||||
|
||||
def dispatch
|
||||
headers = [email.in_reply_to, email.references].flatten.compact
|
||||
subject = email.subject.to_s
|
||||
if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
|
||||
klass, object_id = $1, $2.to_i
|
||||
method_name = "receive_#{klass}_reply"
|
||||
@@ -133,9 +132,9 @@ class MailHandler < ActionMailer::Base
|
||||
else
|
||||
# ignoring it
|
||||
end
|
||||
elsif m = subject.match(ISSUE_REPLY_SUBJECT_RE)
|
||||
elsif m = email.subject.match(ISSUE_REPLY_SUBJECT_RE)
|
||||
receive_issue_reply(m[1].to_i)
|
||||
elsif m = subject.match(MESSAGE_REPLY_SUBJECT_RE)
|
||||
elsif m = email.subject.match(MESSAGE_REPLY_SUBJECT_RE)
|
||||
receive_message_reply(m[1].to_i)
|
||||
else
|
||||
dispatch_to_default
|
||||
@@ -245,26 +244,9 @@ class MailHandler < ActionMailer::Base
|
||||
def add_attachments(obj)
|
||||
if email.attachments && email.attachments.any?
|
||||
email.attachments.each do |attachment|
|
||||
filename = attachment.filename
|
||||
unless filename.respond_to?(:encoding)
|
||||
# try to reencode to utf8 manually with ruby1.8
|
||||
h = attachment.header['Content-Disposition']
|
||||
unless h.nil?
|
||||
begin
|
||||
if m = h.value.match(/filename\*[0-9\*]*=([^=']+)'/)
|
||||
filename = Redmine::CodesetUtil.to_utf8(filename, m[1])
|
||||
elsif m = h.value.match(/filename=.*=\?([^\?]+)\?[BbQq]\?/)
|
||||
# http://tools.ietf.org/html/rfc2047#section-4
|
||||
filename = Redmine::CodesetUtil.to_utf8(filename, m[1])
|
||||
end
|
||||
rescue
|
||||
# nop
|
||||
end
|
||||
end
|
||||
end
|
||||
obj.attachments << Attachment.create(:container => obj,
|
||||
:file => attachment.decoded,
|
||||
:filename => filename,
|
||||
:filename => attachment.filename,
|
||||
:author => user,
|
||||
:content_type => attachment.mime_type)
|
||||
end
|
||||
@@ -360,8 +342,8 @@ class MailHandler < ActionMailer::Base
|
||||
# Returns a Hash of issue custom field values extracted from keywords in the email body
|
||||
def custom_field_values_from_keywords(customized)
|
||||
customized.custom_field_values.inject({}) do |h, v|
|
||||
if keyword = get_keyword(v.custom_field.name, :override => true)
|
||||
h[v.custom_field.id.to_s] = v.custom_field.value_from_keyword(keyword, customized)
|
||||
if value = get_keyword(v.custom_field.name, :override => true)
|
||||
h[v.custom_field.id.to_s] = value
|
||||
end
|
||||
h
|
||||
end
|
||||
@@ -391,8 +373,7 @@ class MailHandler < ActionMailer::Base
|
||||
# try to reencode to utf8 manually with ruby1.8
|
||||
begin
|
||||
if h = email.header[:subject]
|
||||
# http://tools.ietf.org/html/rfc2047#section-4
|
||||
if m = h.value.match(/=\?([^\?]+)\?[BbQq]\?/)
|
||||
if m = h.value.match(/^=\?([^\?]+)\?/)
|
||||
subject = Redmine::CodesetUtil.to_utf8(subject, m[1])
|
||||
end
|
||||
end
|
||||
@@ -487,7 +468,7 @@ class MailHandler < ActionMailer::Base
|
||||
}
|
||||
end
|
||||
if assignee.nil?
|
||||
assignee ||= assignable.detect {|a| a.name.downcase == keyword}
|
||||
assignee ||= assignable.detect {|a| a.is_a?(Group) && a.name.downcase == keyword}
|
||||
end
|
||||
assignee
|
||||
end
|
||||
|
||||
@@ -327,31 +327,22 @@ class Mailer < ActionMailer::Base
|
||||
# * :days => how many days in the future to remind about (defaults to 7)
|
||||
# * :tracker => id of tracker for filtering issues (defaults to all trackers)
|
||||
# * :project => id or identifier of project to process (defaults to all projects)
|
||||
# * :users => array of user/group ids who should be reminded
|
||||
# * :users => array of user ids who should be reminded
|
||||
def self.reminders(options={})
|
||||
days = options[:days] || 7
|
||||
project = options[:project] ? Project.find(options[:project]) : nil
|
||||
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
|
||||
user_ids = options[:users]
|
||||
|
||||
scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" +
|
||||
scope = Issue.open.scoped(:conditions => ["#{Issue.table_name}.assigned_to_id IS NOT NULL" +
|
||||
" AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" +
|
||||
" AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date
|
||||
" AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date]
|
||||
)
|
||||
scope = scope.where(:assigned_to_id => user_ids) if user_ids.present?
|
||||
scope = scope.where(:project_id => project.id) if project
|
||||
scope = scope.where(:tracker_id => tracker.id) if tracker
|
||||
|
||||
issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker).all.group_by(&:assigned_to)
|
||||
issues_by_assignee.keys.each do |assignee|
|
||||
if assignee.is_a?(Group)
|
||||
assignee.users.each do |user|
|
||||
issues_by_assignee[user] ||= []
|
||||
issues_by_assignee[user] += issues_by_assignee[assignee]
|
||||
end
|
||||
end
|
||||
end
|
||||
scope = scope.scoped(:conditions => {:assigned_to_id => user_ids}) if user_ids.present?
|
||||
scope = scope.scoped(:conditions => {:project_id => project.id}) if project
|
||||
scope = scope.scoped(:conditions => {:tracker_id => tracker.id}) if tracker
|
||||
|
||||
issues_by_assignee = scope.all(:include => [:status, :assigned_to, :project, :tracker]).group_by(&:assigned_to)
|
||||
issues_by_assignee.each do |assignee, issues|
|
||||
reminder(assignee, issues, days).deliver if assignee.is_a?(User) && assignee.active?
|
||||
end
|
||||
|
||||
@@ -41,9 +41,9 @@ class Message < ActiveRecord::Base
|
||||
validates_length_of :subject, :maximum => 255
|
||||
validate :cannot_reply_to_locked_topic, :on => :create
|
||||
|
||||
after_create :add_author_as_watcher, :reset_counters!
|
||||
after_create :add_author_as_watcher, :update_parent_last_reply
|
||||
after_update :update_messages_board
|
||||
after_destroy :reset_counters!
|
||||
after_destroy :reset_board_counters
|
||||
|
||||
scope :visible, lambda {|*args| { :include => {:board => :project},
|
||||
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
|
||||
@@ -63,6 +63,13 @@ class Message < ActiveRecord::Base
|
||||
errors.add :base, 'Topic is locked' if root.locked? && self != root
|
||||
end
|
||||
|
||||
def update_parent_last_reply
|
||||
if parent
|
||||
parent.reload.update_attribute(:last_reply_id, self.id)
|
||||
end
|
||||
board.reset_counters!
|
||||
end
|
||||
|
||||
def update_messages_board
|
||||
if board_id_changed?
|
||||
Message.update_all("board_id = #{board_id}", ["id = ? OR parent_id = ?", root.id, root.id])
|
||||
@@ -71,10 +78,7 @@ class Message < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def reset_counters!
|
||||
if parent && parent.id
|
||||
Message.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id})
|
||||
end
|
||||
def reset_board_counters
|
||||
board.reset_counters!
|
||||
end
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class Principal < ActiveRecord::Base
|
||||
self.table_name = "#{table_name_prefix}users#{table_name_suffix}"
|
||||
|
||||
has_many :members, :foreign_key => 'user_id', :dependent => :destroy
|
||||
has_many :memberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :project, :roles ], :conditions => "#{Project.table_name}.status<>#{Project::STATUS_ARCHIVED}", :order => "#{Project.table_name}.name"
|
||||
has_many :memberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :project, :roles ], :conditions => "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}", :order => "#{Project.table_name}.name"
|
||||
has_many :projects, :through => :memberships
|
||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||
|
||||
@@ -30,13 +30,13 @@ class Principal < ActiveRecord::Base
|
||||
if q.blank?
|
||||
{}
|
||||
else
|
||||
q = q.to_s
|
||||
q = q.to_s.downcase
|
||||
pattern = "%#{q}%"
|
||||
sql = "LOWER(login) LIKE LOWER(:p) OR LOWER(firstname) LIKE LOWER(:p) OR LOWER(lastname) LIKE LOWER(:p) OR LOWER(mail) LIKE LOWER(:p)"
|
||||
sql = "LOWER(login) LIKE :p OR LOWER(firstname) LIKE :p OR LOWER(lastname) LIKE :p OR LOWER(mail) LIKE :p"
|
||||
params = {:p => pattern}
|
||||
if q =~ /^(.+)\s+(.+)$/
|
||||
a, b = "#{$1}%", "#{$2}%"
|
||||
sql << " OR (LOWER(firstname) LIKE LOWER(:a) AND LOWER(lastname) LIKE LOWER(:b)) OR (LOWER(firstname) LIKE LOWER(:b) AND LOWER(lastname) LIKE LOWER(:a))"
|
||||
sql << " OR (LOWER(firstname) LIKE :a AND LOWER(lastname) LIKE :b) OR (LOWER(firstname) LIKE :b AND LOWER(lastname) LIKE :a)"
|
||||
params.merge!(:a => a, :b => b)
|
||||
end
|
||||
{:conditions => [sql, params]}
|
||||
|
||||
@@ -20,7 +20,6 @@ class Project < ActiveRecord::Base
|
||||
|
||||
# Project statuses
|
||||
STATUS_ACTIVE = 1
|
||||
STATUS_CLOSED = 5
|
||||
STATUS_ARCHIVED = 9
|
||||
|
||||
# Maximum length for project identifiers
|
||||
@@ -81,7 +80,6 @@ class Project < ActiveRecord::Base
|
||||
# reserved words
|
||||
validates_exclusion_of :identifier, :in => %w( new )
|
||||
|
||||
after_save :update_position_under_parent, :if => Proc.new {|project| project.name_changed?}
|
||||
before_destroy :delete_all_members
|
||||
|
||||
scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } }
|
||||
@@ -123,7 +121,7 @@ class Project < ActiveRecord::Base
|
||||
self.enabled_module_names = Setting.default_projects_modules
|
||||
end
|
||||
if !initialized.key?('trackers') && !initialized.key?('tracker_ids')
|
||||
self.trackers = Tracker.sorted.all
|
||||
self.trackers = Tracker.all
|
||||
end
|
||||
end
|
||||
|
||||
@@ -163,11 +161,12 @@ class Project < ActiveRecord::Base
|
||||
# * :with_subprojects => limit the condition to project and its subprojects
|
||||
# * :member => limit the condition to the user projects
|
||||
def self.allowed_to_condition(user, permission, options={})
|
||||
perm = Redmine::AccessControl.permission(permission)
|
||||
base_statement = (perm && perm.read? ? "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" : "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}")
|
||||
if perm && perm.project_module
|
||||
# If the permission belongs to a project module, make sure the module is enabled
|
||||
base_statement << " AND #{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.project_module}')"
|
||||
base_statement = "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"
|
||||
if perm = Redmine::AccessControl.permission(permission)
|
||||
unless perm.project_module.nil?
|
||||
# If the permission belongs to a project module, make sure the module is enabled
|
||||
base_statement << " AND #{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.project_module}')"
|
||||
end
|
||||
end
|
||||
if options[:project]
|
||||
project_statement = "#{Project.table_name}.id = #{options[:project].id}"
|
||||
@@ -187,7 +186,7 @@ class Project < ActiveRecord::Base
|
||||
end
|
||||
if user.logged?
|
||||
user.projects_by_role.each do |role, projects|
|
||||
if role.allowed_to?(permission) && projects.any?
|
||||
if role.allowed_to?(permission)
|
||||
statement_by_role[role] = "#{Project.table_name}.id IN (#{projects.collect(&:id).join(',')})"
|
||||
end
|
||||
end
|
||||
@@ -326,14 +325,6 @@ class Project < ActiveRecord::Base
|
||||
update_attribute :status, STATUS_ACTIVE
|
||||
end
|
||||
|
||||
def close
|
||||
self_and_descendants.status(STATUS_ACTIVE).update_all :status => STATUS_CLOSED
|
||||
end
|
||||
|
||||
def reopen
|
||||
self_and_descendants.status(STATUS_CLOSED).update_all :status => STATUS_ACTIVE
|
||||
end
|
||||
|
||||
# Returns an array of projects the project can be moved to
|
||||
# by the current user
|
||||
def allowed_parents
|
||||
@@ -384,7 +375,22 @@ class Project < ActiveRecord::Base
|
||||
# Nothing to do
|
||||
true
|
||||
elsif p.nil? || (p.active? && move_possible?(p))
|
||||
set_or_update_position_under(p)
|
||||
# Insert the project so that target's children or root projects stay alphabetically sorted
|
||||
sibs = (p.nil? ? self.class.roots : p.children)
|
||||
to_be_inserted_before = sibs.detect {|c| c.name.to_s.downcase > name.to_s.downcase }
|
||||
if to_be_inserted_before
|
||||
move_to_left_of(to_be_inserted_before)
|
||||
elsif p.nil?
|
||||
if sibs.empty?
|
||||
# move_to_root adds the project in first (ie. left) position
|
||||
move_to_root
|
||||
else
|
||||
move_to_right_of(sibs.last) unless self == sibs.last
|
||||
end
|
||||
else
|
||||
# move_to_child_of adds the project in last (ie.right) position
|
||||
move_to_child_of(p)
|
||||
end
|
||||
Issue.update_versions_from_hierarchy_change(self)
|
||||
true
|
||||
else
|
||||
@@ -398,7 +404,7 @@ class Project < ActiveRecord::Base
|
||||
@rolled_up_trackers ||=
|
||||
Tracker.find(:all, :joins => :projects,
|
||||
:select => "DISTINCT #{Tracker.table_name}.*",
|
||||
:conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> #{STATUS_ARCHIVED}", lft, rgt],
|
||||
:conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt],
|
||||
:order => "#{Tracker.table_name}.position")
|
||||
end
|
||||
|
||||
@@ -417,20 +423,20 @@ class Project < ActiveRecord::Base
|
||||
def rolled_up_versions
|
||||
@rolled_up_versions ||=
|
||||
Version.scoped(:include => :project,
|
||||
:conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status <> #{STATUS_ARCHIVED}", lft, rgt])
|
||||
:conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt])
|
||||
end
|
||||
|
||||
# Returns a scope of the Versions used by the project
|
||||
def shared_versions
|
||||
if new_record?
|
||||
Version.scoped(:include => :project,
|
||||
:conditions => "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND #{Version.table_name}.sharing = 'system'")
|
||||
:conditions => "#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND #{Version.table_name}.sharing = 'system'")
|
||||
else
|
||||
@shared_versions ||= begin
|
||||
r = root? ? self : root
|
||||
Version.scoped(:include => :project,
|
||||
:conditions => "#{Project.table_name}.id = #{id}" +
|
||||
" OR (#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND (" +
|
||||
" OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" +
|
||||
" #{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 < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" +
|
||||
@@ -509,13 +515,6 @@ class Project < ActiveRecord::Base
|
||||
s << ' root' if root?
|
||||
s << ' child' if child?
|
||||
s << (leaf? ? ' leaf' : ' parent')
|
||||
unless active?
|
||||
if archived?
|
||||
s << ' archived'
|
||||
else
|
||||
s << ' closed'
|
||||
end
|
||||
end
|
||||
s
|
||||
end
|
||||
|
||||
@@ -559,20 +558,11 @@ class Project < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# Return true if this project allows to do the specified action.
|
||||
# Return true if this project is allowed to do the specified action.
|
||||
# action can be:
|
||||
# * a parameter-like Hash (eg. :controller => 'projects', :action => 'edit')
|
||||
# * a permission Symbol (eg. :edit_project)
|
||||
def allows_to?(action)
|
||||
if archived?
|
||||
# No action allowed on archived projects
|
||||
return false
|
||||
end
|
||||
unless active? || Redmine::AccessControl.read_action?(action)
|
||||
# No write action allowed on closed projects
|
||||
return false
|
||||
end
|
||||
# No action allowed on disabled modules
|
||||
if action.is_a? Hash
|
||||
allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
|
||||
else
|
||||
@@ -763,30 +753,27 @@ class Project < ActiveRecord::Base
|
||||
end
|
||||
|
||||
# Copies issues from +project+
|
||||
# Note: issues assigned to a closed version won't be copied due to validation rules
|
||||
def copy_issues(project)
|
||||
# Stores the source issue id as a key and the copied issues as the
|
||||
# value. Used to map the two togeather for issue relations.
|
||||
issues_map = {}
|
||||
|
||||
# Store status and reopen locked/closed versions
|
||||
version_statuses = versions.reject(&:open?).map {|version| [version, version.status]}
|
||||
version_statuses.each do |version, status|
|
||||
version.update_attribute :status, 'open'
|
||||
end
|
||||
|
||||
# Get issues sorted by root_id, lft so that parent issues
|
||||
# get copied before their children
|
||||
project.issues.find(:all, :order => 'root_id, lft').each do |issue|
|
||||
new_issue = Issue.new
|
||||
new_issue.copy_from(issue, :subtasks => false)
|
||||
new_issue.copy_from(issue)
|
||||
new_issue.project = self
|
||||
# Reassign fixed_versions by name, since names are unique per project
|
||||
if issue.fixed_version && issue.fixed_version.project == project
|
||||
new_issue.fixed_version = self.versions.detect {|v| v.name == issue.fixed_version.name}
|
||||
# Reassign fixed_versions by name, since names are unique per
|
||||
# project and the versions for self are not yet saved
|
||||
if issue.fixed_version
|
||||
new_issue.fixed_version = self.versions.select {|v| v.name == issue.fixed_version.name}.first
|
||||
end
|
||||
# Reassign the category by name, since names are unique per project
|
||||
# Reassign the category by name, since names are unique per
|
||||
# project and the categories for self are not yet saved
|
||||
if issue.category
|
||||
new_issue.category = self.issue_categories.detect {|c| c.name == issue.category.name}
|
||||
new_issue.category = self.issue_categories.select {|c| c.name == issue.category.name}.first
|
||||
end
|
||||
# Parent issue
|
||||
if issue.parent_id
|
||||
@@ -803,11 +790,6 @@ class Project < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# Restore locked/closed version statuses
|
||||
version_statuses.each do |version, status|
|
||||
version.update_attribute :status, status
|
||||
end
|
||||
|
||||
# Relations after in case issues related each other
|
||||
project.issues.each do |issue|
|
||||
new_issue = issues_map[issue.id]
|
||||
@@ -937,28 +919,4 @@ class Project < ActiveRecord::Base
|
||||
end
|
||||
update_attribute :status, STATUS_ARCHIVED
|
||||
end
|
||||
|
||||
def update_position_under_parent
|
||||
set_or_update_position_under(parent)
|
||||
end
|
||||
|
||||
# Inserts/moves the project so that target's children or root projects stay alphabetically sorted
|
||||
def set_or_update_position_under(target_parent)
|
||||
sibs = (target_parent.nil? ? self.class.roots : target_parent.children)
|
||||
to_be_inserted_before = sibs.sort_by {|c| c.name.to_s.downcase}.detect {|c| c.name.to_s.downcase > name.to_s.downcase }
|
||||
|
||||
if to_be_inserted_before
|
||||
move_to_left_of(to_be_inserted_before)
|
||||
elsif target_parent.nil?
|
||||
if sibs.empty?
|
||||
# move_to_root adds the project in first (ie. left) position
|
||||
move_to_root
|
||||
else
|
||||
move_to_right_of(sibs.last) unless self == sibs.last
|
||||
end
|
||||
else
|
||||
# move_to_child_of adds the project in last (ie.right) position
|
||||
move_to_child_of(target_parent)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,7 +57,10 @@ class QueryCustomFieldColumn < QueryColumn
|
||||
def initialize(custom_field)
|
||||
self.name = "cf_#{custom_field.id}".to_sym
|
||||
self.sortable = custom_field.order_statement || false
|
||||
self.groupable = custom_field.group_statement || false
|
||||
if %w(list date bool int).include?(custom_field.field_format) && !custom_field.multiple?
|
||||
self.groupable = custom_field.order_statement
|
||||
end
|
||||
self.groupable ||= false
|
||||
@cf = custom_field
|
||||
end
|
||||
|
||||
@@ -141,7 +144,7 @@ class Query < ActiveRecord::Base
|
||||
QueryColumn.new(:assigned_to, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
|
||||
QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
|
||||
QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true),
|
||||
QueryColumn.new(:fixed_version, :sortable => lambda {Version.fields_for_order_statement}, :groupable => true),
|
||||
QueryColumn.new(:fixed_version, :sortable => ["#{Version.table_name}.effective_date", "#{Version.table_name}.name"], :default_order => 'desc', :groupable => true),
|
||||
QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
|
||||
QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
|
||||
QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
|
||||
@@ -210,18 +213,11 @@ class Query < ActiveRecord::Base
|
||||
is_public && !@is_for_all && user.allowed_to?(:manage_public_queries, project)
|
||||
end
|
||||
|
||||
def trackers
|
||||
@trackers ||= project.nil? ? Tracker.find(:all, :order => 'position') : project.rolled_up_trackers
|
||||
end
|
||||
|
||||
# Returns a hash of localized labels for all filter operators
|
||||
def self.operators_labels
|
||||
operators.inject({}) {|h, operator| h[operator.first] = l(operator.last); h}
|
||||
end
|
||||
|
||||
def available_filters
|
||||
return @available_filters if @available_filters
|
||||
|
||||
trackers = project.nil? ? Tracker.find(:all, :order => 'position') : project.rolled_up_trackers
|
||||
|
||||
@available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
|
||||
"tracker_id" => { :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } },
|
||||
"priority_id" => { :type => :list, :order => 3, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s] } },
|
||||
@@ -304,34 +300,9 @@ class Query < ActiveRecord::Base
|
||||
end
|
||||
add_custom_fields_filters(IssueCustomField.find(:all, :conditions => {:is_filter => true, :is_for_all => true}))
|
||||
end
|
||||
|
||||
add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version
|
||||
|
||||
if User.current.allowed_to?(:set_issues_private, nil, :global => true) ||
|
||||
User.current.allowed_to?(:set_own_issues_private, nil, :global => true)
|
||||
@available_filters["is_private"] = { :type => :list, :order => 15, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]] }
|
||||
end
|
||||
|
||||
Tracker.disabled_core_fields(trackers).each {|field|
|
||||
@available_filters.delete field
|
||||
}
|
||||
|
||||
@available_filters.each do |field, options|
|
||||
options[:name] ||= l("field_#{field}".gsub(/_id$/, ''))
|
||||
end
|
||||
|
||||
@available_filters
|
||||
end
|
||||
|
||||
# Returns a representation of the available filters for JSON serialization
|
||||
def available_filters_as_json
|
||||
json = {}
|
||||
available_filters.each do |field, options|
|
||||
json[field] = options.slice(:type, :name, :values).stringify_keys
|
||||
end
|
||||
json
|
||||
end
|
||||
|
||||
def add_filter(field, operator, values)
|
||||
# values must be an array
|
||||
return unless values.nil? || values.is_a?(Array)
|
||||
@@ -409,17 +380,6 @@ class Query < ActiveRecord::Base
|
||||
:caption => :label_spent_time
|
||||
)
|
||||
end
|
||||
|
||||
if User.current.allowed_to?(:set_issues_private, nil, :global => true) ||
|
||||
User.current.allowed_to?(:set_own_issues_private, nil, :global => true)
|
||||
@available_columns << QueryColumn.new(:is_private, :sortable => "#{Issue.table_name}.is_private")
|
||||
end
|
||||
|
||||
disabled_fields = Tracker.disabled_core_fields(trackers).map {|field| field.sub(/_id$/, '')}
|
||||
@available_columns.reject! {|column|
|
||||
disabled_fields.include?(column.name.to_s)
|
||||
}
|
||||
|
||||
@available_columns
|
||||
end
|
||||
|
||||
@@ -574,7 +534,7 @@ class Query < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
if field =~ /cf_(\d+)$/
|
||||
if field =~ /^cf_(\d+)$/
|
||||
# custom field
|
||||
filters_clauses << sql_for_custom_field(field, operator, v, $1)
|
||||
elsif respond_to?("sql_for_#{field}_field")
|
||||
@@ -624,11 +584,13 @@ class Query < ActiveRecord::Base
|
||||
def issues(options={})
|
||||
order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
|
||||
order_option = nil if order_option.blank?
|
||||
|
||||
joins = (order_option && order_option.include?('authors')) ? "LEFT OUTER JOIN users authors ON authors.id = #{Issue.table_name}.author_id" : nil
|
||||
|
||||
issues = Issue.visible.scoped(:conditions => options[:conditions]).find :all, :include => ([:status, :project] + (options[:include] || [])).uniq,
|
||||
:conditions => statement,
|
||||
:order => order_option,
|
||||
:joins => joins_for_order_statement(order_option),
|
||||
:joins => joins,
|
||||
:limit => options[:limit],
|
||||
:offset => options[:offset]
|
||||
|
||||
@@ -644,11 +606,13 @@ class Query < ActiveRecord::Base
|
||||
def issue_ids(options={})
|
||||
order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
|
||||
order_option = nil if order_option.blank?
|
||||
|
||||
joins = (order_option && order_option.include?('authors')) ? "LEFT OUTER JOIN users authors ON authors.id = #{Issue.table_name}.author_id" : nil
|
||||
|
||||
Issue.visible.scoped(:conditions => options[:conditions]).scoped(:include => ([:status, :project] + (options[:include] || [])).uniq,
|
||||
:conditions => statement,
|
||||
:order => order_option,
|
||||
:joins => joins_for_order_statement(order_option),
|
||||
:joins => joins,
|
||||
:limit => options[:limit],
|
||||
:offset => options[:offset]).find_ids
|
||||
rescue ::ActiveRecord::StatementInvalid => e
|
||||
@@ -722,21 +686,13 @@ class Query < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def sql_for_is_private_field(field, operator, value)
|
||||
op = (operator == "=" ? 'IN' : 'NOT IN')
|
||||
va = value.map {|v| v == '0' ? connection.quoted_false : connection.quoted_true}.uniq.join(',')
|
||||
|
||||
"#{Issue.table_name}.is_private #{op} (#{va})"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sql_for_custom_field(field, operator, value, custom_field_id)
|
||||
db_table = CustomValue.table_name
|
||||
db_field = 'value'
|
||||
filter = @available_filters[field]
|
||||
return nil unless filter
|
||||
if filter[:format] == 'user'
|
||||
if filter && filter[:format] == 'user'
|
||||
if value.delete('me')
|
||||
value.push User.current.id.to_s
|
||||
end
|
||||
@@ -747,15 +703,7 @@ class Query < ActiveRecord::Base
|
||||
operator = '='
|
||||
not_in = 'NOT'
|
||||
end
|
||||
customized_key = "id"
|
||||
customized_class = Issue
|
||||
if field =~ /^(.+)\.cf_/
|
||||
assoc = $1
|
||||
customized_key = "#{assoc}_id"
|
||||
customized_class = Issue.reflect_on_association(assoc.to_sym).klass.base_class rescue nil
|
||||
raise "Unknown Issue association #{assoc}" unless customized_class
|
||||
end
|
||||
"#{Issue.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 " +
|
||||
"#{Issue.table_name}.id #{not_in} IN (SELECT #{Issue.table_name}.id FROM #{Issue.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{custom_field_id} WHERE " +
|
||||
sql_for_field(field, operator, value, db_table, db_field, true) + ')'
|
||||
end
|
||||
|
||||
@@ -864,8 +812,7 @@ class Query < ActiveRecord::Base
|
||||
return sql
|
||||
end
|
||||
|
||||
def add_custom_fields_filters(custom_fields, assoc=nil)
|
||||
return unless custom_fields.present?
|
||||
def add_custom_fields_filters(custom_fields)
|
||||
@available_filters ||= {}
|
||||
|
||||
custom_fields.select(&:is_filter?).each do |field|
|
||||
@@ -892,25 +839,7 @@ class Query < ActiveRecord::Base
|
||||
else
|
||||
options = { :type => :string, :order => 20 }
|
||||
end
|
||||
filter_id = "cf_#{field.id}"
|
||||
filter_name = field.name
|
||||
if assoc.present?
|
||||
filter_id = "#{assoc}.#{filter_id}"
|
||||
filter_name = l("label_attribute_of_#{assoc}", :name => filter_name)
|
||||
end
|
||||
@available_filters[filter_id] = options.merge({ :name => filter_name, :format => field.field_format })
|
||||
end
|
||||
end
|
||||
|
||||
def add_associations_custom_fields_filters(*associations)
|
||||
fields_by_class = CustomField.where(:is_filter => true).group_by(&:class)
|
||||
associations.each do |assoc|
|
||||
association_klass = Issue.reflect_on_association(assoc).klass
|
||||
fields_by_class.each do |field_class, fields|
|
||||
if field_class.customized_class <= association_klass
|
||||
add_custom_fields_filters(fields, assoc)
|
||||
end
|
||||
end
|
||||
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name, :format => field.field_format })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -939,24 +868,4 @@ class Query < ActiveRecord::Base
|
||||
def relative_date_clause(table, field, days_from, days_to)
|
||||
date_clause(table, field, (days_from ? Date.today + days_from : nil), (days_to ? Date.today + days_to : nil))
|
||||
end
|
||||
|
||||
# Additional joins required for the given sort options
|
||||
def joins_for_order_statement(order_options)
|
||||
joins = []
|
||||
|
||||
if order_options
|
||||
if order_options.include?('authors')
|
||||
joins << "LEFT OUTER JOIN #{User.table_name} authors ON authors.id = #{Issue.table_name}.author_id"
|
||||
end
|
||||
order_options.scan(/cf_\d+/).uniq.each do |name|
|
||||
column = available_columns.detect {|c| c.name.to_s == name}
|
||||
join = column && column.custom_field.join_for_order_statement
|
||||
if join
|
||||
joins << join
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
joins.any? ? joins.join(' ') : nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,10 +19,6 @@ class ScmFetchError < Exception; end
|
||||
|
||||
class Repository < ActiveRecord::Base
|
||||
include Redmine::Ciphering
|
||||
include Redmine::SafeAttributes
|
||||
|
||||
# Maximum length for repository identifiers
|
||||
IDENTIFIER_MAX_LENGTH = 255
|
||||
|
||||
belongs_to :project
|
||||
has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
|
||||
@@ -37,7 +33,7 @@ class Repository < ActiveRecord::Base
|
||||
before_destroy :clear_changesets
|
||||
|
||||
validates_length_of :password, :maximum => 255, :allow_nil => true
|
||||
validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
|
||||
validates_length_of :identifier, :maximum => 255, :allow_blank => true
|
||||
validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
|
||||
validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
|
||||
validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
|
||||
@@ -46,16 +42,6 @@ class Repository < ActiveRecord::Base
|
||||
# Checks if the SCM is enabled when creating a repository
|
||||
validate :repo_create_validation, :on => :create
|
||||
|
||||
safe_attributes 'identifier',
|
||||
'login',
|
||||
'password',
|
||||
'path_encoding',
|
||||
'log_encoding',
|
||||
'is_default'
|
||||
|
||||
safe_attributes 'url',
|
||||
:if => lambda {|repository, user| repository.new_record?}
|
||||
|
||||
def repo_create_validation
|
||||
unless Setting.enabled_scm.include?(self.class.name.demodulize)
|
||||
errors.add(:type, :invalid)
|
||||
@@ -117,14 +103,6 @@ class Repository < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def identifier=(identifier)
|
||||
super unless identifier_frozen?
|
||||
end
|
||||
|
||||
def identifier_frozen?
|
||||
errors[:identifier].blank? && !(new_record? || identifier.blank?)
|
||||
end
|
||||
|
||||
def identifier_param
|
||||
if is_default?
|
||||
nil
|
||||
@@ -189,9 +167,7 @@ class Repository < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def entries(path=nil, identifier=nil)
|
||||
entries = scm.entries(path, identifier)
|
||||
load_entries_changesets(entries)
|
||||
entries
|
||||
scm.entries(path, identifier)
|
||||
end
|
||||
|
||||
def branches
|
||||
@@ -404,16 +380,6 @@ class Repository < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def load_entries_changesets(entries)
|
||||
if entries
|
||||
entries.each do |entry|
|
||||
if entry.lastrev && entry.lastrev.identifier
|
||||
entry.changeset = find_changeset_by_name(entry.lastrev.identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Deletes repository data
|
||||
@@ -427,9 +393,5 @@ class Repository < ActiveRecord::Base
|
||||
connection.delete("DELETE FROM #{ci} WHERE #{ci}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
|
||||
connection.delete("DELETE FROM #{cp} WHERE #{cp}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
|
||||
connection.delete("DELETE FROM #{cs} WHERE #{cs}.repository_id = #{id}")
|
||||
clear_extra_info_of_changesets
|
||||
end
|
||||
|
||||
def clear_extra_info_of_changesets
|
||||
end
|
||||
end
|
||||
|
||||
@@ -63,8 +63,6 @@ class Repository::Bazaar < Repository
|
||||
end
|
||||
end
|
||||
end
|
||||
load_entries_changesets(entries)
|
||||
entries
|
||||
end
|
||||
|
||||
def fetch_changesets
|
||||
|
||||
@@ -21,9 +21,6 @@ require 'digest/sha1'
|
||||
class Repository::Cvs < Repository
|
||||
validates_presence_of :url, :root_url, :log_encoding
|
||||
|
||||
safe_attributes 'root_url',
|
||||
:if => lambda {|repository, user| repository.new_record?}
|
||||
|
||||
def self.human_attribute_name(attribute_key_name, *args)
|
||||
attr_name = attribute_key_name.to_s
|
||||
if attr_name == "root_url"
|
||||
@@ -69,7 +66,6 @@ class Repository::Cvs < Repository
|
||||
end
|
||||
end
|
||||
end
|
||||
load_entries_changesets(entries)
|
||||
entries
|
||||
end
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ class Repository::Darcs < Repository
|
||||
end
|
||||
end
|
||||
end
|
||||
load_entries_changesets(entries)
|
||||
entries
|
||||
end
|
||||
|
||||
|
||||
@@ -44,6 +44,10 @@ class Repository::Filesystem < Repository
|
||||
false
|
||||
end
|
||||
|
||||
def entries(path=nil, identifier=nil)
|
||||
scm.entries(path, identifier)
|
||||
end
|
||||
|
||||
def fetch_changesets
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -87,16 +87,16 @@ class Repository::Git < Repository
|
||||
end
|
||||
|
||||
def find_changeset_by_name(name)
|
||||
if name.present?
|
||||
changesets.where(:revision => name.to_s).first ||
|
||||
changesets.where('scmid LIKE ?', "#{name}%").first
|
||||
end
|
||||
return nil if name.nil? || name.empty?
|
||||
e = changesets.find(:first, :conditions => ['revision = ?', name.to_s])
|
||||
return e if e
|
||||
changesets.find(:first, :conditions => ['scmid LIKE ?', "#{name}%"])
|
||||
end
|
||||
|
||||
def entries(path=nil, identifier=nil)
|
||||
entries = scm.entries(path, identifier, :report_last_commit => extra_report_last_commit)
|
||||
load_entries_changesets(entries)
|
||||
entries
|
||||
scm.entries(path,
|
||||
identifier,
|
||||
options = {:report_last_commit => extra_report_last_commit})
|
||||
end
|
||||
|
||||
# With SCMs that have a sequential commit numbering,
|
||||
@@ -255,15 +255,4 @@ class Repository::Git < Repository
|
||||
:order => 'committed_on DESC'
|
||||
)
|
||||
end
|
||||
|
||||
def clear_extra_info_of_changesets
|
||||
return if extra_info.nil?
|
||||
v = extra_info["extra_report_last_commit"]
|
||||
write_attribute(:extra_info, nil)
|
||||
h = {}
|
||||
h["extra_report_last_commit"] = v
|
||||
merge_extra_info(h)
|
||||
self.save
|
||||
end
|
||||
private :clear_extra_info_of_changesets
|
||||
end
|
||||
|
||||
@@ -76,12 +76,12 @@ class Repository::Mercurial < Repository
|
||||
return nil if name.blank?
|
||||
s = name.to_s
|
||||
if /[^\d]/ =~ s or s.size > 8
|
||||
cs = changesets.where(:scmid => s).first
|
||||
e = changesets.find(:first, :conditions => ['scmid = ?', s])
|
||||
else
|
||||
cs = changesets.where(:revision => s).first
|
||||
e = changesets.find(:first, :conditions => ['revision = ?', s])
|
||||
end
|
||||
return cs if cs
|
||||
changesets.where('scmid LIKE ?', "#{s}%").first
|
||||
return e if e
|
||||
changesets.find(:first, :conditions => ['scmid LIKE ?', "#{s}%"]) # last ditch
|
||||
end
|
||||
|
||||
# Returns the latest changesets for +path+; sorted by revision number
|
||||
|
||||
@@ -40,12 +40,7 @@ class Repository::Subversion < Repository
|
||||
|
||||
def latest_changesets(path, rev, limit=10)
|
||||
revisions = scm.revisions(path, rev, nil, :limit => limit)
|
||||
if revisions
|
||||
identifiers = revisions.collect(&:identifier).compact
|
||||
changesets.where(:revision => identifiers).reorder("committed_on DESC").includes(:repository, :user).all
|
||||
else
|
||||
[]
|
||||
end
|
||||
revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC", :include => :user) : []
|
||||
end
|
||||
|
||||
# Returns a path relative to the url of the repository
|
||||
@@ -86,24 +81,6 @@ class Repository::Subversion < Repository
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def load_entries_changesets(entries)
|
||||
return unless entries
|
||||
|
||||
entries_with_identifier = entries.select {|entry| entry.lastrev && entry.lastrev.identifier.present?}
|
||||
identifiers = entries_with_identifier.map {|entry| entry.lastrev.identifier}.compact.uniq
|
||||
|
||||
if identifiers.any?
|
||||
changesets_by_identifier = changesets.where(:revision => identifiers).includes(:user, :repository).all.group_by(&:revision)
|
||||
entries_with_identifier.each do |entry|
|
||||
if m = changesets_by_identifier[entry.lastrev.identifier]
|
||||
entry.changeset = m.first
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Returns the relative url of the repository
|
||||
|
||||
@@ -16,19 +16,6 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class Role < ActiveRecord::Base
|
||||
# Custom coder for the permissions attribute that should be an
|
||||
# array of symbols. Rails 3 uses Psych which can be *unbelievably*
|
||||
# slow on some platforms (eg. mingw32).
|
||||
class PermissionsAttributeCoder
|
||||
def self.load(str)
|
||||
str.to_s.scan(/:([a-z0-9_]+)/).flatten.map(&:to_sym)
|
||||
end
|
||||
|
||||
def self.dump(value)
|
||||
YAML.dump(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Built-in roles
|
||||
BUILTIN_NON_MEMBER = 1
|
||||
BUILTIN_ANONYMOUS = 2
|
||||
@@ -39,17 +26,17 @@ class Role < ActiveRecord::Base
|
||||
['own', :label_issues_visibility_own]
|
||||
]
|
||||
|
||||
scope :sorted, order("#{table_name}.builtin ASC, #{table_name}.position ASC")
|
||||
scope :givable, order("#{table_name}.position ASC").where(:builtin => 0)
|
||||
scope :sorted, {:order => 'builtin, position'}
|
||||
scope :givable, { :conditions => "builtin = 0", :order => 'position' }
|
||||
scope :builtin, lambda { |*args|
|
||||
compare = (args.first == true ? 'not' : '')
|
||||
where("#{compare} builtin = 0")
|
||||
compare = 'not' if args.first == true
|
||||
{ :conditions => "#{compare} builtin = 0" }
|
||||
}
|
||||
|
||||
before_destroy :check_deletable
|
||||
has_many :workflow_rules, :dependent => :delete_all do
|
||||
has_many :workflows, :dependent => :delete_all do
|
||||
def copy(source_role)
|
||||
WorkflowRule.copy(nil, source_role, nil, proxy_association.owner)
|
||||
Workflow.copy(nil, source_role, nil, proxy_association.owner)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,7 +44,7 @@ class Role < ActiveRecord::Base
|
||||
has_many :members, :through => :member_roles
|
||||
acts_as_list
|
||||
|
||||
serialize :permissions, ::Role::PermissionsAttributeCoder
|
||||
serialize :permissions, Array
|
||||
attr_protected :builtin
|
||||
|
||||
validates_presence_of :name
|
||||
@@ -67,13 +54,8 @@ class Role < ActiveRecord::Base
|
||||
:in => ISSUES_VISIBILITY_OPTIONS.collect(&:first),
|
||||
:if => lambda {|role| role.respond_to?(:issues_visibility)}
|
||||
|
||||
# Copies attributes from another role, arg can be an id or a Role
|
||||
def copy_from(arg, options={})
|
||||
return unless arg.present?
|
||||
role = arg.is_a?(Role) ? arg : Role.find_by_id(arg.to_s)
|
||||
self.attributes = role.attributes.dup.except("id", "name", "position", "builtin", "permissions")
|
||||
self.permissions = role.permissions.dup
|
||||
self
|
||||
def permissions
|
||||
read_attribute(:permissions) || []
|
||||
end
|
||||
|
||||
def permissions=(perms)
|
||||
@@ -105,15 +87,7 @@ class Role < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def <=>(role)
|
||||
if role
|
||||
if builtin == role.builtin
|
||||
position <=> role.position
|
||||
else
|
||||
builtin <=> role.builtin
|
||||
end
|
||||
else
|
||||
-1
|
||||
end
|
||||
role ? position <=> role.position : -1
|
||||
end
|
||||
|
||||
def to_s
|
||||
@@ -133,11 +107,6 @@ class Role < ActiveRecord::Base
|
||||
self.builtin != 0
|
||||
end
|
||||
|
||||
# Return true if the role is the anonymous role
|
||||
def anonymous?
|
||||
builtin == 2
|
||||
end
|
||||
|
||||
# Return true if the role is a project member role
|
||||
def member?
|
||||
!self.builtin?
|
||||
@@ -165,7 +134,7 @@ class Role < ActiveRecord::Base
|
||||
|
||||
# Find all the roles that can be given to a project member
|
||||
def self.find_all_givable
|
||||
Role.givable.all
|
||||
find(:all, :conditions => {:builtin => 0}, :order => 'position')
|
||||
end
|
||||
|
||||
# Return the builtin 'non member' role. If the role doesn't exist,
|
||||
@@ -196,7 +165,7 @@ private
|
||||
end
|
||||
|
||||
def self.find_or_create_system_role(builtin, name)
|
||||
role = where(:builtin => builtin).first
|
||||
role = first(:conditions => {:builtin => builtin})
|
||||
if role.nil?
|
||||
role = create(:name => name, :position => 0) do |r|
|
||||
r.builtin = builtin
|
||||
|
||||
@@ -16,18 +16,11 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class Tracker < ActiveRecord::Base
|
||||
|
||||
CORE_FIELDS_UNDISABLABLE = %w(project_id tracker_id subject description priority_id is_private).freeze
|
||||
# Fields that can be disabled
|
||||
# Other (future) fields should be appended, not inserted!
|
||||
CORE_FIELDS = %w(assigned_to_id category_id fixed_version_id parent_issue_id start_date due_date estimated_hours done_ratio).freeze
|
||||
CORE_FIELDS_ALL = (CORE_FIELDS_UNDISABLABLE + CORE_FIELDS).freeze
|
||||
|
||||
before_destroy :check_integrity
|
||||
has_many :issues
|
||||
has_many :workflow_rules, :dependent => :delete_all do
|
||||
has_many :workflows, :dependent => :delete_all do
|
||||
def copy(source_tracker)
|
||||
WorkflowRule.copy(source_tracker, nil, proxy_association.owner, nil)
|
||||
Workflow.copy(source_tracker, nil, proxy_association.owner, nil)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,14 +28,11 @@ class Tracker < ActiveRecord::Base
|
||||
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
|
||||
acts_as_list
|
||||
|
||||
attr_protected :field_bits
|
||||
|
||||
validates_presence_of :name
|
||||
validates_uniqueness_of :name
|
||||
validates_length_of :name, :maximum => 30
|
||||
|
||||
scope :sorted, order("#{table_name}.position ASC")
|
||||
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
|
||||
scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
||||
|
||||
def to_s; name end
|
||||
|
||||
@@ -50,6 +40,10 @@ class Tracker < ActiveRecord::Base
|
||||
position <=> tracker.position
|
||||
end
|
||||
|
||||
def self.all
|
||||
find(:all, :order => 'position')
|
||||
end
|
||||
|
||||
# Returns an array of IssueStatus that are used
|
||||
# in the tracker's workflows
|
||||
def issue_statuses
|
||||
@@ -59,57 +53,16 @@ class Tracker < ActiveRecord::Base
|
||||
return []
|
||||
end
|
||||
|
||||
ids = WorkflowTransition.
|
||||
connection.select_rows("SELECT DISTINCT old_status_id, new_status_id FROM #{WorkflowTransition.table_name} WHERE tracker_id = #{id} AND type = 'WorkflowTransition'").
|
||||
ids = Workflow.
|
||||
connection.select_rows("SELECT DISTINCT old_status_id, new_status_id FROM #{Workflow.table_name} WHERE tracker_id = #{id}").
|
||||
flatten.
|
||||
uniq
|
||||
|
||||
@issue_statuses = IssueStatus.find_all_by_id(ids).sort
|
||||
end
|
||||
|
||||
def disabled_core_fields
|
||||
i = -1
|
||||
@disabled_core_fields ||= CORE_FIELDS.select { i += 1; (fields_bits || 0) & (2 ** i) != 0}
|
||||
end
|
||||
|
||||
def core_fields
|
||||
CORE_FIELDS - disabled_core_fields
|
||||
end
|
||||
|
||||
def core_fields=(fields)
|
||||
raise ArgumentError.new("Tracker.core_fields takes an array") unless fields.is_a?(Array)
|
||||
|
||||
bits = 0
|
||||
CORE_FIELDS.each_with_index do |field, i|
|
||||
unless fields.include?(field)
|
||||
bits |= 2 ** i
|
||||
end
|
||||
end
|
||||
self.fields_bits = bits
|
||||
@disabled_core_fields = nil
|
||||
core_fields
|
||||
end
|
||||
|
||||
# Returns the fields that are disabled for all the given trackers
|
||||
def self.disabled_core_fields(trackers)
|
||||
if trackers.present?
|
||||
trackers.uniq.map(&:disabled_core_fields).reduce(:&)
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the fields that are enabled for one tracker at least
|
||||
def self.core_fields(trackers)
|
||||
if trackers.present?
|
||||
trackers.uniq.map(&:core_fields).reduce(:|)
|
||||
else
|
||||
CORE_FIELDS.dup
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_integrity
|
||||
raise Exception.new("Can't delete tracker") if Issue.where(:tracker_id => self.id).any?
|
||||
raise "Can't delete tracker" if Issue.find(:first, :conditions => ["tracker_id=?", self.id])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,6 +52,8 @@ class User < Principal
|
||||
has_one :api_token, :class_name => 'Token', :conditions => "action='api'"
|
||||
belongs_to :auth_source
|
||||
|
||||
# Active non-anonymous users scope
|
||||
scope :active, :conditions => "#{User.table_name}.status = #{STATUS_ACTIVE}"
|
||||
scope :logged, :conditions => "#{User.table_name}.status <> #{STATUS_ANONYMOUS}"
|
||||
scope :status, lambda {|arg| arg.blank? ? {} : {:conditions => {:status => arg.to_i}} }
|
||||
|
||||
@@ -392,7 +394,7 @@ class User < Principal
|
||||
def roles_for_project(project)
|
||||
roles = []
|
||||
# No role on archived projects
|
||||
return roles if project.nil? || project.archived?
|
||||
return roles unless project && project.active?
|
||||
if logged?
|
||||
# Find project membership
|
||||
membership = memberships.detect {|m| m.project_id == project.id}
|
||||
@@ -418,13 +420,10 @@ class User < Principal
|
||||
def projects_by_role
|
||||
return @projects_by_role if @projects_by_role
|
||||
|
||||
@projects_by_role = Hash.new([])
|
||||
@projects_by_role = Hash.new {|h,k| h[k]=[]}
|
||||
memberships.each do |membership|
|
||||
if membership.project
|
||||
membership.roles.each do |role|
|
||||
@projects_by_role[role] = [] unless @projects_by_role.key?(role)
|
||||
@projects_by_role[role] << membership.project
|
||||
end
|
||||
membership.roles.each do |role|
|
||||
@projects_by_role[role] << membership.project if membership.project
|
||||
end
|
||||
end
|
||||
@projects_by_role.each do |role, projects|
|
||||
@@ -456,6 +455,9 @@ class User < Principal
|
||||
# or falls back to Non Member / Anonymous permissions depending if the user is logged
|
||||
def allowed_to?(action, context, options={}, &block)
|
||||
if context && context.is_a?(Project)
|
||||
# No action allowed on archived projects
|
||||
return false unless context.active?
|
||||
# No action allowed on disabled modules
|
||||
return false unless context.allows_to?(action)
|
||||
# Admin users are authorized for anything else
|
||||
return true if admin?
|
||||
@@ -660,10 +662,6 @@ class AnonymousUser < User
|
||||
def time_zone; nil end
|
||||
def rss_key; nil end
|
||||
|
||||
def pref
|
||||
UserPreference.new(:user => self)
|
||||
end
|
||||
|
||||
# Anonymous user can not be destroyed
|
||||
def destroy
|
||||
false
|
||||
|
||||
@@ -44,7 +44,7 @@ class UserPreference < ActiveRecord::Base
|
||||
if attribute_present? attr_name
|
||||
super
|
||||
else
|
||||
h = (read_attribute(:others) || {}).dup
|
||||
h = read_attribute(:others).dup || {}
|
||||
h.update(attr_name => value)
|
||||
write_attribute(:others, h)
|
||||
value
|
||||
|
||||
@@ -33,7 +33,6 @@ class Version < ActiveRecord::Base
|
||||
validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :not_a_date, :allow_nil => true
|
||||
validates_inclusion_of :status, :in => VERSION_STATUSES
|
||||
validates_inclusion_of :sharing, :in => VERSION_SHARINGS
|
||||
validate :validate_version
|
||||
|
||||
scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
||||
scope :open, :conditions => {:status => 'open'}
|
||||
@@ -163,13 +162,13 @@ class Version < ActiveRecord::Base
|
||||
"#{project} - #{name}"
|
||||
end
|
||||
|
||||
# Versions are sorted by effective_date and name
|
||||
# Those with no effective_date are at the end, sorted by name
|
||||
# Versions are sorted by effective_date and "Project Name - Version name"
|
||||
# Those with no effective_date are at the end, sorted by "Project Name - Version name"
|
||||
def <=>(version)
|
||||
if self.effective_date
|
||||
if version.effective_date
|
||||
if self.effective_date == version.effective_date
|
||||
name == version.name ? id <=> version.id : name <=> version.name
|
||||
"#{self.project.name} - #{self.name}" <=> "#{version.project.name} - #{version.name}"
|
||||
else
|
||||
self.effective_date <=> version.effective_date
|
||||
end
|
||||
@@ -180,18 +179,11 @@ class Version < ActiveRecord::Base
|
||||
if version.effective_date
|
||||
1
|
||||
else
|
||||
name == version.name ? id <=> version.id : name <=> version.name
|
||||
"#{self.project.name} - #{self.name}" <=> "#{version.project.name} - #{version.name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.fields_for_order_statement(table=nil)
|
||||
table ||= table_name
|
||||
["(CASE WHEN #{table}.effective_date IS NULL THEN 1 ELSE 0 END)", "#{table}.effective_date", "#{table}.name", "#{table}.id"]
|
||||
end
|
||||
|
||||
scope :sorted, order(fields_for_order_statement)
|
||||
|
||||
# Returns the sharings that +user+ can set the version to
|
||||
def allowed_sharings(user = User.current)
|
||||
VERSION_SHARINGS.select do |s|
|
||||
@@ -276,10 +268,4 @@ class Version < ActiveRecord::Base
|
||||
progress
|
||||
end
|
||||
end
|
||||
|
||||
def validate_version
|
||||
if effective_date.nil? && @attributes['effective_date'].present?
|
||||
errors.add :effective_date, :not_a_date
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,15 +15,31 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class WorkflowRule < ActiveRecord::Base
|
||||
self.table_name = "#{table_name_prefix}workflows#{table_name_suffix}"
|
||||
|
||||
class Workflow < ActiveRecord::Base
|
||||
belongs_to :role
|
||||
belongs_to :tracker
|
||||
belongs_to :old_status, :class_name => 'IssueStatus', :foreign_key => 'old_status_id'
|
||||
belongs_to :new_status, :class_name => 'IssueStatus', :foreign_key => 'new_status_id'
|
||||
|
||||
validates_presence_of :role, :tracker, :old_status
|
||||
validates_presence_of :role, :old_status, :new_status
|
||||
|
||||
# Returns workflow transitions count by tracker and role
|
||||
def self.count_by_tracker_and_role
|
||||
counts = connection.select_all("SELECT role_id, tracker_id, count(id) AS c FROM #{Workflow.table_name} GROUP BY role_id, tracker_id")
|
||||
roles = Role.find(:all, :order => 'builtin, position')
|
||||
trackers = Tracker.find(:all, :order => 'position')
|
||||
|
||||
result = []
|
||||
trackers.each do |tracker|
|
||||
t = []
|
||||
roles.each do |role|
|
||||
row = counts.detect {|c| c['role_id'].to_s == role.id.to_s && c['tracker_id'].to_s == tracker.id.to_s}
|
||||
t << [role, (row.nil? ? 0 : row['c'].to_i)]
|
||||
end
|
||||
result << [tracker, t]
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
# Copies workflows from source to targets
|
||||
def self.copy(source_tracker, source_role, target_trackers, target_roles)
|
||||
@@ -34,7 +50,7 @@ class WorkflowRule < ActiveRecord::Base
|
||||
target_trackers = [target_trackers].flatten.compact
|
||||
target_roles = [target_roles].flatten.compact
|
||||
|
||||
target_trackers = Tracker.sorted.all if target_trackers.empty?
|
||||
target_trackers = Tracker.all if target_trackers.empty?
|
||||
target_roles = Role.all if target_roles.empty?
|
||||
|
||||
target_trackers.each do |target_tracker|
|
||||
@@ -62,9 +78,9 @@ class WorkflowRule < ActiveRecord::Base
|
||||
else
|
||||
transaction do
|
||||
delete_all :tracker_id => target_tracker.id, :role_id => target_role.id
|
||||
connection.insert "INSERT INTO #{WorkflowRule.table_name} (tracker_id, role_id, old_status_id, new_status_id, author, assignee, field_name, rule, type)" +
|
||||
" SELECT #{target_tracker.id}, #{target_role.id}, old_status_id, new_status_id, author, assignee, field_name, rule, type" +
|
||||
" FROM #{WorkflowRule.table_name}" +
|
||||
connection.insert "INSERT INTO #{Workflow.table_name} (tracker_id, role_id, old_status_id, new_status_id, author, assignee)" +
|
||||
" SELECT #{target_tracker.id}, #{target_role.id}, old_status_id, new_status_id, author, assignee" +
|
||||
" FROM #{Workflow.table_name}" +
|
||||
" WHERE tracker_id = #{source_tracker.id} AND role_id = #{source_role.id}"
|
||||
end
|
||||
true
|
||||
@@ -1,45 +0,0 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2012 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class WorkflowPermission < WorkflowRule
|
||||
validates_inclusion_of :rule, :in => %w(readonly required)
|
||||
validate :validate_field_name
|
||||
|
||||
# Replaces the workflow permissions for the given tracker and role
|
||||
#
|
||||
# Example:
|
||||
# WorkflowPermission.replace_permissions role, tracker, {'due_date' => {'1' => 'readonly', '2' => 'required'}}
|
||||
def self.replace_permissions(tracker, role, permissions)
|
||||
destroy_all(:tracker_id => tracker.id, :role_id => role.id)
|
||||
|
||||
permissions.each { |field, rule_by_status_id|
|
||||
rule_by_status_id.each { |status_id, rule|
|
||||
if rule.present?
|
||||
WorkflowPermission.create(:role_id => role.id, :tracker_id => tracker.id, :old_status_id => status_id, :field_name => field, :rule => rule)
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def validate_field_name
|
||||
unless Tracker::CORE_FIELDS_ALL.include?(field_name) || field_name.to_s.match(/^\d+$/)
|
||||
errors.add :field_name, :invalid
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,39 +0,0 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2012 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
class WorkflowTransition < WorkflowRule
|
||||
validates_presence_of :new_status
|
||||
|
||||
# Returns workflow transitions count by tracker and role
|
||||
def self.count_by_tracker_and_role
|
||||
counts = connection.select_all("SELECT role_id, tracker_id, count(id) AS c FROM #{table_name} WHERE type = 'WorkflowTransition' GROUP BY role_id, tracker_id")
|
||||
roles = Role.sorted.all
|
||||
trackers = Tracker.sorted.all
|
||||
|
||||
result = []
|
||||
trackers.each do |tracker|
|
||||
t = []
|
||||
roles.each do |role|
|
||||
row = counts.detect {|c| c['role_id'].to_s == role.id.to_s && c['tracker_id'].to_s == tracker.id.to_s}
|
||||
t << [role, (row.nil? ? 0 : row['c'].to_i)]
|
||||
end
|
||||
result << [tracker, t]
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
<%= call_hook :view_account_login_top %>
|
||||
<div id="login-form">
|
||||
<%= form_tag(signin_path) do %>
|
||||
<%= form_tag({:action=> "login"}) do %>
|
||||
<%= back_url_hidden_field_tag %>
|
||||
<table>
|
||||
<tr>
|
||||
@@ -28,7 +28,7 @@
|
||||
<tr>
|
||||
<td align="left">
|
||||
<% if Setting.lost_password? %>
|
||||
<%= link_to l(:label_password_lost), lost_password_path %>
|
||||
<%= link_to l(:label_password_lost), :controller => 'account', :action => 'lost_password' %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td align="right">
|
||||
@@ -36,7 +36,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<%= javascript_tag "$('#username').focus();" %>
|
||||
<%= javascript_tag "Form.Element.focus('username');" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= call_hook :view_account_login_bottom %>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<h2><%=l(:label_password_lost)%></h2>
|
||||
|
||||
<%= form_tag(lost_password_path) do %>
|
||||
<div class="box tabular">
|
||||
<p>
|
||||
<label for="mail"><%=l(:field_mail)%> <span class="required">*</span></label>
|
||||
<%= text_field_tag 'mail', nil, :size => 40 %>
|
||||
<%= submit_tag l(:button_submit) %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="box">
|
||||
<%= form_tag({:action=> "lost_password"}, :class => "tabular") do %>
|
||||
|
||||
<p><label for="mail"><%=l(:field_mail)%> <span class="required">*</span></label>
|
||||
<%= text_field_tag 'mail', nil, :size => 40 %>
|
||||
<%= submit_tag l(:button_submit) %></p>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -2,19 +2,14 @@
|
||||
|
||||
<%= error_messages_for 'user' %>
|
||||
|
||||
<%= form_tag(lost_password_path) do %>
|
||||
<%= hidden_field_tag 'token', @token.value %>
|
||||
<div class="box tabular">
|
||||
<p>
|
||||
<label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'new_password', nil, :size => 25 %>
|
||||
<em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em>
|
||||
</p>
|
||||
<%= form_tag({:token => @token.value}) do %>
|
||||
<div class="box tabular">
|
||||
<p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'new_password', nil, :size => 25 %>
|
||||
<em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
|
||||
|
||||
<p>
|
||||
<label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %>
|
||||
</p>
|
||||
</div>
|
||||
<p><%= submit_tag l(:button_save) %></p>
|
||||
<p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
|
||||
</div>
|
||||
<p><%= submit_tag l(:button_save) %></p>
|
||||
<% end %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<h2><%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></h2>
|
||||
|
||||
<%= labelled_form_for @user, :url => register_path do |f| %>
|
||||
<%= labelled_form_for @user, :url => {:action => 'register'} do |f| %>
|
||||
<%= error_messages_for 'user' %>
|
||||
|
||||
<div class="box tabular">
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<div id="admin-menu">
|
||||
<%= render_menu :admin_menu %>
|
||||
<ul>
|
||||
<%= render_menu :admin_menu %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
<tbody>
|
||||
<% project_tree(@projects) do |project, level| %>
|
||||
<tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
|
||||
<td class="name"><span><%= link_to_project(project, {:action => (project.active? ? 'settings' : 'show')}, :title => project.short_description) %></span></td>
|
||||
<td class="name"><span><%= link_to_project(project, {:action => 'settings'}, :title => project.short_description) %></span></td>
|
||||
<td align="center"><%= checked_image project.is_public? %></td>
|
||||
<td align="center"><%= format_date(project.created_on) %></td>
|
||||
<td class="buttons">
|
||||
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
|
||||
<%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %>
|
||||
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-lock') if project.active? %>
|
||||
<%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if !project.active? && (project.parent.nil? || project.parent.active?) %>
|
||||
<%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
|
||||
<%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %>
|
||||
</td>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<% end %>
|
||||
<span id="attachments_fields">
|
||||
<span>
|
||||
<%= file_field_tag 'attachments[1][file]', :id => nil, :class => 'file',
|
||||
<%= file_field_tag 'attachments[1][file]', :size => 30, :id => nil, :class => 'file',
|
||||
:onchange => "checkFileSize(this, #{Setting.attachment_max_size.to_i.kilobytes}, '#{escape_javascript(l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)))}');" -%>
|
||||
<%= text_field_tag 'attachments[1][description]', '', :id => nil, :class => 'description', :maxlength => 255, :placeholder => l(:label_optional_description) %>
|
||||
<%= link_to_function(image_tag('delete.png'), 'removeFileField(this)', :title => (l(:button_delete))) %>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||
<% if options[:deletable] %>
|
||||
<%= link_to image_tag('delete.png'), attachment_path(attachment),
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:confirm => l(:text_are_you_sure),
|
||||
:method => :delete,
|
||||
:class => 'delete',
|
||||
:title => l(:button_delete) %>
|
||||
@@ -20,14 +20,4 @@
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% if defined?(thumbnails) && thumbnails %>
|
||||
<% images = attachments.select(&:thumbnailable?) %>
|
||||
<% if images.any? %>
|
||||
<div class="thumbnails">
|
||||
<% images.each do |attachment| %>
|
||||
<div><%= thumbnail_tag(attachment) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -23,12 +23,9 @@
|
||||
<p><label for="auth_source_base_dn"><%=l(:field_base_dn)%> <span class="required">*</span></label>
|
||||
<%= text_field 'auth_source', 'base_dn', :size => 60 %></p>
|
||||
|
||||
<p><label for="auth_source_custom_filter"><%=l(:field_auth_source_ldap_filter)%></label>
|
||||
<p><label for="auth_source_custom_filter"><%=l(:field_ldap_filter)%></label>
|
||||
<%= text_field 'auth_source', 'filter', :size => 60 %></p>
|
||||
|
||||
<p><label for="auth_source_timeout"><%=l(:field_timeout)%></label>
|
||||
<%= text_field 'auth_source', 'timeout', :size => 4 %></p>
|
||||
|
||||
<p><label for="auth_source_onthefly_register"><%=l(:field_onthefly)%></label>
|
||||
<%= check_box 'auth_source', 'onthefly_register' %></p>
|
||||
</div>
|
||||
|
||||
@@ -21,7 +21,11 @@
|
||||
<td align="center"><%= h source.users.count %></td>
|
||||
<td class="buttons">
|
||||
<%= link_to l(:button_test), {:action => 'test_connection', :id => source}, :class => 'icon icon-test' %>
|
||||
<%= delete_link auth_source_path(source) %>
|
||||
<%= link_to l(:button_delete), { :action => 'destroy', :id => source },
|
||||
:method => :delete,
|
||||
:confirm => l(:text_are_you_sure),
|
||||
:class => 'icon icon-del',
|
||||
:disabled => source.users.any? %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<%= raw @issues.map {|issue| {
|
||||
'id' => issue.id,
|
||||
'label' => "#{issue.tracker} ##{issue.id}: #{truncate issue.subject.to_s, :length => 60}",
|
||||
'value' => issue.id
|
||||
}
|
||||
}.to_json
|
||||
%>
|
||||
<ul>
|
||||
<% if @issues.any? -%>
|
||||
<% @issues.each do |issue| -%>
|
||||
<%= content_tag 'li', h("#{issue.tracker} ##{issue.id}: #{issue.subject}"), :id => issue.id %>
|
||||
<% end -%>
|
||||
<% else -%>
|
||||
<%= content_tag("li", l(:label_none), :style => 'display:none') %>
|
||||
<% end -%>
|
||||
</ul>
|
||||
|
||||
@@ -3,7 +3,4 @@
|
||||
<div class="box tabular">
|
||||
<p><%= f.text_field :name, :required => true %></p>
|
||||
<p><%= f.text_field :description, :required => true, :size => 80 %></p>
|
||||
<% if @board.valid_parents.any? %>
|
||||
<p><%= f.select :parent_id, boards_options_for_select(@board.valid_parents), :include_blank => true, :label => :field_board_parent %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -8,19 +8,21 @@
|
||||
<th><%= l(:label_message_last) %></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% Board.board_tree(@boards) do |board, level| %>
|
||||
<% for board in @boards %>
|
||||
<tr class="<%= cycle 'odd', 'even' %>">
|
||||
<td style="padding-left: <%= level * 18 %>px;">
|
||||
<td>
|
||||
<%= link_to h(board.name), {:action => 'show', :id => board}, :class => "board" %><br />
|
||||
<%=h board.description %>
|
||||
</td>
|
||||
<td class="topic-count"><%= board.topics_count %></td>
|
||||
<td class="message-count"><%= board.messages_count %></td>
|
||||
<td class="last-message">
|
||||
<td align="center"><%= board.topics_count %></td>
|
||||
<td align="center"><%= board.messages_count %></td>
|
||||
<td>
|
||||
<small>
|
||||
<% if board.last_message %>
|
||||
<%= authoring board.last_message.created_on, board.last_message.author %><br />
|
||||
<%= link_to_message board.last_message %>
|
||||
<% end %>
|
||||
</small>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<%= board_breadcrumb(@board) %>
|
||||
<%= breadcrumb link_to(l(:label_board_plural), project_boards_path(@project)) %>
|
||||
|
||||
<div class="contextual">
|
||||
<%= link_to_if_authorized l(:label_message_new),
|
||||
{:controller => 'messages', :action => 'new', :board_id => @board},
|
||||
:class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' %>
|
||||
:onclick => 'Element.show("add-message"); Form.Element.focus("message_subject"); return false;' %>
|
||||
<%= watcher_tag(@board, User.current) %>
|
||||
</div>
|
||||
|
||||
@@ -14,8 +14,14 @@
|
||||
<%= form_for @message, :url => {:controller => 'messages', :action => 'new', :board_id => @board}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
<%= render :partial => 'messages/form', :locals => {:f => f} %>
|
||||
<p><%= submit_tag l(:button_create) %>
|
||||
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %> |
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' %></p>
|
||||
<%= link_to_remote l(:label_preview),
|
||||
{ :url => { :controller => 'messages', :action => 'preview', :board_id => @board },
|
||||
:method => 'post',
|
||||
:update => 'preview',
|
||||
:with => "Form.serialize('message-form')",
|
||||
:complete => "Element.scrollTo('preview')"
|
||||
}, :accesskey => accesskey(:preview) %> |
|
||||
<%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-message")' %></p>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
<% end %>
|
||||
@@ -37,9 +43,9 @@
|
||||
<% @topics.each do |topic| %>
|
||||
<tr class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>">
|
||||
<td class="subject"><%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => @board, :id => topic } %></td>
|
||||
<td class="author"><%= link_to_user(topic.author) %></td>
|
||||
<td class="created_on"><%= format_time(topic.created_on) %></td>
|
||||
<td class="reply-count"><%= topic.replies_count %></td>
|
||||
<td class="author" align="center"><%= link_to_user(topic.author) %></td>
|
||||
<td class="created_on" align="center"><%= format_time(topic.created_on) %></td>
|
||||
<td class="replies" align="center"><%= topic.replies_count %></td>
|
||||
<td class="last_message">
|
||||
<% if topic.last_reply %>
|
||||
<%= authoring topic.last_reply.created_on, topic.last_reply.author %><br />
|
||||
@@ -63,4 +69,5 @@
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %>
|
||||
<%= stylesheet_link_tag 'scm' %>
|
||||
<% end %>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<%= label_tag('year', l(:label_year)) %>
|
||||
<%= select_year(@year, :prefix => "year", :discard_type => true) %>
|
||||
|
||||
<%= link_to_function l(:button_apply), '$("#query_form").submit()', :class => 'icon icon-checked' %>
|
||||
<%= link_to_function l(:button_apply), '$("query_form").submit()', :class => 'icon icon-checked' %>
|
||||
<%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, :class => 'icon icon-reload' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(displayTabsButtons);
|
||||
$(window).resize(displayTabsButtons);
|
||||
Event.observe(window, 'load', function() { displayTabsButtons(); });
|
||||
Event.observe(window, 'resize', function() { displayTabsButtons(); });
|
||||
</script>
|
||||
|
||||
<% tabs.each do |tab| -%>
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
<% if @message.present? %>
|
||||
<p id="errorExplanation"><%=h @message %></p>
|
||||
<% end %>
|
||||
<p><a href="javascript:history.back()"><%= l(:button_back) %></a></p>
|
||||
<p><a href="javascript:history.back()">Back</a></p>
|
||||
|
||||
<% html_title @status %>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<li><%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue},
|
||||
:class => 'icon-edit', :disabled => !@can[:edit] %></li>
|
||||
<% else %>
|
||||
<li><%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'bulk_edit', :ids => @issue_ids},
|
||||
<li><%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id)},
|
||||
:class => 'icon-edit', :disabled => !@can[:edit] %></li>
|
||||
<% end %>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<a href="#" class="submenu"><%= l(:field_status) %></a>
|
||||
<ul>
|
||||
<% @allowed_statuses.each do |s| -%>
|
||||
<li><%= context_menu_link h(s.name), {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {:status_id => s}, :back_url => @back}, :method => :post,
|
||||
<li><%= context_menu_link h(s.name), {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {:status_id => s}, :back_url => @back}, :method => :post,
|
||||
:selected => (@issue && s == @issue.status), :disabled => !@can[:update] %></li>
|
||||
<% end -%>
|
||||
</ul>
|
||||
@@ -26,77 +26,74 @@
|
||||
<a href="#" class="submenu"><%= l(:field_tracker) %></a>
|
||||
<ul>
|
||||
<% @trackers.each do |t| -%>
|
||||
<li><%= context_menu_link h(t.name), {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'tracker_id' => t}, :back_url => @back}, :method => :post,
|
||||
<li><%= context_menu_link h(t.name), {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'tracker_id' => t}, :back_url => @back}, :method => :post,
|
||||
:selected => (@issue && t == @issue.tracker), :disabled => !@can[:edit] %></li>
|
||||
<% end -%>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if @safe_attributes.include?('priority_id') -%>
|
||||
<li class="folder">
|
||||
<a href="#" class="submenu"><%= l(:field_priority) %></a>
|
||||
<ul>
|
||||
<% @priorities.each do |p| -%>
|
||||
<li><%= context_menu_link h(p.name), {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'priority_id' => p}, :back_url => @back}, :method => :post,
|
||||
<li><%= context_menu_link h(p.name), {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'priority_id' => p}, :back_url => @back}, :method => :post,
|
||||
:selected => (@issue && p == @issue.priority), :disabled => (!@can[:edit] || @issues.detect {|i| !i.leaf?}) %></li>
|
||||
<% end -%>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if @safe_attributes.include?('fixed_version_id') && @versions.any? -%>
|
||||
<% #TODO: allow editing versions when multiple projects %>
|
||||
<% unless @project.nil? || @project.shared_versions.open.empty? -%>
|
||||
<li class="folder">
|
||||
<a href="#" class="submenu"><%= l(:field_fixed_version) %></a>
|
||||
<ul>
|
||||
<% @versions.sort.each do |v| -%>
|
||||
<li><%= context_menu_link format_version_name(v), {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'fixed_version_id' => v}, :back_url => @back}, :method => :post,
|
||||
<% @project.shared_versions.open.sort.each do |v| -%>
|
||||
<li><%= context_menu_link format_version_name(v), {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'fixed_version_id' => v}, :back_url => @back}, :method => :post,
|
||||
:selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:update] %></li>
|
||||
<% end -%>
|
||||
<li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'fixed_version_id' => 'none'}, :back_url => @back}, :method => :post,
|
||||
<li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'fixed_version_id' => 'none'}, :back_url => @back}, :method => :post,
|
||||
:selected => (@issue && @issue.fixed_version.nil?), :disabled => !@can[:update] %></li>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if @safe_attributes.include?('assigned_to_id') && @assignables.present? -%>
|
||||
<% if @assignables.present? -%>
|
||||
<li class="folder">
|
||||
<a href="#" class="submenu"><%= l(:field_assigned_to) %></a>
|
||||
<ul>
|
||||
<% if @assignables.include?(User.current) %>
|
||||
<li><%= context_menu_link "<< #{l(:label_me)} >>", {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'assigned_to_id' => User.current}, :back_url => @back}, :method => :post,
|
||||
<li><%= context_menu_link "<< #{l(:label_me)} >>", {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'assigned_to_id' => User.current}, :back_url => @back}, :method => :post,
|
||||
:disabled => !@can[:update] %></li>
|
||||
<% end %>
|
||||
<% @assignables.each do |u| -%>
|
||||
<li><%= context_menu_link h(u.name), {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'assigned_to_id' => u}, :back_url => @back}, :method => :post,
|
||||
<li><%= context_menu_link h(u.name), {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'assigned_to_id' => u}, :back_url => @back}, :method => :post,
|
||||
:selected => (@issue && u == @issue.assigned_to), :disabled => !@can[:update] %></li>
|
||||
<% end -%>
|
||||
<li><%= context_menu_link l(:label_nobody), {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'assigned_to_id' => 'none'}, :back_url => @back}, :method => :post,
|
||||
<li><%= context_menu_link l(:label_nobody), {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'assigned_to_id' => 'none'}, :back_url => @back}, :method => :post,
|
||||
:selected => (@issue && @issue.assigned_to.nil?), :disabled => !@can[:update] %></li>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if @safe_attributes.include?('category_id') && @project && @project.issue_categories.any? -%>
|
||||
<% unless @project.nil? || @project.issue_categories.empty? -%>
|
||||
<li class="folder">
|
||||
<a href="#" class="submenu"><%= l(:field_category) %></a>
|
||||
<ul>
|
||||
<% @project.issue_categories.each do |u| -%>
|
||||
<li><%= context_menu_link h(u.name), {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'category_id' => u}, :back_url => @back}, :method => :post,
|
||||
<li><%= context_menu_link h(u.name), {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'category_id' => u}, :back_url => @back}, :method => :post,
|
||||
:selected => (@issue && u == @issue.category), :disabled => !@can[:update] %></li>
|
||||
<% end -%>
|
||||
<li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'category_id' => 'none'}, :back_url => @back}, :method => :post,
|
||||
<li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'category_id' => 'none'}, :back_url => @back}, :method => :post,
|
||||
:selected => (@issue && @issue.category.nil?), :disabled => !@can[:update] %></li>
|
||||
</ul>
|
||||
</li>
|
||||
<% end -%>
|
||||
|
||||
<% if @safe_attributes.include?('done_ratio') && Issue.use_field_for_done_ratio? %>
|
||||
<% if Issue.use_field_for_done_ratio? %>
|
||||
<li class="folder">
|
||||
<a href="#" class="submenu"><%= l(:field_done_ratio) %></a>
|
||||
<ul>
|
||||
<% (0..10).map{|x|x*10}.each do |p| -%>
|
||||
<li><%= context_menu_link "#{p}%", {:controller => 'issues', :action => 'bulk_update', :ids => @issue_ids, :issue => {'done_ratio' => p}, :back_url => @back}, :method => :post,
|
||||
<li><%= context_menu_link "#{p}%", {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'done_ratio' => p}, :back_url => @back}, :method => :post,
|
||||
:selected => (@issue && p == @issue.done_ratio), :disabled => (!@can[:edit] || @issues.detect {|i| !i.leaf?}) %></li>
|
||||
<% end -%>
|
||||
</ul>
|
||||
@@ -131,11 +128,11 @@
|
||||
<li><%= context_menu_link l(:button_copy), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue},
|
||||
:class => 'icon-copy', :disabled => !@can[:copy] %></li>
|
||||
<% else %>
|
||||
<li><%= context_menu_link l(:button_copy), {:controller => 'issues', :action => 'bulk_edit', :ids => @issue_ids, :copy => '1'},
|
||||
<li><%= context_menu_link l(:button_copy), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), :copy => '1'},
|
||||
:class => 'icon-copy', :disabled => !@can[:move] %></li>
|
||||
<% end %>
|
||||
<li><%= context_menu_link l(:button_delete), issues_path(:ids => @issue_ids, :back_url => @back),
|
||||
:method => :delete, :data => {:confirm => issues_destroy_confirmation_message(@issues)}, :class => 'icon-del', :disabled => !@can[:delete] %></li>
|
||||
<li><%= context_menu_link l(:button_delete), issues_path(:ids => @issues.collect(&:id), :back_url => @back),
|
||||
:method => :delete, :confirm => issues_destroy_confirmation_message(@issues), :class => 'icon-del', :disabled => !@can[:delete] %></li>
|
||||
|
||||
<%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
|
||||
</ul>
|
||||
|
||||
@@ -28,6 +28,6 @@
|
||||
<li>
|
||||
<%= context_menu_link l(:button_delete),
|
||||
{:controller => 'timelog', :action => 'destroy', :ids => @time_entries.collect(&:id), :back_url => @back},
|
||||
:method => :delete, :data => {:confirm => l(:text_time_entries_destroy_confirmation)}, :class => 'icon-del', :disabled => !@can[:delete] %>
|
||||
:method => :delete, :confirm => l(:text_time_entries_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1,31 +1,86 @@
|
||||
<%= error_messages_for 'custom_field' %>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function toggle_custom_field_format() {
|
||||
format = $("custom_field_field_format");
|
||||
p_length = $("custom_field_min_length");
|
||||
p_regexp = $("custom_field_regexp");
|
||||
p_values = $("custom_field_possible_values");
|
||||
p_searchable = $("custom_field_searchable");
|
||||
p_default = $("custom_field_default_value");
|
||||
p_multiple = $("custom_field_multiple");
|
||||
|
||||
p_default.setAttribute('type','text');
|
||||
Element.show(p_default.parentNode);
|
||||
|
||||
switch (format.value) {
|
||||
case "list":
|
||||
Element.hide(p_length.parentNode);
|
||||
Element.hide(p_regexp.parentNode);
|
||||
if (p_searchable) Element.show(p_searchable.parentNode);
|
||||
Element.show(p_values.parentNode);
|
||||
Element.show(p_multiple.parentNode);
|
||||
break;
|
||||
case "bool":
|
||||
p_default.setAttribute('type','checkbox');
|
||||
Element.hide(p_length.parentNode);
|
||||
Element.hide(p_regexp.parentNode);
|
||||
if (p_searchable) Element.hide(p_searchable.parentNode);
|
||||
Element.hide(p_values.parentNode);
|
||||
Element.hide(p_multiple.parentNode);
|
||||
break;
|
||||
case "date":
|
||||
Element.hide(p_length.parentNode);
|
||||
Element.hide(p_regexp.parentNode);
|
||||
if (p_searchable) Element.hide(p_searchable.parentNode);
|
||||
Element.hide(p_values.parentNode);
|
||||
Element.hide(p_multiple.parentNode);
|
||||
break;
|
||||
case "float":
|
||||
case "int":
|
||||
Element.show(p_length.parentNode);
|
||||
Element.show(p_regexp.parentNode);
|
||||
if (p_searchable) Element.hide(p_searchable.parentNode);
|
||||
Element.hide(p_values.parentNode);
|
||||
Element.hide(p_multiple.parentNode);
|
||||
break;
|
||||
case "user":
|
||||
case "version":
|
||||
Element.hide(p_length.parentNode);
|
||||
Element.hide(p_regexp.parentNode);
|
||||
if (p_searchable) Element.hide(p_searchable.parentNode);
|
||||
Element.hide(p_values.parentNode);
|
||||
Element.hide(p_default.parentNode);
|
||||
Element.show(p_multiple.parentNode);
|
||||
break;
|
||||
default:
|
||||
Element.show(p_length.parentNode);
|
||||
Element.show(p_regexp.parentNode);
|
||||
if (p_searchable) Element.show(p_searchable.parentNode);
|
||||
Element.hide(p_values.parentNode);
|
||||
Element.hide(p_multiple.parentNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<div class="box tabular">
|
||||
<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>
|
||||
|
||||
<% if @custom_field.format_in? 'list', 'user', 'version' %>
|
||||
<p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :onchange => "toggle_custom_field_format();",
|
||||
:disabled => !@custom_field.new_record? %></p>
|
||||
<p><%= f.check_box :multiple, :disabled => @custom_field.multiple && !@custom_field.new_record? %></p>
|
||||
<% end %>
|
||||
|
||||
<% unless @custom_field.format_in? 'list', 'bool', 'date', 'user', 'version' %>
|
||||
<p><label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
|
||||
<%= f.text_field :min_length, :size => 5, :no_label => true %> -
|
||||
<%= f.text_field :max_length, :size => 5, :no_label => true %><br />(<%=l(:text_min_max_length_info)%>)</p>
|
||||
<p><%= f.text_field :regexp, :size => 50 %><br />(<%=l(:text_regexp_info)%>)</p>
|
||||
<% end %>
|
||||
|
||||
<% if @custom_field.format_in? 'list' %>
|
||||
<p>
|
||||
<%= f.text_area :possible_values, :value => @custom_field.possible_values.to_a.join("\n"), :rows => 15 %>
|
||||
<em class="info"><%= l(:text_custom_field_possible_values_info) %></em>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% unless @custom_field.format_in? 'user', 'version' %>
|
||||
<p><%= @custom_field.field_format == 'bool' ? f.check_box(:default_value) : f.text_field(:default_value) %></p>
|
||||
<% end %>
|
||||
|
||||
<%= call_hook(:view_custom_fields_form_upper_box, :custom_field => @custom_field, :form => f) %>
|
||||
</div>
|
||||
|
||||
@@ -34,7 +89,7 @@
|
||||
when "IssueCustomField" %>
|
||||
|
||||
<fieldset><legend><%=l(:label_tracker_plural)%></legend>
|
||||
<% Tracker.sorted.all.each do |tracker| %>
|
||||
<% Tracker.all.each do |tracker| %>
|
||||
<%= check_box_tag "custom_field[tracker_ids][]",
|
||||
tracker.id,
|
||||
(@custom_field.trackers.include? tracker),
|
||||
@@ -55,21 +110,11 @@ when "IssueCustomField" %>
|
||||
<p><%= f.check_box :is_required %></p>
|
||||
<p><%= f.check_box :visible %></p>
|
||||
<p><%= f.check_box :editable %></p>
|
||||
<p><%= f.check_box :is_filter %></p>
|
||||
|
||||
<% when "ProjectCustomField" %>
|
||||
<p><%= f.check_box :is_required %></p>
|
||||
<p><%= f.check_box :visible %></p>
|
||||
<p><%= f.check_box :searchable %></p>
|
||||
<p><%= f.check_box :is_filter %></p>
|
||||
|
||||
<% when "VersionCustomField" %>
|
||||
<p><%= f.check_box :is_required %></p>
|
||||
<p><%= f.check_box :is_filter %></p>
|
||||
|
||||
<% when "GroupCustomField" %>
|
||||
<p><%= f.check_box :is_required %></p>
|
||||
<p><%= f.check_box :is_filter %></p>
|
||||
|
||||
<% when "TimeEntryCustomField" %>
|
||||
<p><%= f.check_box :is_required %></p>
|
||||
@@ -80,3 +125,4 @@ when "IssueCustomField" %>
|
||||
<% end %>
|
||||
<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
|
||||
</div>
|
||||
<%= javascript_tag "toggle_custom_field_format();" %>
|
||||
|
||||
@@ -22,7 +22,10 @@
|
||||
<% end %>
|
||||
<td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'update', :id => custom_field}, :put) %></td>
|
||||
<td class="buttons">
|
||||
<%= delete_link custom_field_path(custom_field) %>
|
||||
<%= link_to(l(:button_delete), custom_field_path(custom_field),
|
||||
:method => :delete,
|
||||
:confirm => l(:text_are_you_sure),
|
||||
:class => 'icon icon-del') %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end; reset_cycle %>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
» <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.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} do |f| %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user