Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41c2af55cf |
@@ -1,25 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 SysApi < ActionWebService::API::Base
|
||||
api_method :projects,
|
||||
:expects => [],
|
||||
:returns => [[Project]]
|
||||
api_method :repository_created,
|
||||
:expects => [:int, :string],
|
||||
:returns => [:int]
|
||||
end
|
||||
@@ -1,131 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 AccountController < ApplicationController
|
||||
layout 'base'
|
||||
helper :custom_fields
|
||||
include CustomFieldsHelper
|
||||
|
||||
# prevents login action to be filtered by check_if_login_required application scope filter
|
||||
skip_before_filter :check_if_login_required, :only => [:login, :lost_password, :register]
|
||||
before_filter :require_login, :only => :logout
|
||||
|
||||
# Show user's account
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
@custom_values = @user.custom_values.find(:all, :include => :custom_field)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
# Login request and validation
|
||||
def login
|
||||
if request.get?
|
||||
# Logout user
|
||||
self.logged_in_user = nil
|
||||
else
|
||||
# Authenticate user
|
||||
user = User.try_to_login(params[:login], params[:password])
|
||||
if user
|
||||
self.logged_in_user = user
|
||||
redirect_back_or_default :controller => 'my', :action => 'page'
|
||||
else
|
||||
flash.now[:notice] = l(:notice_account_invalid_creditentials)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Log out current user and redirect to welcome page
|
||||
def logout
|
||||
self.logged_in_user = nil
|
||||
redirect_to :controller => 'welcome'
|
||||
end
|
||||
|
||||
# Enable user to choose a new password
|
||||
def lost_password
|
||||
redirect_to :controller => 'welcome' and return unless Setting.lost_password?
|
||||
if params[:token]
|
||||
@token = Token.find_by_action_and_value("recovery", params[:token])
|
||||
redirect_to :controller => 'welcome' and return unless @token and !@token.expired?
|
||||
@user = @token.user
|
||||
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 :action => 'login'
|
||||
return
|
||||
end
|
||||
end
|
||||
render :template => "account/password_recovery"
|
||||
return
|
||||
else
|
||||
if request.post?
|
||||
user = User.find_by_mail(params[:mail])
|
||||
# user not found in db
|
||||
flash.now[:notice] = l(:notice_account_unknown_email) and return unless user
|
||||
# user uses an external authentification
|
||||
flash.now[:notice] = l(:notice_can_t_change_password) and return if user.auth_source_id
|
||||
# create a new token for password recovery
|
||||
token = Token.new(:user => user, :action => "recovery")
|
||||
if token.save
|
||||
Mailer.deliver_lost_password(token)
|
||||
flash[:notice] = l(:notice_account_lost_email_sent)
|
||||
redirect_to :action => 'login'
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# User self-registration
|
||||
def register
|
||||
redirect_to :controller => 'welcome' and return unless Setting.self_registration?
|
||||
if params[:token]
|
||||
token = Token.find_by_action_and_value("register", params[:token])
|
||||
redirect_to :controller => 'welcome' and return unless token and !token.expired?
|
||||
user = token.user
|
||||
redirect_to :controller => 'welcome' and return unless user.status == User::STATUS_REGISTERED
|
||||
user.status = User::STATUS_ACTIVE
|
||||
if user.save
|
||||
token.destroy
|
||||
flash[:notice] = l(:notice_account_activated)
|
||||
redirect_to :action => 'login'
|
||||
return
|
||||
end
|
||||
else
|
||||
if request.get?
|
||||
@user = User.new(:language => Setting.default_language)
|
||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
|
||||
else
|
||||
@user = User.new(params[:user])
|
||||
@user.admin = false
|
||||
@user.login = params[:user][:login]
|
||||
@user.status = User::STATUS_REGISTERED
|
||||
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
|
||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
|
||||
@user.custom_values = @custom_values
|
||||
token = Token.new(:user => @user, :action => "register")
|
||||
if @user.save and token.save
|
||||
Mailer.deliver_register(token)
|
||||
flash[:notice] = l(:notice_account_register_done)
|
||||
redirect_to :controller => 'welcome' and return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,148 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 ApplicationController < ActionController::Base
|
||||
before_filter :check_if_login_required, :set_localization
|
||||
filter_parameter_logging :password
|
||||
|
||||
def logged_in_user=(user)
|
||||
@logged_in_user = user
|
||||
session[:user_id] = (user ? user.id : nil)
|
||||
end
|
||||
|
||||
def logged_in_user
|
||||
if session[:user_id]
|
||||
@logged_in_user ||= User.find(session[:user_id])
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the role that the logged in user has on the current project
|
||||
# or nil if current user is not a member of the project
|
||||
def logged_in_user_membership
|
||||
@user_membership ||= logged_in_user.role_for_project(@project)
|
||||
end
|
||||
|
||||
# check if login is globally required to access the application
|
||||
def check_if_login_required
|
||||
require_login if Setting.login_required?
|
||||
end
|
||||
|
||||
def set_localization
|
||||
lang = begin
|
||||
if self.logged_in_user and self.logged_in_user.language and !self.logged_in_user.language.empty? and GLoc.valid_languages.include? self.logged_in_user.language.to_sym
|
||||
self.logged_in_user.language
|
||||
elsif request.env['HTTP_ACCEPT_LANGUAGE']
|
||||
accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.split('-').first
|
||||
if accept_lang and !accept_lang.empty? and GLoc.valid_languages.include? accept_lang.to_sym
|
||||
accept_lang
|
||||
end
|
||||
end
|
||||
rescue
|
||||
nil
|
||||
end || Setting.default_language
|
||||
set_language_if_valid(lang)
|
||||
end
|
||||
|
||||
def require_login
|
||||
unless self.logged_in_user
|
||||
store_location
|
||||
redirect_to :controller => "account", :action => "login"
|
||||
return false
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
def require_admin
|
||||
return unless require_login
|
||||
unless self.logged_in_user.admin?
|
||||
render :nothing => true, :status => 403
|
||||
return false
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
# authorizes the user for the requested action.
|
||||
def authorize(ctrl = params[:controller], action = params[:action])
|
||||
# check if action is allowed on public projects
|
||||
if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ ctrl, action ]
|
||||
return true
|
||||
end
|
||||
# if action is not public, force login
|
||||
return unless require_login
|
||||
# admin is always authorized
|
||||
return true if self.logged_in_user.admin?
|
||||
# if not admin, check membership permission
|
||||
if logged_in_user_membership and Permission.allowed_to_role( "%s/%s" % [ ctrl, action ], logged_in_user_membership )
|
||||
return true
|
||||
end
|
||||
render :nothing => true, :status => 403
|
||||
false
|
||||
end
|
||||
|
||||
# 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
|
||||
return true if @project.is_public?
|
||||
return false unless logged_in_user
|
||||
return true if logged_in_user.admin? || logged_in_user_membership
|
||||
render :nothing => true, :status => 403
|
||||
false
|
||||
end
|
||||
|
||||
# store current uri in session.
|
||||
# return to this location by calling redirect_back_or_default
|
||||
def store_location
|
||||
session[:return_to_params] = params
|
||||
end
|
||||
|
||||
# move to the last store_location call or to the passed default one
|
||||
def redirect_back_or_default(default)
|
||||
if session[:return_to_params].nil?
|
||||
redirect_to default
|
||||
else
|
||||
redirect_to session[:return_to_params]
|
||||
session[:return_to_params] = nil
|
||||
end
|
||||
end
|
||||
|
||||
def render_404
|
||||
@html_title = "404"
|
||||
render :template => "common/404", :layout => true, :status => 404
|
||||
return false
|
||||
end
|
||||
|
||||
# qvalues http header parser
|
||||
# code taken from webrick
|
||||
def parse_qvalues(value)
|
||||
tmp = []
|
||||
if value
|
||||
parts = value.split(/,\s*/)
|
||||
parts.each {|part|
|
||||
if m = %r{^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$}.match(part)
|
||||
val = m[1]
|
||||
q = (m[2] or 1).to_f
|
||||
tmp.push([val, q])
|
||||
end
|
||||
}
|
||||
tmp = tmp.sort_by{|val, q| -q}
|
||||
tmp.collect!{|val, q| val}
|
||||
end
|
||||
return tmp
|
||||
end
|
||||
end
|
||||
@@ -1,83 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 AuthSourcesController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
def index
|
||||
list
|
||||
render :action => 'list' unless request.xhr?
|
||||
end
|
||||
|
||||
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
|
||||
verify :method => :post, :only => [ :destroy, :create, :update ],
|
||||
:redirect_to => { :action => :list }
|
||||
|
||||
def list
|
||||
@auth_source_pages, @auth_sources = paginate :auth_sources, :per_page => 10
|
||||
render :action => "list", :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def new
|
||||
@auth_source = AuthSourceLdap.new
|
||||
end
|
||||
|
||||
def create
|
||||
@auth_source = AuthSourceLdap.new(params[:auth_source])
|
||||
if @auth_source.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :action => 'list'
|
||||
else
|
||||
render :action => 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@auth_source = AuthSource.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@auth_source = AuthSource.find(params[:id])
|
||||
if @auth_source.update_attributes(params[:auth_source])
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'list'
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def test_connection
|
||||
@auth_method = AuthSource.find(params[:id])
|
||||
begin
|
||||
@auth_method.test_connection
|
||||
rescue => text
|
||||
flash[:notice] = text
|
||||
end
|
||||
flash[:notice] ||= l(:notice_successful_connection)
|
||||
redirect_to :action => 'list'
|
||||
end
|
||||
|
||||
def destroy
|
||||
@auth_source = AuthSource.find(params[:id])
|
||||
unless @auth_source.users.find(:first)
|
||||
@auth_source.destroy
|
||||
flash[:notice] = l(:notice_successful_delete)
|
||||
end
|
||||
redirect_to :action => 'list'
|
||||
end
|
||||
end
|
||||
@@ -1,72 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 CustomFieldsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
def index
|
||||
list
|
||||
render :action => 'list' unless request.xhr?
|
||||
end
|
||||
|
||||
def list
|
||||
@custom_fields_by_type = CustomField.find(:all).group_by {|f| f.type.to_s }
|
||||
@tab = params[:tab] || 'IssueCustomField'
|
||||
render :action => "list", :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def new
|
||||
case params[:type]
|
||||
when "IssueCustomField"
|
||||
@custom_field = IssueCustomField.new(params[:custom_field])
|
||||
@custom_field.trackers = Tracker.find(params[:tracker_ids]) if params[:tracker_ids]
|
||||
when "UserCustomField"
|
||||
@custom_field = UserCustomField.new(params[:custom_field])
|
||||
when "ProjectCustomField"
|
||||
@custom_field = ProjectCustomField.new(params[:custom_field])
|
||||
else
|
||||
redirect_to :action => 'list'
|
||||
return
|
||||
end
|
||||
if request.post? and @custom_field.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :action => 'list', :tab => @custom_field.type
|
||||
end
|
||||
@trackers = Tracker.find(:all, :order => 'position')
|
||||
end
|
||||
|
||||
def edit
|
||||
@custom_field = CustomField.find(params[:id])
|
||||
if request.post? and @custom_field.update_attributes(params[:custom_field])
|
||||
if @custom_field.is_a? IssueCustomField
|
||||
@custom_field.trackers = params[:tracker_ids] ? Tracker.find(params[:tracker_ids]) : []
|
||||
end
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'list', :tab => @custom_field.type
|
||||
end
|
||||
@trackers = Tracker.find(:all, :order => 'position')
|
||||
end
|
||||
|
||||
def destroy
|
||||
@custom_field = CustomField.find(params[:id]).destroy
|
||||
redirect_to :action => 'list', :tab => @custom_field.type
|
||||
rescue
|
||||
flash[:notice] = "Unable to delete custom field"
|
||||
redirect_to :action => 'list'
|
||||
end
|
||||
end
|
||||
@@ -1,96 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 FeedsController < ApplicationController
|
||||
before_filter :find_scope
|
||||
session :off
|
||||
|
||||
helper :issues
|
||||
include IssuesHelper
|
||||
helper :custom_fields
|
||||
include CustomFieldsHelper
|
||||
|
||||
# news feeds
|
||||
def news
|
||||
News.with_scope(:find => @find_options) do
|
||||
@news = News.find :all, :order => "#{News.table_name}.created_on DESC", :include => [ :author, :project ]
|
||||
end
|
||||
headers["Content-Type"] = "application/rss+xml"
|
||||
render :action => 'news_atom' if 'atom' == params[:format]
|
||||
end
|
||||
|
||||
# issue feeds
|
||||
def issues
|
||||
if @project && params[:query_id]
|
||||
query = Query.find(params[:query_id])
|
||||
# ignore query if it's not valid
|
||||
query = nil unless query.valid?
|
||||
# override with query conditions
|
||||
@find_options[:conditions] = query.statement if query.valid? and @project == query.project
|
||||
end
|
||||
|
||||
Issue.with_scope(:find => @find_options) do
|
||||
@issues = Issue.find :all, :include => [:project, :author, :tracker, :status],
|
||||
:order => "#{Issue.table_name}.created_on DESC"
|
||||
end
|
||||
@title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
|
||||
headers["Content-Type"] = "application/rss+xml"
|
||||
render :action => 'issues_atom' if 'atom' == params[:format]
|
||||
end
|
||||
|
||||
# issue changes feeds
|
||||
def history
|
||||
if @project && params[:query_id]
|
||||
query = Query.find(params[:query_id])
|
||||
# ignore query if it's not valid
|
||||
query = nil unless query.valid?
|
||||
# override with query conditions
|
||||
@find_options[:conditions] = query.statement if query.valid? and @project == query.project
|
||||
end
|
||||
|
||||
Journal.with_scope(:find => @find_options) do
|
||||
@journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ],
|
||||
:order => "#{Journal.table_name}.created_on DESC"
|
||||
end
|
||||
|
||||
@title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
|
||||
headers["Content-Type"] = "application/rss+xml"
|
||||
render :action => 'history_atom' if 'atom' == params[:format]
|
||||
end
|
||||
|
||||
private
|
||||
# override for feeds specific authentication
|
||||
def check_if_login_required
|
||||
@user = User.find_by_rss_key(params[:key])
|
||||
render(:nothing => true, :status => 403) and return false if !@user && Setting.login_required?
|
||||
end
|
||||
|
||||
def find_scope
|
||||
if params[:project_id]
|
||||
# project feed
|
||||
# check if project is public or if the user is a member
|
||||
@project = Project.find(params[:project_id])
|
||||
render(:nothing => true, :status => 403) and return false unless @project.is_public? || (@user && @user.role_for_project(@project))
|
||||
scope = ["#{Project.table_name}.id=?", params[:project_id].to_i]
|
||||
else
|
||||
# global feed
|
||||
scope = ["#{Project.table_name}.is_public=?", true]
|
||||
end
|
||||
@find_options = {:conditions => scope, :limit => Setting.feeds_limit}
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -1,159 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 IssuesController < ApplicationController
|
||||
layout 'base', :except => :export_pdf
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
helper :custom_fields
|
||||
include CustomFieldsHelper
|
||||
helper :ifpdf
|
||||
include IfpdfHelper
|
||||
|
||||
def show
|
||||
@status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
|
||||
@custom_values = @issue.custom_values.find(:all, :include => :custom_field)
|
||||
@journals_count = @issue.journals.count
|
||||
@journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "#{Journal.table_name}.created_on desc")
|
||||
end
|
||||
|
||||
def history
|
||||
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on desc")
|
||||
@journals_count = @journals.length
|
||||
end
|
||||
|
||||
def export_pdf
|
||||
@custom_values = @issue.custom_values.find(:all, :include => :custom_field)
|
||||
@options_for_rfpdf ||= {}
|
||||
@options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.long_id}.pdf"
|
||||
end
|
||||
|
||||
def edit
|
||||
@priorities = Enumeration::get_values('IPRI')
|
||||
if request.get?
|
||||
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x, :customized => @issue) }
|
||||
else
|
||||
begin
|
||||
@issue.init_journal(self.logged_in_user)
|
||||
# Retrieve custom fields and values
|
||||
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
|
||||
@issue.custom_values = @custom_values
|
||||
@issue.attributes = params[:issue]
|
||||
if @issue.save
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'show', :id => @issue
|
||||
end
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
# Optimistic locking exception
|
||||
flash[:notice] = l(:notice_locking_conflict)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def add_note
|
||||
unless params[:notes].empty?
|
||||
journal = @issue.init_journal(self.logged_in_user, params[:notes])
|
||||
if @issue.save
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||||
redirect_to :action => 'show', :id => @issue
|
||||
return
|
||||
end
|
||||
end
|
||||
show
|
||||
render :action => 'show'
|
||||
end
|
||||
|
||||
def change_status
|
||||
@status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
|
||||
@new_status = IssueStatus.find(params[:new_status_id])
|
||||
if params[:confirm]
|
||||
begin
|
||||
journal = @issue.init_journal(self.logged_in_user, params[:notes])
|
||||
@issue.status = @new_status
|
||||
if @issue.update_attributes(params[:issue])
|
||||
# Save attachments
|
||||
params[:attachments].each { |file|
|
||||
next unless file.size > 0
|
||||
a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
|
||||
journal.details << JournalDetail.new(:property => 'attachment',
|
||||
:prop_key => a.id,
|
||||
:value => a.filename) unless a.new_record?
|
||||
} if params[:attachments] and params[:attachments].is_a? Array
|
||||
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||||
redirect_to :action => 'show', :id => @issue
|
||||
end
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
# Optimistic locking exception
|
||||
flash[:notice] = l(:notice_locking_conflict)
|
||||
end
|
||||
end
|
||||
@assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
|
||||
end
|
||||
|
||||
def destroy
|
||||
@issue.destroy
|
||||
redirect_to :controller => 'projects', :action => 'list_issues', :id => @project
|
||||
end
|
||||
|
||||
def add_attachment
|
||||
# Save the attachments
|
||||
@attachments = []
|
||||
journal = @issue.init_journal(self.logged_in_user)
|
||||
params[:attachments].each { |file|
|
||||
next unless file.size > 0
|
||||
a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
|
||||
@attachments << a unless a.new_record?
|
||||
journal.details << JournalDetail.new(:property => 'attachment',
|
||||
:prop_key => a.id,
|
||||
:value => a.filename) unless a.new_record?
|
||||
} if params[:attachments] and params[:attachments].is_a? Array
|
||||
journal.save if journal.details.any?
|
||||
Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||||
redirect_to :action => 'show', :id => @issue
|
||||
end
|
||||
|
||||
def destroy_attachment
|
||||
a = @issue.attachments.find(params[:attachment_id])
|
||||
a.destroy
|
||||
journal = @issue.init_journal(self.logged_in_user)
|
||||
journal.details << JournalDetail.new(:property => 'attachment',
|
||||
:prop_key => a.id,
|
||||
:old_value => a.filename)
|
||||
journal.save
|
||||
redirect_to :action => 'show', :id => @issue
|
||||
end
|
||||
|
||||
# Send the file in stream mode
|
||||
def download
|
||||
@attachment = @issue.attachments.find(params[:attachment_id])
|
||||
send_file @attachment.diskfile, :filename => @attachment.filename
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
private
|
||||
def find_project
|
||||
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
|
||||
@project = @issue.project
|
||||
@html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}"
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
end
|
||||
@@ -1,136 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 MyController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_login
|
||||
|
||||
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
|
||||
'issuesreportedbyme' => :label_reported_issues,
|
||||
'news' => :label_news_latest,
|
||||
'calendar' => :label_calendar,
|
||||
'documents' => :label_document_plural
|
||||
}.freeze
|
||||
|
||||
DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'],
|
||||
'right' => ['issuesreportedbyme']
|
||||
}.freeze
|
||||
|
||||
verify :xhr => true,
|
||||
:session => :page_layout,
|
||||
:only => [:add_block, :remove_block, :order_blocks]
|
||||
|
||||
def index
|
||||
page
|
||||
render :action => 'page'
|
||||
end
|
||||
|
||||
# Show user's page
|
||||
def page
|
||||
@user = self.logged_in_user
|
||||
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT
|
||||
end
|
||||
|
||||
# Edit user's account
|
||||
def account
|
||||
@user = self.logged_in_user
|
||||
@pref = @user.pref
|
||||
@user.attributes = params[:user]
|
||||
@user.pref.attributes = params[:pref]
|
||||
if request.post? and @user.save and @user.pref.save
|
||||
set_localization
|
||||
flash.now[:notice] = l(:notice_account_updated)
|
||||
self.logged_in_user.reload
|
||||
end
|
||||
end
|
||||
|
||||
# Change user's password
|
||||
def change_password
|
||||
@user = self.logged_in_user
|
||||
flash[:notice] = l(:notice_can_t_change_password) and redirect_to :action => 'account' and return if @user.auth_source_id
|
||||
if @user.check_password?(params[:password])
|
||||
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
||||
if @user.save
|
||||
flash[:notice] = l(:notice_account_password_updated)
|
||||
else
|
||||
render :action => 'account'
|
||||
return
|
||||
end
|
||||
else
|
||||
flash[:notice] = l(:notice_account_wrong_password)
|
||||
end
|
||||
redirect_to :action => 'account'
|
||||
end
|
||||
|
||||
# User's page layout configuration
|
||||
def page_layout
|
||||
@user = self.logged_in_user
|
||||
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup
|
||||
session[:page_layout] = @blocks
|
||||
%w(top left right).each {|f| session[:page_layout][f] ||= [] }
|
||||
@block_options = []
|
||||
BLOCKS.each {|k, v| @block_options << [l(v), k]}
|
||||
end
|
||||
|
||||
# Add a block to user's page
|
||||
# The block is added on top of the page
|
||||
# params[:block] : id of the block to add
|
||||
def add_block
|
||||
block = params[:block]
|
||||
render(:nothing => true) and return unless block && (BLOCKS.keys.include? block)
|
||||
@user = self.logged_in_user
|
||||
# remove if already present in a group
|
||||
%w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }
|
||||
# add it on top
|
||||
session[:page_layout]['top'].unshift block
|
||||
render :partial => "block", :locals => {:user => @user, :block_name => block}
|
||||
end
|
||||
|
||||
# Remove a block to user's page
|
||||
# params[:block] : id of the block to remove
|
||||
def remove_block
|
||||
block = params[:block]
|
||||
# remove block in all groups
|
||||
%w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
# Change blocks order on user's page
|
||||
# params[:group] : group to order (top, left or right)
|
||||
# params[:list-(top|left|right)] : array of block ids of the group
|
||||
def order_blocks
|
||||
group = params[:group]
|
||||
group_items = params["list-#{group}"]
|
||||
if group_items and group_items.is_a? Array
|
||||
# remove group blocks if they are presents in other groups
|
||||
%w(top left right).each {|f|
|
||||
session[:page_layout][f] = (session[:page_layout][f] || []) - group_items
|
||||
}
|
||||
session[:page_layout][group] = group_items
|
||||
end
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
# Save user's page layout
|
||||
def page_layout_save
|
||||
@user = self.logged_in_user
|
||||
@user.pref[:my_page_layout] = session[:page_layout] if session[:page_layout]
|
||||
@user.pref.save
|
||||
session[:page_layout] = nil
|
||||
redirect_to :action => 'page'
|
||||
end
|
||||
end
|
||||
@@ -1,60 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 NewsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def edit
|
||||
if request.post? and @news.update_attributes(params[:news])
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'show', :id => @news
|
||||
end
|
||||
end
|
||||
|
||||
def add_comment
|
||||
@comment = Comment.new(params[:comment])
|
||||
@comment.author = logged_in_user
|
||||
if @news.comments << @comment
|
||||
flash[:notice] = l(:label_comment_added)
|
||||
redirect_to :action => 'show', :id => @news
|
||||
else
|
||||
render :action => 'show'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_comment
|
||||
@news.comments.find(params[:comment_id]).destroy
|
||||
redirect_to :action => 'show', :id => @news
|
||||
end
|
||||
|
||||
def destroy
|
||||
@news.destroy
|
||||
redirect_to :controller => 'projects', :action => 'list_news', :id => @project
|
||||
end
|
||||
|
||||
private
|
||||
def find_project
|
||||
@news = News.find(params[:id])
|
||||
@project = @news.project
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
end
|
||||
@@ -1,691 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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.
|
||||
|
||||
require 'csv'
|
||||
|
||||
class ProjectsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
|
||||
before_filter :require_admin, :only => [ :add, :destroy ]
|
||||
|
||||
helper :sort
|
||||
include SortHelper
|
||||
helper :custom_fields
|
||||
include CustomFieldsHelper
|
||||
helper :ifpdf
|
||||
include IfpdfHelper
|
||||
helper IssuesHelper
|
||||
helper :queries
|
||||
include QueriesHelper
|
||||
|
||||
def index
|
||||
list
|
||||
render :action => 'list' unless request.xhr?
|
||||
end
|
||||
|
||||
# Lists public projects
|
||||
def list
|
||||
sort_init "#{Project.table_name}.name", "asc"
|
||||
sort_update
|
||||
@project_count = Project.count(:all, :conditions => ["is_public=?", true])
|
||||
@project_pages = Paginator.new self, @project_count,
|
||||
15,
|
||||
params['page']
|
||||
@projects = Project.find :all, :order => sort_clause,
|
||||
:conditions => ["#{Project.table_name}.is_public=?", true],
|
||||
:include => :parent,
|
||||
:limit => @project_pages.items_per_page,
|
||||
:offset => @project_pages.current.offset
|
||||
|
||||
render :action => "list", :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
# Add a new project
|
||||
def add
|
||||
@custom_fields = IssueCustomField.find(:all)
|
||||
@root_projects = Project.find(:all, :conditions => "parent_id is null")
|
||||
@project = Project.new(params[:project])
|
||||
if request.get?
|
||||
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
|
||||
else
|
||||
@project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
|
||||
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
|
||||
@project.custom_values = @custom_values
|
||||
if params[:repository_enabled] && params[:repository_enabled] == "1"
|
||||
@project.repository = Repository.new
|
||||
@project.repository.attributes = params[:repository]
|
||||
end
|
||||
if "1" == params[:wiki_enabled]
|
||||
@project.wiki = Wiki.new
|
||||
@project.wiki.attributes = params[:wiki]
|
||||
end
|
||||
if @project.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :controller => 'admin', :action => 'projects'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show @project
|
||||
def show
|
||||
@custom_values = @project.custom_values.find(:all, :include => :custom_field)
|
||||
@members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role}
|
||||
@subprojects = @project.children if @project.children.size > 0
|
||||
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
||||
@trackers = Tracker.find(:all, :order => 'position')
|
||||
@open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false])
|
||||
@total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id])
|
||||
end
|
||||
|
||||
def settings
|
||||
@root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
|
||||
@custom_fields = IssueCustomField.find(:all)
|
||||
@issue_category ||= IssueCategory.new
|
||||
@member ||= @project.members.new
|
||||
@roles = Role.find(:all, :order => 'position')
|
||||
@users = User.find_active(:all) - @project.users
|
||||
@custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
|
||||
end
|
||||
|
||||
# Edit @project
|
||||
def edit
|
||||
if request.post?
|
||||
@project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
|
||||
if params[:custom_fields]
|
||||
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
|
||||
@project.custom_values = @custom_values
|
||||
end
|
||||
if params[:repository_enabled]
|
||||
case params[:repository_enabled]
|
||||
when "0"
|
||||
@project.repository = nil
|
||||
when "1"
|
||||
@project.repository ||= Repository.new
|
||||
@project.repository.update_attributes params[:repository]
|
||||
end
|
||||
end
|
||||
if params[:wiki_enabled]
|
||||
case params[:wiki_enabled]
|
||||
when "0"
|
||||
@project.wiki.destroy if @project.wiki
|
||||
when "1"
|
||||
@project.wiki ||= Wiki.new
|
||||
@project.wiki.update_attributes params[:wiki]
|
||||
end
|
||||
end
|
||||
@project.attributes = params[:project]
|
||||
if @project.save
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'settings', :id => @project
|
||||
else
|
||||
settings
|
||||
render :action => 'settings'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Delete @project
|
||||
def destroy
|
||||
if request.post? and params[:confirm]
|
||||
@project.destroy
|
||||
redirect_to :controller => 'admin', :action => 'projects'
|
||||
end
|
||||
end
|
||||
|
||||
# Add a new issue category to @project
|
||||
def add_issue_category
|
||||
if request.post?
|
||||
@issue_category = @project.issue_categories.build(params[:issue_category])
|
||||
if @issue_category.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :action => 'settings', :tab => 'categories', :id => @project
|
||||
else
|
||||
settings
|
||||
render :action => 'settings'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Add a new version to @project
|
||||
def add_version
|
||||
@version = @project.versions.build(params[:version])
|
||||
if request.post? and @version.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :action => 'settings', :tab => 'versions', :id => @project
|
||||
end
|
||||
end
|
||||
|
||||
# Add a new member to @project
|
||||
def add_member
|
||||
@member = @project.members.build(params[:member])
|
||||
if request.post?
|
||||
if @member.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :action => 'settings', :tab => 'members', :id => @project
|
||||
else
|
||||
settings
|
||||
render :action => 'settings'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show members list of @project
|
||||
def list_members
|
||||
@members = @project.members.find(:all)
|
||||
end
|
||||
|
||||
# Add a new document to @project
|
||||
def add_document
|
||||
@categories = Enumeration::get_values('DCAT')
|
||||
@document = @project.documents.build(params[:document])
|
||||
if request.post? and @document.save
|
||||
# Save the attachments
|
||||
params[:attachments].each { |a|
|
||||
Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
|
||||
} if params[:attachments] and params[:attachments].is_a? Array
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||||
redirect_to :action => 'list_documents', :id => @project
|
||||
end
|
||||
end
|
||||
|
||||
# Show documents list of @project
|
||||
def list_documents
|
||||
@documents = @project.documents.find :all, :include => :category
|
||||
end
|
||||
|
||||
# Add a new issue to @project
|
||||
def add_issue
|
||||
@tracker = Tracker.find(params[:tracker_id])
|
||||
@priorities = Enumeration::get_values('IPRI')
|
||||
|
||||
default_status = IssueStatus.default
|
||||
@issue = Issue.new(:project => @project, :tracker => @tracker)
|
||||
@issue.status = default_status
|
||||
@allowed_statuses = default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
|
||||
if request.get?
|
||||
@issue.start_date = Date.today
|
||||
@custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
|
||||
else
|
||||
@issue.attributes = params[:issue]
|
||||
|
||||
requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
|
||||
@issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
|
||||
|
||||
@issue.author_id = self.logged_in_user.id if self.logged_in_user
|
||||
# Multiple file upload
|
||||
@attachments = []
|
||||
params[:attachments].each { |a|
|
||||
@attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
|
||||
} if params[:attachments] and params[:attachments].is_a? Array
|
||||
@custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
|
||||
@issue.custom_values = @custom_values
|
||||
if @issue.save
|
||||
@attachments.each(&:save)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||||
redirect_to :action => 'list_issues', :id => @project
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show filtered/sorted issues list of @project
|
||||
def list_issues
|
||||
sort_init "#{Issue.table_name}.id", "desc"
|
||||
sort_update
|
||||
|
||||
retrieve_query
|
||||
|
||||
@results_per_page_options = [ 15, 25, 50, 100 ]
|
||||
if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
|
||||
@results_per_page = params[:per_page].to_i
|
||||
session[:results_per_page] = @results_per_page
|
||||
else
|
||||
@results_per_page = session[:results_per_page] || 25
|
||||
end
|
||||
|
||||
if @query.valid?
|
||||
@issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
|
||||
@issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
|
||||
@issues = Issue.find :all, :order => sort_clause,
|
||||
:include => [ :assigned_to, :status, :tracker, :project, :priority ],
|
||||
:conditions => @query.statement,
|
||||
:limit => @issue_pages.items_per_page,
|
||||
:offset => @issue_pages.current.offset
|
||||
end
|
||||
@trackers = Tracker.find :all, :order => 'position'
|
||||
render :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
# Export filtered/sorted issues list to CSV
|
||||
def export_issues_csv
|
||||
sort_init "#{Issue.table_name}.id", "desc"
|
||||
sort_update
|
||||
|
||||
retrieve_query
|
||||
render :action => 'list_issues' and return unless @query.valid?
|
||||
|
||||
@issues = Issue.find :all, :order => sort_clause,
|
||||
:include => [ :assigned_to, :author, :status, :tracker, :priority, {:custom_values => :custom_field} ],
|
||||
:conditions => @query.statement,
|
||||
:limit => Setting.issues_export_limit
|
||||
|
||||
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||
export = StringIO.new
|
||||
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
||||
# csv header fields
|
||||
headers = [ "#", l(:field_status),
|
||||
l(:field_tracker),
|
||||
l(:field_priority),
|
||||
l(:field_subject),
|
||||
l(:field_assigned_to),
|
||||
l(:field_author),
|
||||
l(:field_start_date),
|
||||
l(:field_due_date),
|
||||
l(:field_done_ratio),
|
||||
l(:field_created_on),
|
||||
l(:field_updated_on)
|
||||
]
|
||||
for custom_field in @project.all_custom_fields
|
||||
headers << custom_field.name
|
||||
end
|
||||
csv << headers.collect {|c| ic.iconv(c) }
|
||||
# csv lines
|
||||
@issues.each do |issue|
|
||||
fields = [issue.id, issue.status.name,
|
||||
issue.tracker.name,
|
||||
issue.priority.name,
|
||||
issue.subject,
|
||||
(issue.assigned_to ? issue.assigned_to.name : ""),
|
||||
issue.author.name,
|
||||
issue.start_date ? l_date(issue.start_date) : nil,
|
||||
issue.due_date ? l_date(issue.due_date) : nil,
|
||||
issue.done_ratio,
|
||||
l_datetime(issue.created_on),
|
||||
l_datetime(issue.updated_on)
|
||||
]
|
||||
for custom_field in @project.all_custom_fields
|
||||
fields << (show_value issue.custom_value_for(custom_field))
|
||||
end
|
||||
csv << fields.collect {|c| ic.iconv(c.to_s) }
|
||||
end
|
||||
end
|
||||
export.rewind
|
||||
send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
|
||||
end
|
||||
|
||||
# Export filtered/sorted issues to PDF
|
||||
def export_issues_pdf
|
||||
sort_init "#{Issue.table_name}.id", "desc"
|
||||
sort_update
|
||||
|
||||
retrieve_query
|
||||
render :action => 'list_issues' and return unless @query.valid?
|
||||
|
||||
@issues = Issue.find :all, :order => sort_clause,
|
||||
:include => [ :author, :status, :tracker, :priority ],
|
||||
:conditions => @query.statement,
|
||||
:limit => Setting.issues_export_limit
|
||||
|
||||
@options_for_rfpdf ||= {}
|
||||
@options_for_rfpdf[:file_name] = "export.pdf"
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def move_issues
|
||||
@issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
|
||||
redirect_to :action => 'list_issues', :id => @project and return unless @issues
|
||||
@projects = []
|
||||
# find projects to which the user is allowed to move the issue
|
||||
@logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role)}
|
||||
# issue can be moved to any tracker
|
||||
@trackers = Tracker.find(:all)
|
||||
if request.post? and params[:new_project_id] and params[:new_tracker_id]
|
||||
new_project = Project.find(params[:new_project_id])
|
||||
new_tracker = Tracker.find(params[:new_tracker_id])
|
||||
@issues.each { |i|
|
||||
# project dependent properties
|
||||
unless i.project_id == new_project.id
|
||||
i.category = nil
|
||||
i.fixed_version = nil
|
||||
end
|
||||
# move the issue
|
||||
i.project = new_project
|
||||
i.tracker = new_tracker
|
||||
i.save
|
||||
}
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'list_issues', :id => @project
|
||||
end
|
||||
end
|
||||
|
||||
def add_query
|
||||
@query = Query.new(params[:query])
|
||||
@query.project = @project
|
||||
@query.user = logged_in_user
|
||||
|
||||
params[:fields].each do |field|
|
||||
@query.add_filter(field, params[:operators][field], params[:values][field])
|
||||
end if params[:fields]
|
||||
|
||||
if request.post? and @query.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :controller => 'reports', :action => 'issue_report', :id => @project
|
||||
end
|
||||
render :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
# Add a news to @project
|
||||
def add_news
|
||||
@news = News.new(:project => @project)
|
||||
if request.post?
|
||||
@news.attributes = params[:news]
|
||||
@news.author_id = self.logged_in_user.id if self.logged_in_user
|
||||
if @news.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :action => 'list_news', :id => @project
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show news list of @project
|
||||
def list_news
|
||||
@news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "#{News.table_name}.created_on DESC"
|
||||
render :action => "list_news", :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def add_file
|
||||
if request.post?
|
||||
@version = @project.versions.find_by_id(params[:version_id])
|
||||
# Save the attachments
|
||||
@attachments = []
|
||||
params[:attachments].each { |file|
|
||||
next unless file.size > 0
|
||||
a = Attachment.create(:container => @version, :file => file, :author => logged_in_user)
|
||||
@attachments << a unless a.new_record?
|
||||
} if params[:attachments] and params[:attachments].is_a? Array
|
||||
Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||||
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
||||
end
|
||||
@versions = @project.versions
|
||||
end
|
||||
|
||||
def list_files
|
||||
@versions = @project.versions
|
||||
end
|
||||
|
||||
# Show changelog for @project
|
||||
def changelog
|
||||
@trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
|
||||
retrieve_selected_tracker_ids(@trackers)
|
||||
|
||||
@fixed_issues = @project.issues.find(:all,
|
||||
:include => [ :fixed_version, :status, :tracker ],
|
||||
:conditions => [ "#{IssueStatus.table_name}.is_closed=? and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}) and #{Issue.table_name}.fixed_version_id is not null", true],
|
||||
:order => "#{Version.table_name}.effective_date DESC, #{Issue.table_name}.id DESC"
|
||||
) unless @selected_tracker_ids.empty?
|
||||
@fixed_issues ||= []
|
||||
end
|
||||
|
||||
def roadmap
|
||||
@trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position')
|
||||
retrieve_selected_tracker_ids(@trackers)
|
||||
|
||||
@versions = @project.versions.find(:all,
|
||||
:conditions => [ "#{Version.table_name}.effective_date>?", Date.today],
|
||||
:order => "#{Version.table_name}.effective_date ASC"
|
||||
)
|
||||
end
|
||||
|
||||
def activity
|
||||
if params[:year] and params[:year].to_i > 1900
|
||||
@year = params[:year].to_i
|
||||
if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
|
||||
@month = params[:month].to_i
|
||||
end
|
||||
end
|
||||
@year ||= Date.today.year
|
||||
@month ||= Date.today.month
|
||||
|
||||
@date_from = Date.civil(@year, @month, 1)
|
||||
@date_to = (@date_from >> 1)-1
|
||||
|
||||
@events_by_day = {}
|
||||
|
||||
unless params[:show_issues] == "0"
|
||||
@project.issues.find(:all, :include => [:author], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] ).each { |i|
|
||||
@events_by_day[i.created_on.to_date] ||= []
|
||||
@events_by_day[i.created_on.to_date] << i
|
||||
}
|
||||
@show_issues = 1
|
||||
end
|
||||
|
||||
unless params[:show_news] == "0"
|
||||
@project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author ).each { |i|
|
||||
@events_by_day[i.created_on.to_date] ||= []
|
||||
@events_by_day[i.created_on.to_date] << i
|
||||
}
|
||||
@show_news = 1
|
||||
end
|
||||
|
||||
unless params[:show_files] == "0"
|
||||
Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
|
||||
@events_by_day[i.created_on.to_date] ||= []
|
||||
@events_by_day[i.created_on.to_date] << i
|
||||
}
|
||||
@show_files = 1
|
||||
end
|
||||
|
||||
unless params[:show_documents] == "0"
|
||||
@project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] ).each { |i|
|
||||
@events_by_day[i.created_on.to_date] ||= []
|
||||
@events_by_day[i.created_on.to_date] << i
|
||||
}
|
||||
Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
|
||||
@events_by_day[i.created_on.to_date] ||= []
|
||||
@events_by_day[i.created_on.to_date] << i
|
||||
}
|
||||
@show_documents = 1
|
||||
end
|
||||
|
||||
unless params[:show_wiki_edits] == "0"
|
||||
select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comment, " +
|
||||
"#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title"
|
||||
joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
|
||||
"LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id "
|
||||
conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
|
||||
@project.id, @date_from, @date_to]
|
||||
|
||||
WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions).each { |i|
|
||||
# We provide this alias so all events can be treated in the same manner
|
||||
def i.created_on
|
||||
self.updated_on
|
||||
end
|
||||
|
||||
@events_by_day[i.created_on.to_date] ||= []
|
||||
@events_by_day[i.created_on.to_date] << i
|
||||
}
|
||||
@show_wiki_edits = 1
|
||||
end
|
||||
|
||||
unless @project.repository.nil? || params[:show_changesets] == "0"
|
||||
@project.repository.changesets.find(:all, :conditions => ["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to]).each { |i|
|
||||
def i.created_on
|
||||
self.committed_on
|
||||
end
|
||||
@events_by_day[i.created_on.to_date] ||= []
|
||||
@events_by_day[i.created_on.to_date] << i
|
||||
}
|
||||
@show_changesets = 1
|
||||
end
|
||||
|
||||
render :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def calendar
|
||||
@trackers = Tracker.find(:all, :order => 'position')
|
||||
retrieve_selected_tracker_ids(@trackers)
|
||||
|
||||
if params[:year] and params[:year].to_i > 1900
|
||||
@year = params[:year].to_i
|
||||
if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
|
||||
@month = params[:month].to_i
|
||||
end
|
||||
end
|
||||
@year ||= Date.today.year
|
||||
@month ||= Date.today.month
|
||||
|
||||
@date_from = Date.civil(@year, @month, 1)
|
||||
@date_to = (@date_from >> 1)-1
|
||||
# start on monday
|
||||
@date_from = @date_from - (@date_from.cwday-1)
|
||||
# finish on sunday
|
||||
@date_to = @date_to + (7-@date_to.cwday)
|
||||
|
||||
@events = []
|
||||
@project.issues_with_subprojects(params[:with_subprojects]) do
|
||||
@events += Issue.find(:all,
|
||||
:include => [:tracker, :status, :assigned_to, :priority],
|
||||
:conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", @date_from, @date_to, @date_from, @date_to]
|
||||
) unless @selected_tracker_ids.empty?
|
||||
end
|
||||
@events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
|
||||
|
||||
@ending_events_by_days = @events.group_by {|event| event.due_date}
|
||||
@starting_events_by_days = @events.group_by {|event| event.start_date}
|
||||
|
||||
render :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def gantt
|
||||
@trackers = Tracker.find(:all, :order => 'position')
|
||||
retrieve_selected_tracker_ids(@trackers)
|
||||
|
||||
if params[:year] and params[:year].to_i >0
|
||||
@year_from = params[:year].to_i
|
||||
if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
|
||||
@month_from = params[:month].to_i
|
||||
else
|
||||
@month_from = 1
|
||||
end
|
||||
else
|
||||
@month_from ||= (Date.today << 1).month
|
||||
@year_from ||= (Date.today << 1).year
|
||||
end
|
||||
|
||||
@zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
|
||||
@months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
|
||||
|
||||
@date_from = Date.civil(@year_from, @month_from, 1)
|
||||
@date_to = (@date_from >> @months) - 1
|
||||
|
||||
@events = []
|
||||
@project.issues_with_subprojects(params[:with_subprojects]) do
|
||||
@events += Issue.find(:all,
|
||||
:order => "start_date, due_date",
|
||||
:include => [:tracker, :status, :assigned_to, :priority],
|
||||
:conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]
|
||||
) unless @selected_tracker_ids.empty?
|
||||
end
|
||||
@events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
|
||||
@events.sort! {|x,y| x.start_date <=> y.start_date }
|
||||
|
||||
if params[:output]=='pdf'
|
||||
@options_for_rfpdf ||= {}
|
||||
@options_for_rfpdf[:file_name] = "gantt.pdf"
|
||||
render :template => "projects/gantt.rfpdf", :layout => false
|
||||
else
|
||||
render :template => "projects/gantt.rhtml"
|
||||
end
|
||||
end
|
||||
|
||||
def search
|
||||
@question = params[:q] || ""
|
||||
@question.strip!
|
||||
@all_words = params[:all_words] || (params[:submit] ? false : true)
|
||||
@scope = params[:scope] || (params[:submit] ? [] : %w(issues changesets news documents wiki) )
|
||||
# tokens must be at least 3 character long
|
||||
@tokens = @question.split.uniq.select {|w| w.length > 2 }
|
||||
if !@tokens.empty?
|
||||
# no more than 5 tokens to search for
|
||||
@tokens.slice! 5..-1 if @tokens.size > 5
|
||||
# strings used in sql like statement
|
||||
like_tokens = @tokens.collect {|w| "%#{w}%"}
|
||||
operator = @all_words ? " AND " : " OR "
|
||||
limit = 10
|
||||
@results = []
|
||||
@results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(subject) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues'
|
||||
@results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort], :include => :author ) if @scope.include? 'news'
|
||||
@results += @project.documents.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'documents'
|
||||
@results += @project.wiki.pages.find(:all, :limit => limit, :include => :content, :conditions => [ (["(LOWER(title) like ? OR LOWER(text) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @project.wiki && @scope.include?('wiki')
|
||||
@results += @project.repository.changesets.find(:all, :limit => limit, :conditions => [ (["(LOWER(comment) like ?)"] * like_tokens.size).join(operator), * (like_tokens).sort] ) if @project.repository && @scope.include?('changesets')
|
||||
@question = @tokens.join(" ")
|
||||
else
|
||||
@question = ""
|
||||
end
|
||||
end
|
||||
|
||||
def feeds
|
||||
@queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)]
|
||||
@key = logged_in_user.get_or_create_rss_key.value if logged_in_user
|
||||
end
|
||||
|
||||
private
|
||||
# Find project of id params[:id]
|
||||
# if not found, redirect to project list
|
||||
# Used as a before_filter
|
||||
def find_project
|
||||
@project = Project.find(params[:id])
|
||||
@html_title = @project.name
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def retrieve_selected_tracker_ids(selectable_trackers)
|
||||
if ids = params[:tracker_ids]
|
||||
@selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
|
||||
else
|
||||
@selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
|
||||
end
|
||||
end
|
||||
|
||||
# Retrieve query from session or build a new query
|
||||
def retrieve_query
|
||||
if params[:query_id]
|
||||
@query = @project.queries.find(params[:query_id])
|
||||
session[:query] = @query
|
||||
else
|
||||
if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
|
||||
# Give it a name, required to be valid
|
||||
@query = Query.new(:name => "_")
|
||||
@query.project = @project
|
||||
if params[:fields] and params[:fields].is_a? Array
|
||||
params[:fields].each do |field|
|
||||
@query.add_filter(field, params[:operators][field], params[:values][field])
|
||||
end
|
||||
else
|
||||
@query.available_filters.keys.each do |field|
|
||||
@query.add_short_filter(field, params[field]) if params[field]
|
||||
end
|
||||
end
|
||||
session[:query] = @query
|
||||
else
|
||||
@query = session[:query]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,51 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 QueriesController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_login, :find_query
|
||||
|
||||
def edit
|
||||
if request.post?
|
||||
@query.filters = {}
|
||||
params[:fields].each do |field|
|
||||
@query.add_filter(field, params[:operators][field], params[:values][field])
|
||||
end if params[:fields]
|
||||
@query.attributes = params[:query]
|
||||
|
||||
if @query.save
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => @query
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@query.destroy if request.post?
|
||||
redirect_to :controller => 'reports', :action => 'issue_report', :id => @project
|
||||
end
|
||||
|
||||
private
|
||||
def find_query
|
||||
@query = Query.find(params[:id])
|
||||
@project = @query.project
|
||||
# check if user is allowed to manage queries (same permission as add_query)
|
||||
authorize('projects', 'add_query')
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
end
|
||||
@@ -1,191 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 ReportsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
def issue_report
|
||||
@statuses = IssueStatus.find(:all, :order => 'position')
|
||||
|
||||
case params[:detail]
|
||||
when "tracker"
|
||||
@field = "tracker_id"
|
||||
@rows = Tracker.find :all, :order => 'position'
|
||||
@data = issues_by_tracker
|
||||
@report_title = l(:field_tracker)
|
||||
render :template => "reports/issue_report_details"
|
||||
when "priority"
|
||||
@field = "priority_id"
|
||||
@rows = Enumeration::get_values('IPRI')
|
||||
@data = issues_by_priority
|
||||
@report_title = l(:field_priority)
|
||||
render :template => "reports/issue_report_details"
|
||||
when "category"
|
||||
@field = "category_id"
|
||||
@rows = @project.issue_categories
|
||||
@data = issues_by_category
|
||||
@report_title = l(:field_category)
|
||||
render :template => "reports/issue_report_details"
|
||||
when "author"
|
||||
@field = "author_id"
|
||||
@rows = @project.members.collect { |m| m.user }
|
||||
@data = issues_by_author
|
||||
@report_title = l(:field_author)
|
||||
render :template => "reports/issue_report_details"
|
||||
when "subproject"
|
||||
@field = "project_id"
|
||||
@rows = @project.children
|
||||
@data = issues_by_subproject
|
||||
@report_title = l(:field_subproject)
|
||||
render :template => "reports/issue_report_details"
|
||||
else
|
||||
@queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)]
|
||||
@trackers = Tracker.find(:all, :order => 'position')
|
||||
@priorities = Enumeration::get_values('IPRI')
|
||||
@categories = @project.issue_categories
|
||||
@authors = @project.members.collect { |m| m.user }
|
||||
@subprojects = @project.children
|
||||
issues_by_tracker
|
||||
issues_by_priority
|
||||
issues_by_category
|
||||
issues_by_author
|
||||
issues_by_subproject
|
||||
@total_hours = @project.time_entries.sum(:hours)
|
||||
render :template => "reports/issue_report"
|
||||
end
|
||||
end
|
||||
|
||||
def delays
|
||||
@trackers = Tracker.find(:all)
|
||||
if request.get?
|
||||
@selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
|
||||
else
|
||||
@selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
|
||||
end
|
||||
@selected_tracker_ids ||= []
|
||||
@raw =
|
||||
ActiveRecord::Base.connection.select_all("SELECT datediff( a.created_on, b.created_on ) as delay, count(a.id) as total
|
||||
FROM issue_histories a, issue_histories b, issues i
|
||||
WHERE a.status_id =5
|
||||
AND a.issue_id = b.issue_id
|
||||
AND a.issue_id = i.id
|
||||
AND i.tracker_id in (#{@selected_tracker_ids.join(',')})
|
||||
AND b.id = (
|
||||
SELECT min( c.id )
|
||||
FROM issue_histories c
|
||||
WHERE b.issue_id = c.issue_id )
|
||||
GROUP BY delay") unless @selected_tracker_ids.empty?
|
||||
@raw ||=[]
|
||||
|
||||
@x_from = 0
|
||||
@x_to = 0
|
||||
@y_from = 0
|
||||
@y_to = 0
|
||||
@sum_total = 0
|
||||
@sum_delay = 0
|
||||
@raw.each do |r|
|
||||
@x_to = [r['delay'].to_i, @x_to].max
|
||||
@y_to = [r['total'].to_i, @y_to].max
|
||||
@sum_total = @sum_total + r['total'].to_i
|
||||
@sum_delay = @sum_delay + r['total'].to_i * r['delay'].to_i
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Find project of id params[:id]
|
||||
def find_project
|
||||
@project = Project.find(params[:id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def issues_by_tracker
|
||||
@issues_by_tracker ||=
|
||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||
s.is_closed as closed,
|
||||
t.id as tracker_id,
|
||||
count(i.id) as total
|
||||
from
|
||||
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t
|
||||
where
|
||||
i.status_id=s.id
|
||||
and i.tracker_id=t.id
|
||||
and i.project_id=#{@project.id}
|
||||
group by s.id, s.is_closed, t.id")
|
||||
end
|
||||
|
||||
def issues_by_priority
|
||||
@issues_by_priority ||=
|
||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||
s.is_closed as closed,
|
||||
p.id as priority_id,
|
||||
count(i.id) as total
|
||||
from
|
||||
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Enumeration.table_name} p
|
||||
where
|
||||
i.status_id=s.id
|
||||
and i.priority_id=p.id
|
||||
and i.project_id=#{@project.id}
|
||||
group by s.id, s.is_closed, p.id")
|
||||
end
|
||||
|
||||
def issues_by_category
|
||||
@issues_by_category ||=
|
||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||
s.is_closed as closed,
|
||||
c.id as category_id,
|
||||
count(i.id) as total
|
||||
from
|
||||
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssueCategory.table_name} c
|
||||
where
|
||||
i.status_id=s.id
|
||||
and i.category_id=c.id
|
||||
and i.project_id=#{@project.id}
|
||||
group by s.id, s.is_closed, c.id")
|
||||
end
|
||||
|
||||
def issues_by_author
|
||||
@issues_by_author ||=
|
||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||
s.is_closed as closed,
|
||||
a.id as author_id,
|
||||
count(i.id) as total
|
||||
from
|
||||
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
|
||||
where
|
||||
i.status_id=s.id
|
||||
and i.author_id=a.id
|
||||
and i.project_id=#{@project.id}
|
||||
group by s.id, s.is_closed, a.id")
|
||||
end
|
||||
|
||||
def issues_by_subproject
|
||||
@issues_by_subproject ||=
|
||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||
s.is_closed as closed,
|
||||
i.project_id as project_id,
|
||||
count(i.id) as total
|
||||
from
|
||||
#{Issue.table_name} i, #{IssueStatus.table_name} s
|
||||
where
|
||||
i.status_id=s.id
|
||||
and i.project_id IN (#{@project.children.collect{|p| p.id}.join(',')})
|
||||
group by s.id, s.is_closed, i.project_id") if @project.children.any?
|
||||
@issues_by_subproject ||= []
|
||||
end
|
||||
end
|
||||
@@ -1,208 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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.
|
||||
|
||||
require 'SVG/Graph/Bar'
|
||||
require 'SVG/Graph/BarHorizontal'
|
||||
|
||||
class RepositoriesController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project
|
||||
before_filter :authorize, :except => [:stats, :graph]
|
||||
before_filter :check_project_privacy, :only => [:stats, :graph]
|
||||
|
||||
def show
|
||||
# get entries for the browse frame
|
||||
@entries = @repository.scm.entries('')
|
||||
show_error and return unless @entries
|
||||
# check if new revisions have been committed in the repository
|
||||
scm_latestrev = @entries.revisions.latest
|
||||
if Setting.autofetch_changesets? && scm_latestrev && ((@repository.latest_changeset.nil?) || (@repository.latest_changeset.revision < scm_latestrev.identifier.to_i))
|
||||
@repository.fetch_changesets
|
||||
@repository.reload
|
||||
end
|
||||
@changesets = @repository.changesets.find(:all, :limit => 5, :order => "committed_on DESC")
|
||||
end
|
||||
|
||||
def browse
|
||||
@entries = @repository.scm.entries(@path, @rev)
|
||||
show_error and return unless @entries
|
||||
end
|
||||
|
||||
def revisions
|
||||
unless @path == ''
|
||||
@entry = @repository.scm.entry(@path, @rev)
|
||||
show_error and return unless @entry
|
||||
end
|
||||
@repository.changesets_with_path @path do
|
||||
@changeset_count = @repository.changesets.count
|
||||
@changeset_pages = Paginator.new self, @changeset_count,
|
||||
25,
|
||||
params['page']
|
||||
@changesets = @repository.changesets.find(:all,
|
||||
:limit => @changeset_pages.items_per_page,
|
||||
:offset => @changeset_pages.current.offset)
|
||||
end
|
||||
render :action => "revisions", :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def entry
|
||||
if 'raw' == params[:format]
|
||||
content = @repository.scm.cat(@path, @rev)
|
||||
show_error and return unless content
|
||||
send_data content, :filename => @path.split('/').last
|
||||
end
|
||||
end
|
||||
|
||||
def revision
|
||||
@changeset = @repository.changesets.find_by_revision(@rev)
|
||||
show_error and return unless @changeset
|
||||
end
|
||||
|
||||
def diff
|
||||
@rev_to = params[:rev_to] || (@rev-1)
|
||||
type = params[:type] || 'inline'
|
||||
@diff = @repository.scm.diff(params[:path], @rev, @rev_to, type)
|
||||
show_error and return unless @diff
|
||||
end
|
||||
|
||||
def stats
|
||||
end
|
||||
|
||||
def graph
|
||||
data = nil
|
||||
case params[:graph]
|
||||
when "commits_per_month"
|
||||
data = graph_commits_per_month(@repository)
|
||||
when "commits_per_author"
|
||||
data = graph_commits_per_author(@repository)
|
||||
end
|
||||
if data
|
||||
headers["Content-Type"] = "image/svg+xml"
|
||||
send_data(data, :type => "image/svg+xml", :disposition => "inline")
|
||||
else
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def find_project
|
||||
@project = Project.find(params[:id])
|
||||
@repository = @project.repository
|
||||
render_404 and return false unless @repository
|
||||
@path = params[:path].squeeze('/').gsub(/^\//, '') if params[:path]
|
||||
@path ||= ''
|
||||
@rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def show_error
|
||||
flash.now[:notice] = l(:notice_scm_error)
|
||||
render :nothing => true, :layout => true
|
||||
end
|
||||
|
||||
def graph_commits_per_month(repository)
|
||||
@date_to = Date.today
|
||||
@date_from = @date_to << 12
|
||||
commits_by_day = repository.changesets.count(:all, :group => :commit_date, :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
|
||||
commits_by_month = [0] * 12
|
||||
commits_by_day.each {|c| commits_by_month[c.first.to_date.months_ago] += c.last }
|
||||
|
||||
changes_by_day = repository.changes.count(:all, :group => :commit_date)
|
||||
changes_by_month = [0] * 12
|
||||
changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last }
|
||||
|
||||
fields = []
|
||||
month_names = l(:actionview_datehelper_select_month_names_abbr).split(',')
|
||||
12.times {|m| fields << month_names[((Date.today.month - 1 - m) % 12)]}
|
||||
|
||||
graph = SVG::Graph::Bar.new(
|
||||
:height => 300,
|
||||
:width => 500,
|
||||
:fields => fields.reverse,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:step_x_labels => 2,
|
||||
:show_data_values => false,
|
||||
:graph_title => l(:label_commits_per_month),
|
||||
:show_graph_title => true
|
||||
)
|
||||
|
||||
graph.add_data(
|
||||
:data => commits_by_month[0..11].reverse,
|
||||
:title => l(:label_revision_plural)
|
||||
)
|
||||
|
||||
graph.add_data(
|
||||
:data => changes_by_month[0..11].reverse,
|
||||
:title => l(:label_change_plural)
|
||||
)
|
||||
|
||||
graph.burn
|
||||
end
|
||||
|
||||
def graph_commits_per_author(repository)
|
||||
commits_by_author = repository.changesets.count(:all, :group => :committer)
|
||||
commits_by_author.sort! {|x, y| x.last <=> y.last}
|
||||
|
||||
changes_by_author = repository.changes.count(:all, :group => :committer)
|
||||
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
||||
|
||||
fields = commits_by_author.collect {|r| r.first}
|
||||
commits_data = commits_by_author.collect {|r| r.last}
|
||||
changes_data = commits_by_author.collect {|r| h[r.first] || 0}
|
||||
|
||||
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
||||
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
||||
changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10
|
||||
|
||||
graph = SVG::Graph::BarHorizontal.new(
|
||||
:height => 300,
|
||||
:width => 500,
|
||||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:show_data_values => false,
|
||||
:rotate_y_labels => false,
|
||||
:graph_title => l(:label_commits_per_author),
|
||||
:show_graph_title => true
|
||||
)
|
||||
|
||||
graph.add_data(
|
||||
:data => commits_data,
|
||||
:title => l(:label_revision_plural)
|
||||
)
|
||||
|
||||
graph.add_data(
|
||||
:data => changes_data,
|
||||
:title => l(:label_change_plural)
|
||||
)
|
||||
|
||||
graph.burn
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Date
|
||||
def months_ago(date = Date.today)
|
||||
(date.year - self.year)*12 + (date.month - self.month)
|
||||
end
|
||||
|
||||
def weeks_ago(date = Date.today)
|
||||
(date.year - self.year)*52 + (date.cweek - self.cweek)
|
||||
end
|
||||
end
|
||||
@@ -1,33 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 SettingsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
def index
|
||||
edit
|
||||
render :action => 'edit'
|
||||
end
|
||||
|
||||
def edit
|
||||
if request.post? and params[:settings] and params[:settings].is_a? Hash
|
||||
params[:settings].each { |name, value| Setting[name] = value }
|
||||
redirect_to :action => 'edit' and return
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,44 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 SysController < ActionController::Base
|
||||
wsdl_service_name 'Sys'
|
||||
web_service_api SysApi
|
||||
web_service_scaffold :invoke
|
||||
|
||||
before_invocation :check_enabled
|
||||
|
||||
def projects
|
||||
Project.find(:all, :include => :repository)
|
||||
end
|
||||
|
||||
def repository_created(project_id, url)
|
||||
project = Project.find_by_id(project_id)
|
||||
return 0 unless project && project.repository.nil?
|
||||
logger.debug "Repository for #{project.name} created"
|
||||
repository = Repository.new(:project => project, :url => url)
|
||||
repository.root_url = url
|
||||
repository.save
|
||||
repository.id
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def check_enabled(name, args)
|
||||
Setting.sys_api_enabled?
|
||||
end
|
||||
end
|
||||
@@ -1,80 +0,0 @@
|
||||
class TimelogController < ApplicationController
|
||||
layout 'base'
|
||||
|
||||
before_filter :find_project
|
||||
before_filter :authorize, :only => :edit
|
||||
before_filter :check_project_privacy, :only => :details
|
||||
|
||||
helper :sort
|
||||
include SortHelper
|
||||
|
||||
def details
|
||||
sort_init 'spent_on', 'desc'
|
||||
sort_update
|
||||
|
||||
@entries = (@issue ? @issue : @project).time_entries.find(:all, :include => [:activity, :user, {:issue => [:tracker, :assigned_to, :priority]}], :order => sort_clause)
|
||||
|
||||
@total_hours = @entries.inject(0) { |sum,entry| sum + entry.hours }
|
||||
@owner_id = logged_in_user ? logged_in_user.id : 0
|
||||
|
||||
send_csv and return if 'csv' == params[:export]
|
||||
render :action => 'details', :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def edit
|
||||
render_404 and return if @time_entry && @time_entry.user != logged_in_user
|
||||
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => logged_in_user, :spent_on => Date.today)
|
||||
@time_entry.attributes = params[:time_entry]
|
||||
if request.post? and @time_entry.save
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'details', :project_id => @time_entry.project, :issue_id => @time_entry.issue
|
||||
return
|
||||
end
|
||||
@activities = Enumeration::get_values('ACTI')
|
||||
end
|
||||
|
||||
private
|
||||
def find_project
|
||||
if params[:id]
|
||||
@time_entry = TimeEntry.find(params[:id])
|
||||
@project = @time_entry.project
|
||||
elsif params[:issue_id]
|
||||
@issue = Issue.find(params[:issue_id])
|
||||
@project = @issue.project
|
||||
elsif params[:project_id]
|
||||
@project = Project.find(params[:project_id])
|
||||
else
|
||||
render_404
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def send_csv
|
||||
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||
export = StringIO.new
|
||||
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
||||
# csv header fields
|
||||
headers = [l(:field_spent_on),
|
||||
l(:field_user),
|
||||
l(:field_activity),
|
||||
l(:field_issue),
|
||||
l(:field_hours),
|
||||
l(:field_comment)
|
||||
]
|
||||
csv << headers.collect {|c| ic.iconv(c) }
|
||||
# csv lines
|
||||
@entries.each do |entry|
|
||||
fields = [l_date(entry.spent_on),
|
||||
entry.user.name,
|
||||
entry.activity.name,
|
||||
(entry.issue ? entry.issue.id : nil),
|
||||
entry.hours,
|
||||
entry.comment
|
||||
]
|
||||
csv << fields.collect {|c| ic.iconv(c.to_s) }
|
||||
end
|
||||
end
|
||||
export.rewind
|
||||
send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
|
||||
end
|
||||
end
|
||||
@@ -1,119 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 UsersController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :require_admin
|
||||
|
||||
helper :sort
|
||||
include SortHelper
|
||||
helper :custom_fields
|
||||
include CustomFieldsHelper
|
||||
|
||||
def index
|
||||
list
|
||||
render :action => 'list' unless request.xhr?
|
||||
end
|
||||
|
||||
def list
|
||||
sort_init 'login', 'asc'
|
||||
sort_update
|
||||
|
||||
@status = params[:status] ? params[:status].to_i : 1
|
||||
conditions = nil
|
||||
conditions = ["status=?", @status] unless @status == 0
|
||||
|
||||
@user_count = User.count(:conditions => conditions)
|
||||
@user_pages = Paginator.new self, @user_count,
|
||||
15,
|
||||
params['page']
|
||||
@users = User.find :all,:order => sort_clause,
|
||||
:conditions => conditions,
|
||||
:limit => @user_pages.items_per_page,
|
||||
:offset => @user_pages.current.offset
|
||||
|
||||
render :action => "list", :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def add
|
||||
if request.get?
|
||||
@user = User.new(:language => Setting.default_language)
|
||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
|
||||
else
|
||||
@user = User.new(params[:user])
|
||||
@user.admin = params[:user][:admin] || false
|
||||
@user.login = params[:user][:login]
|
||||
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id
|
||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
|
||||
@user.custom_values = @custom_values
|
||||
if @user.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :action => 'list'
|
||||
end
|
||||
end
|
||||
@auth_sources = AuthSource.find(:all)
|
||||
end
|
||||
|
||||
def edit
|
||||
@user = User.find(params[:id])
|
||||
if request.get?
|
||||
@custom_values = UserCustomField.find(:all).collect { |x| @user.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
|
||||
else
|
||||
@user.admin = params[:user][:admin] if params[:user][:admin]
|
||||
@user.login = params[:user][:login] if params[:user][:login]
|
||||
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless params[:password].nil? or params[:password].empty? or @user.auth_source_id
|
||||
if params[:custom_fields]
|
||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
|
||||
@user.custom_values = @custom_values
|
||||
end
|
||||
if @user.update_attributes(params[:user])
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :action => 'list'
|
||||
end
|
||||
end
|
||||
@auth_sources = AuthSource.find(:all)
|
||||
@roles = Role.find(:all, :order => 'position')
|
||||
@projects = Project.find(:all) - @user.projects
|
||||
@membership ||= Member.new
|
||||
end
|
||||
|
||||
def edit_membership
|
||||
@user = User.find(params[:id])
|
||||
@membership = params[:membership_id] ? Member.find(params[:membership_id]) : Member.new(:user => @user)
|
||||
@membership.attributes = params[:membership]
|
||||
if request.post? and @membership.save
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
end
|
||||
redirect_to :action => 'edit', :id => @user and return
|
||||
end
|
||||
|
||||
def destroy_membership
|
||||
@user = User.find(params[:id])
|
||||
if request.post? and Member.find(params[:membership_id]).destroy
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
end
|
||||
redirect_to :action => 'edit', :id => @user and return
|
||||
end
|
||||
|
||||
def destroy
|
||||
User.find(params[:id]).destroy
|
||||
redirect_to :action => 'list'
|
||||
rescue
|
||||
flash[:notice] = "Unable to delete user"
|
||||
redirect_to :action => 'list'
|
||||
end
|
||||
end
|
||||
@@ -1,112 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 WikiController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_wiki, :check_project_privacy, :except => [:preview]
|
||||
|
||||
# display a page (in editing mode if it doesn't exist)
|
||||
def index
|
||||
page_title = params[:page]
|
||||
@page = @wiki.find_or_new_page(page_title)
|
||||
if @page.new_record?
|
||||
edit
|
||||
render :action => 'edit' and return
|
||||
end
|
||||
@content = @page.content_for_version(params[:version])
|
||||
if params[:export] == 'html'
|
||||
export = render_to_string :action => 'export', :layout => false
|
||||
send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
|
||||
return
|
||||
elsif params[:export] == 'txt'
|
||||
send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt")
|
||||
return
|
||||
end
|
||||
render :action => 'show'
|
||||
end
|
||||
|
||||
# edit an existing page or a new one
|
||||
def edit
|
||||
@page = @wiki.find_or_new_page(params[:page])
|
||||
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||
|
||||
@content = @page.content_for_version(params[:version])
|
||||
@content.text = "h1. #{@page.pretty_title}" if @content.text.blank?
|
||||
# don't keep previous comment
|
||||
@content.comment = nil
|
||||
if request.post?
|
||||
if @content.text == params[:content][:text]
|
||||
# don't save if text wasn't changed
|
||||
redirect_to :action => 'index', :id => @project, :page => @page.title
|
||||
return
|
||||
end
|
||||
@content.text = params[:content][:text]
|
||||
@content.comment = params[:content][:comment]
|
||||
@content.author = logged_in_user
|
||||
# if page is new @page.save will also save content, but not if page isn't a new record
|
||||
if (@page.new_record? ? @page.save : @content.save)
|
||||
redirect_to :action => 'index', :id => @project, :page => @page.title
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# show page history
|
||||
def history
|
||||
@page = @wiki.find_page(params[:page])
|
||||
# don't load text
|
||||
@versions = @page.content.versions.find :all,
|
||||
:select => "id, author_id, comment, updated_on, version",
|
||||
:order => 'version DESC'
|
||||
end
|
||||
|
||||
# display special pages
|
||||
def special
|
||||
page_title = params[:page].downcase
|
||||
case page_title
|
||||
# show pages index, sorted by title
|
||||
when 'page_index'
|
||||
# eager load information about last updates, without loading text
|
||||
@pages = @wiki.pages.find :all, :select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on",
|
||||
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id",
|
||||
:order => 'title'
|
||||
# export wiki to a single html file
|
||||
when 'export'
|
||||
@pages = @wiki.pages.find :all, :order => 'title'
|
||||
export = render_to_string :action => 'export_multiple', :layout => false
|
||||
send_data(export, :type => 'text/html', :filename => "wiki.html")
|
||||
return
|
||||
else
|
||||
# requested special page doesn't exist, redirect to default page
|
||||
redirect_to :action => 'index', :id => @project, :page => nil and return
|
||||
end
|
||||
render :action => "special_#{page_title}"
|
||||
end
|
||||
|
||||
def preview
|
||||
@text = params[:content][:text]
|
||||
render :partial => 'preview'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_wiki
|
||||
@project = Project.find(params[:id])
|
||||
@wiki = @project.wiki
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
end
|
||||
@@ -1,241 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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.
|
||||
|
||||
module ApplicationHelper
|
||||
|
||||
# Return current logged in user or nil
|
||||
def loggedin?
|
||||
@logged_in_user
|
||||
end
|
||||
|
||||
# Return true if user is logged in and is admin, otherwise false
|
||||
def admin_loggedin?
|
||||
@logged_in_user and @logged_in_user.admin?
|
||||
end
|
||||
|
||||
# Return true if user is authorized for controller/action, otherwise false
|
||||
def authorize_for(controller, action)
|
||||
# check if action is allowed on public projects
|
||||
if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ controller, action ]
|
||||
return true
|
||||
end
|
||||
# check if user is authorized
|
||||
if @logged_in_user and (@logged_in_user.admin? or Permission.allowed_to_role( "%s/%s" % [ controller, action ], @logged_in_user.role_for_project(@project) ) )
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
# Display a link if user is authorized
|
||||
def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller], options[:action])
|
||||
end
|
||||
|
||||
# Display a link to user's account page
|
||||
def link_to_user(user)
|
||||
link_to user.display_name, :controller => 'account', :action => 'show', :id => user
|
||||
end
|
||||
|
||||
def link_to_issue(issue)
|
||||
link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue
|
||||
end
|
||||
|
||||
def toggle_link(name, id, options={})
|
||||
onclick = "Element.toggle('#{id}'); "
|
||||
onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
|
||||
onclick << "return false;"
|
||||
link_to(name, "#", :onclick => onclick)
|
||||
end
|
||||
|
||||
def image_to_function(name, function, html_options = {})
|
||||
html_options.symbolize_keys!
|
||||
tag(:input, html_options.merge({
|
||||
:type => "image", :src => image_path(name),
|
||||
:onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
|
||||
}))
|
||||
end
|
||||
|
||||
def format_date(date)
|
||||
l_date(date) if date
|
||||
end
|
||||
|
||||
def format_time(time)
|
||||
l_datetime((time.is_a? String) ? time.to_time : time) if time
|
||||
end
|
||||
|
||||
def day_name(day)
|
||||
l(:general_day_names).split(',')[day-1]
|
||||
end
|
||||
|
||||
def month_name(month)
|
||||
l(:actionview_datehelper_select_month_names).split(',')[month-1]
|
||||
end
|
||||
|
||||
def pagination_links_full(paginator, options={}, html_options={})
|
||||
html = ''
|
||||
html << link_to_remote(('« ' + l(:label_previous)),
|
||||
{:update => "content", :url => options.merge(:page => paginator.current.previous)},
|
||||
{:href => url_for(:params => options.merge(:page => paginator.current.previous))}) + ' ' if paginator.current.previous
|
||||
|
||||
html << (pagination_links_each(paginator, options) do |n|
|
||||
link_to_remote(n.to_s,
|
||||
{:url => {:params => options.merge(:page => n)}, :update => 'content'},
|
||||
{:href => url_for(:params => options.merge(:page => n))})
|
||||
end || '')
|
||||
|
||||
html << ' ' + link_to_remote((l(:label_next) + ' »'),
|
||||
{:update => "content", :url => options.merge(:page => paginator.current.next)},
|
||||
{:href => url_for(:params => options.merge(:page => paginator.current.next))}) if paginator.current.next
|
||||
html
|
||||
end
|
||||
|
||||
# textilize text according to system settings and RedCloth availability
|
||||
def textilizable(text, options = {})
|
||||
# different methods for formatting wiki links
|
||||
case options[:wiki_links]
|
||||
when :local
|
||||
# used for local links to html files
|
||||
format_wiki_link = Proc.new {|title| "#{title}.html" }
|
||||
when :anchor
|
||||
# used for single-file wiki export
|
||||
format_wiki_link = Proc.new {|title| "##{title}" }
|
||||
else
|
||||
if @project
|
||||
format_wiki_link = Proc.new {|title| url_for :controller => 'wiki', :action => 'index', :id => @project, :page => title }
|
||||
else
|
||||
format_wiki_link = Proc.new {|title| title }
|
||||
end
|
||||
end
|
||||
|
||||
# turn wiki links into textile links:
|
||||
# example:
|
||||
# [[link]] -> "link":link
|
||||
# [[link|title]] -> "title":link
|
||||
text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + format_wiki_link.call(Wiki.titleize($1)) }
|
||||
|
||||
# turn issue ids to textile links
|
||||
# example:
|
||||
# #52 -> "#52":/issues/show/52
|
||||
text = text.gsub(/#(\d+)(?=\b)/) {|m| "\"##{$1}\":" + url_for(:controller => 'issues', :action => 'show', :id => $1) }
|
||||
|
||||
# turn revision ids to textile links (@project needed)
|
||||
# example:
|
||||
# r52 -> "r52":/repositories/revision/6?rev=52 (@project.id is 6)
|
||||
text = text.gsub(/(?=\b)r(\d+)(?=\b)/) {|m| "\"r#{$1}\":" + url_for(:controller => 'repositories', :action => 'revision', :id => @project.id, :rev => $1) } if @project
|
||||
|
||||
# finally textilize text
|
||||
@do_textilize ||= (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize")
|
||||
text = @do_textilize ? auto_link(RedCloth.new(text).to_html) : simple_format(auto_link(h(text)))
|
||||
end
|
||||
|
||||
def error_messages_for(object_name, options = {})
|
||||
options = options.symbolize_keys
|
||||
object = instance_variable_get("@#{object_name}")
|
||||
if object && !object.errors.empty?
|
||||
# build full_messages here with controller current language
|
||||
full_messages = []
|
||||
object.errors.each do |attr, msg|
|
||||
next if msg.nil?
|
||||
msg = msg.first if msg.is_a? Array
|
||||
if attr == "base"
|
||||
full_messages << l(msg)
|
||||
else
|
||||
full_messages << "« " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " » " + l(msg) unless attr == "custom_values"
|
||||
end
|
||||
end
|
||||
# retrieve custom values error messages
|
||||
if object.errors[:custom_values]
|
||||
object.custom_values.each do |v|
|
||||
v.errors.each do |attr, msg|
|
||||
next if msg.nil?
|
||||
msg = msg.first if msg.is_a? Array
|
||||
full_messages << "« " + v.custom_field.name + " » " + l(msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
content_tag("div",
|
||||
content_tag(
|
||||
options[:header_tag] || "h2", lwr(:gui_validation_error, full_messages.length) + " :"
|
||||
) +
|
||||
content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
|
||||
"id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
|
||||
)
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def lang_options_for_select(blank=true)
|
||||
(blank ? [["(auto)", ""]] : []) +
|
||||
(GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]}
|
||||
end
|
||||
|
||||
def label_tag_for(name, option_tags = nil, options = {})
|
||||
label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
|
||||
content_tag("label", label_text)
|
||||
end
|
||||
|
||||
def labelled_tabular_form_for(name, object, options, &proc)
|
||||
options[:html] ||= {}
|
||||
options[:html].store :class, "tabular"
|
||||
form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
|
||||
end
|
||||
|
||||
def check_all_links(form_name)
|
||||
link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
|
||||
" | " +
|
||||
link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
|
||||
end
|
||||
|
||||
def calendar_for(field_id)
|
||||
image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
|
||||
javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
|
||||
end
|
||||
end
|
||||
|
||||
class TabularFormBuilder < ActionView::Helpers::FormBuilder
|
||||
include GLoc
|
||||
|
||||
def initialize(object_name, object, template, options, proc)
|
||||
set_language_if_valid options.delete(:lang)
|
||||
@object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
|
||||
end
|
||||
|
||||
(field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
|
||||
src = <<-END_SRC
|
||||
def #{selector}(field, options = {})
|
||||
return super if options.delete :no_label
|
||||
label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
|
||||
label = @template.content_tag("label", label_text,
|
||||
:class => (@object && @object.errors[field] ? "error" : nil),
|
||||
:for => (@object_name.to_s + "_" + field.to_s))
|
||||
label + super
|
||||
end
|
||||
END_SRC
|
||||
class_eval src, __FILE__, __LINE__
|
||||
end
|
||||
|
||||
def select(field, choices, options = {}, html_options = {})
|
||||
label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
|
||||
label = @template.content_tag("label", label_text,
|
||||
:class => (@object && @object.errors[field] ? "error" : nil),
|
||||
:for => (@object_name.to_s + "_" + field.to_s))
|
||||
label + super
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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.
|
||||
|
||||
module AuthSourcesHelper
|
||||
end
|
||||
@@ -1,77 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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.
|
||||
|
||||
module CustomFieldsHelper
|
||||
|
||||
# Return custom field html tag corresponding to its format
|
||||
def custom_field_tag(custom_value)
|
||||
custom_field = custom_value.custom_field
|
||||
field_name = "custom_fields[#{custom_field.id}]"
|
||||
field_id = "custom_fields_#{custom_field.id}"
|
||||
|
||||
case custom_field.field_format
|
||||
when "string", "int"
|
||||
text_field 'custom_value', 'value', :name => field_name, :id => field_id
|
||||
when "date"
|
||||
text_field('custom_value', 'value', :name => field_name, :id => field_id, :size => 10) +
|
||||
calendar_for(field_id)
|
||||
when "text"
|
||||
text_area 'custom_value', 'value', :name => field_name, :id => field_id, :cols => 60, :rows => 3
|
||||
when "bool"
|
||||
check_box 'custom_value', 'value', :name => field_name, :id => field_id
|
||||
when "list"
|
||||
select 'custom_value', 'value', custom_field.possible_values, { :include_blank => true }, :name => field_name, :id => field_id
|
||||
end
|
||||
end
|
||||
|
||||
# Return custom field label tag
|
||||
def custom_field_label_tag(custom_value)
|
||||
content_tag "label", custom_value.custom_field.name +
|
||||
(custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>" : ""),
|
||||
:for => "custom_fields_#{custom_value.custom_field.id}",
|
||||
:class => (custom_value.errors.empty? ? nil : "error" )
|
||||
end
|
||||
|
||||
# Return custom field tag with its label tag
|
||||
def custom_field_tag_with_label(custom_value)
|
||||
custom_field_label_tag(custom_value) + custom_field_tag(custom_value)
|
||||
end
|
||||
|
||||
# Return a string used to display a custom value
|
||||
def show_value(custom_value)
|
||||
return "" unless custom_value
|
||||
format_value(custom_value.value, custom_value.custom_field.field_format)
|
||||
end
|
||||
|
||||
# Return a string used to display a custom value
|
||||
def format_value(value, field_format)
|
||||
return "" unless value && !value.empty?
|
||||
case field_format
|
||||
when "date"
|
||||
begin; l_date(value.to_date); rescue; value end
|
||||
when "bool"
|
||||
l_YesNo(value == "1")
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
# Return an array of custom field formats which can be used in select_tag
|
||||
def custom_field_formats_for_select
|
||||
CustomField::FIELD_FORMATS.sort {|a,b| a[1][:order]<=>b[1][:order]}.collect { |k| [ l(k[1][:name]), k[0] ] }
|
||||
end
|
||||
end
|
||||
@@ -1,75 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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.
|
||||
|
||||
require 'iconv'
|
||||
require 'rfpdf/chinese'
|
||||
|
||||
module IfpdfHelper
|
||||
|
||||
class IFPDF < FPDF
|
||||
include GLoc
|
||||
attr_accessor :footer_date
|
||||
|
||||
def initialize(lang)
|
||||
super()
|
||||
set_language_if_valid lang
|
||||
case current_language
|
||||
when :ja
|
||||
extend(PDF_Japanese)
|
||||
AddSJISFont()
|
||||
@font_for_content = 'SJIS'
|
||||
@font_for_footer = 'SJIS'
|
||||
when :zh
|
||||
extend(PDF_Chinese)
|
||||
AddBig5Font()
|
||||
@font_for_content = 'Big5'
|
||||
@font_for_footer = 'Big5'
|
||||
else
|
||||
@font_for_content = 'Arial'
|
||||
@font_for_footer = 'Helvetica'
|
||||
end
|
||||
SetCreator("redMine #{Redmine::VERSION}")
|
||||
SetFont(@font_for_content)
|
||||
end
|
||||
|
||||
def SetFontStyle(style, size)
|
||||
SetFont(@font_for_content, style, size)
|
||||
end
|
||||
|
||||
def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
|
||||
@ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
|
||||
txt = begin
|
||||
@ic.iconv(txt)
|
||||
rescue
|
||||
txt
|
||||
end
|
||||
super w,h,txt,border,ln,align,fill,link
|
||||
end
|
||||
|
||||
def Footer
|
||||
SetFont(@font_for_footer, 'I', 8)
|
||||
SetY(-15)
|
||||
SetX(15)
|
||||
Cell(0, 5, @footer_date, 0, 0, 'L')
|
||||
SetY(-15)
|
||||
SetX(-30)
|
||||
Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,86 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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.
|
||||
|
||||
module IssuesHelper
|
||||
|
||||
def show_detail(detail, no_html=false)
|
||||
case detail.property
|
||||
when 'attr'
|
||||
label = l(("field_" + detail.prop_key.to_s.gsub(/\_id$/, "")).to_sym)
|
||||
case detail.prop_key
|
||||
when 'due_date', 'start_date'
|
||||
value = format_date(detail.value.to_date) if detail.value
|
||||
old_value = format_date(detail.old_value.to_date) if detail.old_value
|
||||
when 'status_id'
|
||||
s = IssueStatus.find_by_id(detail.value) and value = s.name if detail.value
|
||||
s = IssueStatus.find_by_id(detail.old_value) and old_value = s.name if detail.old_value
|
||||
when 'assigned_to_id'
|
||||
u = User.find_by_id(detail.value) and value = u.name if detail.value
|
||||
u = User.find_by_id(detail.old_value) and old_value = u.name if detail.old_value
|
||||
when 'priority_id'
|
||||
e = Enumeration.find_by_id(detail.value) and value = e.name if detail.value
|
||||
e = Enumeration.find_by_id(detail.old_value) and old_value = e.name if detail.old_value
|
||||
when 'category_id'
|
||||
c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value
|
||||
c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value
|
||||
when 'fixed_version_id'
|
||||
v = Version.find_by_id(detail.value) and value = v.name if detail.value
|
||||
v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value
|
||||
end
|
||||
when 'cf'
|
||||
custom_field = CustomField.find_by_id(detail.prop_key)
|
||||
if custom_field
|
||||
label = custom_field.name
|
||||
value = format_value(detail.value, custom_field.field_format) if detail.value
|
||||
old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
|
||||
end
|
||||
when 'attachment'
|
||||
label = l(:label_attachment)
|
||||
end
|
||||
|
||||
label ||= detail.prop_key
|
||||
value ||= detail.value
|
||||
old_value ||= detail.old_value
|
||||
|
||||
unless no_html
|
||||
label = content_tag('strong', label)
|
||||
old_value = content_tag("i", h(old_value)) if detail.old_value
|
||||
old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?)
|
||||
value = content_tag("i", h(value)) if value
|
||||
end
|
||||
|
||||
if detail.value and !detail.value.to_s.empty?
|
||||
case detail.property
|
||||
when 'attr', 'cf'
|
||||
if old_value
|
||||
label + " " + l(:text_journal_changed, old_value, value)
|
||||
else
|
||||
label + " " + l(:text_journal_set_to, value)
|
||||
end
|
||||
when 'attachment'
|
||||
"#{label} #{value} #{l(:label_added)}"
|
||||
end
|
||||
else
|
||||
case detail.property
|
||||
when 'attr', 'cf'
|
||||
label + " " + l(:text_journal_deleted) + " (#{old_value})"
|
||||
when 'attachment'
|
||||
"#{label} #{old_value} #{l(:label_deleted)}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,19 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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.
|
||||
|
||||
module MyHelper
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
module QueriesHelper
|
||||
|
||||
def operators_for_select(filter_type)
|
||||
Query.operators_by_filter_type[filter_type].collect {|o| [l(Query.operators[o]), o]}
|
||||
end
|
||||
end
|
||||
@@ -1,19 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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.
|
||||
|
||||
module SettingsHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module TimelogHelper
|
||||
end
|
||||
@@ -1,19 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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.
|
||||
|
||||
module WikiHelper
|
||||
end
|
||||
@@ -1,47 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 AuthSource < ActiveRecord::Base
|
||||
has_many :users
|
||||
|
||||
validates_presence_of :name
|
||||
validates_uniqueness_of :name
|
||||
|
||||
def authenticate(login, password)
|
||||
end
|
||||
|
||||
def test_connection
|
||||
end
|
||||
|
||||
def auth_method_name
|
||||
"Abstract"
|
||||
end
|
||||
|
||||
# Try to authenticate a user not yet registered against available sources
|
||||
def self.authenticate(login, password)
|
||||
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)
|
||||
rescue
|
||||
attrs = nil
|
||||
end
|
||||
return attrs if attrs
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
@@ -1,79 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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.
|
||||
|
||||
require 'net/ldap'
|
||||
require 'iconv'
|
||||
|
||||
class AuthSourceLdap < AuthSource
|
||||
validates_presence_of :host, :port, :attr_login
|
||||
|
||||
def after_initialize
|
||||
self.port = 389 if self.port == 0
|
||||
end
|
||||
|
||||
def authenticate(login, password)
|
||||
attrs = []
|
||||
# get user's DN
|
||||
ldap_con = initialize_ldap_con(self.account, self.account_password)
|
||||
login_filter = Net::LDAP::Filter.eq( self.attr_login, login )
|
||||
object_filter = Net::LDAP::Filter.eq( "objectClass", "*" )
|
||||
dn = String.new
|
||||
ldap_con.search( :base => self.base_dn,
|
||||
:filter => object_filter & login_filter,
|
||||
:attributes=> ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail]) do |entry|
|
||||
dn = entry.dn
|
||||
attrs = [:firstname => AuthSourceLdap.get_attr(entry, self.attr_firstname),
|
||||
:lastname => AuthSourceLdap.get_attr(entry, self.attr_lastname),
|
||||
:mail => AuthSourceLdap.get_attr(entry, self.attr_mail),
|
||||
:auth_source_id => self.id ]
|
||||
end
|
||||
return nil if dn.empty?
|
||||
logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?
|
||||
# authenticate user
|
||||
ldap_con = initialize_ldap_con(dn, password)
|
||||
return nil unless ldap_con.bind
|
||||
# return user's attributes
|
||||
logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
|
||||
attrs
|
||||
rescue Net::LDAP::LdapError => text
|
||||
raise "LdapError: " + text
|
||||
end
|
||||
|
||||
# test the connection to the LDAP
|
||||
def test_connection
|
||||
ldap_con = initialize_ldap_con(self.account, self.account_password)
|
||||
ldap_con.open { }
|
||||
rescue Net::LDAP::LdapError => text
|
||||
raise "LdapError: " + text
|
||||
end
|
||||
|
||||
def auth_method_name
|
||||
"LDAP"
|
||||
end
|
||||
|
||||
private
|
||||
def initialize_ldap_con(ldap_user, ldap_password)
|
||||
Net::LDAP.new( {:host => self.host,
|
||||
:port => self.port,
|
||||
:auth => { :method => :simple, :username => Iconv.new('iso-8859-15', 'utf-8').iconv(ldap_user), :password => Iconv.new('iso-8859-15', 'utf-8').iconv(ldap_password) }}
|
||||
)
|
||||
end
|
||||
|
||||
def self.get_attr(entry, attr_name)
|
||||
entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name]
|
||||
end
|
||||
end
|
||||
@@ -1,22 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 Change < ActiveRecord::Base
|
||||
belongs_to :changeset
|
||||
|
||||
validates_presence_of :changeset_id, :action, :path
|
||||
end
|
||||
@@ -1,30 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 Changeset < ActiveRecord::Base
|
||||
belongs_to :repository
|
||||
has_many :changes, :dependent => :delete_all
|
||||
|
||||
validates_presence_of :repository_id, :revision, :committed_on, :commit_date
|
||||
validates_numericality_of :revision, :only_integer => true
|
||||
validates_uniqueness_of :revision, :scope => :repository_id
|
||||
|
||||
def committed_on=(date)
|
||||
self.commit_date = date
|
||||
super
|
||||
end
|
||||
end
|
||||
@@ -1,60 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 CustomField < ActiveRecord::Base
|
||||
has_many :custom_values, :dependent => :delete_all
|
||||
serialize :possible_values
|
||||
|
||||
FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 },
|
||||
"text" => { :name => :label_text, :order => 2 },
|
||||
"int" => { :name => :label_integer, :order => 3 },
|
||||
"list" => { :name => :label_list, :order => 4 },
|
||||
"date" => { :name => :label_date, :order => 5 },
|
||||
"bool" => { :name => :label_boolean, :order => 6 }
|
||||
}.freeze
|
||||
|
||||
validates_presence_of :name, :field_format
|
||||
validates_uniqueness_of :name
|
||||
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||
validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys
|
||||
|
||||
def initialize(attributes = nil)
|
||||
super
|
||||
self.possible_values ||= []
|
||||
end
|
||||
|
||||
def before_validation
|
||||
# remove empty values
|
||||
self.possible_values = self.possible_values.collect{|v| v unless v.empty?}.compact
|
||||
end
|
||||
|
||||
def validate
|
||||
if self.field_format == "list"
|
||||
errors.add(:possible_values, :activerecord_error_blank) if self.possible_values.nil? || self.possible_values.empty?
|
||||
errors.add(:possible_values, :activerecord_error_invalid) unless self.possible_values.is_a? Array
|
||||
end
|
||||
end
|
||||
|
||||
# to move in project_custom_field
|
||||
def self.for_all
|
||||
find(:all, :conditions => ["is_for_all=?", true])
|
||||
end
|
||||
|
||||
def type_name
|
||||
nil
|
||||
end
|
||||
end
|
||||
@@ -1,38 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 CustomValue < ActiveRecord::Base
|
||||
belongs_to :custom_field
|
||||
belongs_to :customized, :polymorphic => true
|
||||
|
||||
protected
|
||||
def validate
|
||||
errors.add(:value, :activerecord_error_blank) and return if custom_field.is_required? and value.empty?
|
||||
errors.add(:value, :activerecord_error_invalid) unless custom_field.regexp.empty? or value =~ Regexp.new(custom_field.regexp)
|
||||
errors.add(:value, :activerecord_error_too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length and value.length > 0
|
||||
errors.add(:value, :activerecord_error_too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length
|
||||
case custom_field.field_format
|
||||
when "int"
|
||||
errors.add(:value, :activerecord_error_not_a_number) unless value =~ /^[0-9]*$/
|
||||
when "date"
|
||||
errors.add(:value, :activerecord_error_not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/ or value.empty?
|
||||
when "list"
|
||||
errors.add(:value, :activerecord_error_inclusion) unless custom_field.possible_values.include? value or value.empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 Issue < ActiveRecord::Base
|
||||
|
||||
belongs_to :project
|
||||
belongs_to :tracker
|
||||
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id'
|
||||
belongs_to :fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
|
||||
belongs_to :priority, :class_name => 'Enumeration', :foreign_key => 'priority_id'
|
||||
belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id'
|
||||
|
||||
has_many :journals, :as => :journalized, :dependent => :destroy
|
||||
has_many :attachments, :as => :container, :dependent => :destroy
|
||||
has_many :time_entries
|
||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||
has_many :custom_fields, :through => :custom_values
|
||||
|
||||
validates_presence_of :subject, :description, :priority, :tracker, :author, :status
|
||||
validates_inclusion_of :done_ratio, :in => 0..100
|
||||
validates_associated :custom_values, :on => :update
|
||||
|
||||
# set default status for new issues
|
||||
def before_validation
|
||||
self.status = IssueStatus.default if status.nil?
|
||||
end
|
||||
|
||||
def validate
|
||||
if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
|
||||
errors.add :due_date, :activerecord_error_not_a_date
|
||||
end
|
||||
|
||||
if self.due_date and self.start_date and self.due_date < self.start_date
|
||||
errors.add :due_date, :activerecord_error_greater_than_start_date
|
||||
end
|
||||
end
|
||||
|
||||
#def before_create
|
||||
# build_history
|
||||
#end
|
||||
|
||||
def before_save
|
||||
if @current_journal
|
||||
# attributes changes
|
||||
(Issue.column_names - %w(id description)).each {|c|
|
||||
@current_journal.details << JournalDetail.new(:property => 'attr',
|
||||
:prop_key => c,
|
||||
:old_value => @issue_before_change.send(c),
|
||||
:value => send(c)) unless send(c)==@issue_before_change.send(c)
|
||||
}
|
||||
# custom fields changes
|
||||
custom_values.each {|c|
|
||||
@current_journal.details << JournalDetail.new(:property => 'cf',
|
||||
:prop_key => c.custom_field_id,
|
||||
:old_value => @custom_values_before_change[c.custom_field_id],
|
||||
:value => c.value) unless @custom_values_before_change[c.custom_field_id]==c.value
|
||||
}
|
||||
@current_journal.save unless @current_journal.details.empty? and @current_journal.notes.empty?
|
||||
end
|
||||
end
|
||||
|
||||
def long_id
|
||||
"%05d" % self.id
|
||||
end
|
||||
|
||||
def custom_value_for(custom_field)
|
||||
self.custom_values.each {|v| return v if v.custom_field_id == custom_field.id }
|
||||
return nil
|
||||
end
|
||||
|
||||
def init_journal(user, notes = "")
|
||||
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
|
||||
@issue_before_change = self.clone
|
||||
@custom_values_before_change = {}
|
||||
self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
|
||||
@current_journal
|
||||
end
|
||||
|
||||
def spent_hours
|
||||
@spent_hours ||= time_entries.sum(:hours) || 0
|
||||
end
|
||||
|
||||
private
|
||||
# Creates an history for the issue
|
||||
#def build_history
|
||||
# @history = self.histories.build
|
||||
# @history.status = self.status
|
||||
# @history.author = self.author
|
||||
#end
|
||||
end
|
||||
@@ -1,26 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 Journal < ActiveRecord::Base
|
||||
belongs_to :journalized, :polymorphic => true
|
||||
# added as a quick fix to allow eager loading of the polymorphic association
|
||||
# since always associated to an issue, for now
|
||||
belongs_to :issue, :foreign_key => :journalized_id
|
||||
|
||||
belongs_to :user
|
||||
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 JournalDetail < ActiveRecord::Base
|
||||
belongs_to :journal
|
||||
end
|
||||
@@ -1,88 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 Mailer < ActionMailer::Base
|
||||
helper IssuesHelper
|
||||
|
||||
def issue_add(issue)
|
||||
set_language_if_valid(Setting.default_language)
|
||||
# Sends to all project members
|
||||
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
|
||||
@from = Setting.mail_from
|
||||
@subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
|
||||
@body['issue'] = issue
|
||||
end
|
||||
|
||||
def issue_edit(journal)
|
||||
set_language_if_valid(Setting.default_language)
|
||||
# Sends to all project members
|
||||
issue = journal.journalized
|
||||
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
|
||||
@from = Setting.mail_from
|
||||
@subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
|
||||
@body['issue'] = issue
|
||||
@body['journal']= journal
|
||||
end
|
||||
|
||||
def document_add(document)
|
||||
set_language_if_valid(Setting.default_language)
|
||||
@recipients = document.project.users.collect { |u| u.mail if u.mail_notification }.compact
|
||||
@from = Setting.mail_from
|
||||
@subject = "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
|
||||
@body['document'] = document
|
||||
end
|
||||
|
||||
def attachments_add(attachments)
|
||||
set_language_if_valid(Setting.default_language)
|
||||
container = attachments.first.container
|
||||
url = "http://#{Setting.host_name}/"
|
||||
added_to = ""
|
||||
case container.class.to_s
|
||||
when 'Version'
|
||||
url << "projects/list_files/#{container.project_id}"
|
||||
added_to = "#{l(:label_version)}: #{container.name}"
|
||||
when 'Document'
|
||||
url << "documents/show/#{container.id}"
|
||||
added_to = "#{l(:label_document)}: #{container.title}"
|
||||
when 'Issue'
|
||||
url << "issues/show/#{container.id}"
|
||||
added_to = "#{container.tracker.name} ##{container.id}: #{container.subject}"
|
||||
end
|
||||
@recipients = container.project.users.collect { |u| u.mail if u.mail_notification }.compact
|
||||
@from = Setting.mail_from
|
||||
@subject = "[#{container.project.name}] #{l(:label_attachment_new)}"
|
||||
@body['attachments'] = attachments
|
||||
@body['url'] = url
|
||||
@body['added_to'] = added_to
|
||||
end
|
||||
|
||||
def lost_password(token)
|
||||
set_language_if_valid(token.user.language)
|
||||
@recipients = token.user.mail
|
||||
@from = Setting.mail_from
|
||||
@subject = l(:mail_subject_lost_password)
|
||||
@body['token'] = token
|
||||
end
|
||||
|
||||
def register(token)
|
||||
set_language_if_valid(token.user.language)
|
||||
@recipients = token.user.mail
|
||||
@from = Setting.mail_from
|
||||
@subject = l(:mail_subject_register)
|
||||
@body['token'] = token
|
||||
end
|
||||
end
|
||||
@@ -1,94 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 Project < ActiveRecord::Base
|
||||
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
|
||||
has_many :members, :dependent => :delete_all, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}"
|
||||
has_many :users, :through => :members
|
||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||
has_many :issues, :dependent => :destroy, :order => "#{Issue.table_name}.created_on DESC", :include => [:status, :tracker]
|
||||
has_many :time_entries, :dependent => :delete_all
|
||||
has_many :queries, :dependent => :delete_all
|
||||
has_many :documents, :dependent => :destroy
|
||||
has_many :news, :dependent => :delete_all, :include => :author
|
||||
has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name"
|
||||
has_one :repository, :dependent => :destroy
|
||||
has_one :wiki, :dependent => :destroy
|
||||
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
|
||||
acts_as_tree :order => "name", :counter_cache => true
|
||||
|
||||
validates_presence_of :name, :description, :identifier
|
||||
validates_uniqueness_of :name, :identifier
|
||||
validates_associated :custom_values, :on => :update
|
||||
validates_associated :repository, :wiki
|
||||
validates_length_of :name, :maximum => 30
|
||||
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||
validates_length_of :description, :maximum => 255
|
||||
validates_length_of :identifier, :in => 3..12
|
||||
validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
|
||||
|
||||
def identifier=(identifier)
|
||||
super unless identifier_frozen?
|
||||
end
|
||||
|
||||
def identifier_frozen?
|
||||
errors[:identifier].nil? && !(new_record? || identifier.blank?)
|
||||
end
|
||||
|
||||
def issues_with_subprojects(include_subprojects=false)
|
||||
conditions = nil
|
||||
if include_subprojects && children.size > 0
|
||||
ids = [id] + children.collect {|c| c.id}
|
||||
conditions = ["#{Issue.table_name}.project_id IN (#{ids.join(',')})"]
|
||||
else
|
||||
conditions = ["#{Issue.table_name}.project_id = ?", id]
|
||||
end
|
||||
Issue.with_scope :find => { :conditions => conditions } do
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
# returns latest created projects
|
||||
# non public projects will be returned only if user is a member of those
|
||||
def self.latest(user=nil, count=5)
|
||||
find(:all, :limit => count, :conditions => visible_by(user), :order => "created_on DESC")
|
||||
end
|
||||
|
||||
def self.visible_by(user=nil)
|
||||
if user && !user.memberships.empty?
|
||||
return ["#{Project.table_name}.is_public = ? or #{Project.table_name}.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')})", true]
|
||||
else
|
||||
return ["#{Project.table_name}.is_public = ?", true]
|
||||
end
|
||||
end
|
||||
|
||||
# Returns an array of all custom fields enabled for project issues
|
||||
# (explictly associated custom fields and custom fields enabled for all projects)
|
||||
def custom_fields_for_issues(tracker)
|
||||
all_custom_fields.select {|c| tracker.custom_fields.include? c }
|
||||
end
|
||||
|
||||
def all_custom_fields
|
||||
@all_custom_fields ||= (IssueCustomField.for_all + custom_fields).uniq
|
||||
end
|
||||
|
||||
protected
|
||||
def validate
|
||||
errors.add(parent_id, " must be a root project") if parent and parent.parent
|
||||
errors.add_to_base("A project with subprojects can't be a subproject") if parent and children.size > 0
|
||||
end
|
||||
end
|
||||
@@ -1,22 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 ProjectCustomField < CustomField
|
||||
def type_name
|
||||
:label_project_plural
|
||||
end
|
||||
end
|
||||
@@ -1,182 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 Query < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
serialize :filters
|
||||
|
||||
attr_protected :project, :user
|
||||
|
||||
validates_presence_of :name, :on => :save
|
||||
|
||||
@@operators = { "=" => :label_equals,
|
||||
"!" => :label_not_equals,
|
||||
"o" => :label_open_issues,
|
||||
"c" => :label_closed_issues,
|
||||
"!*" => :label_none,
|
||||
"*" => :label_all,
|
||||
"<t+" => :label_in_less_than,
|
||||
">t+" => :label_in_more_than,
|
||||
"t+" => :label_in,
|
||||
"t" => :label_today,
|
||||
">t-" => :label_less_than_ago,
|
||||
"<t-" => :label_more_than_ago,
|
||||
"t-" => :label_ago,
|
||||
"~" => :label_contains,
|
||||
"!~" => :label_not_contains }
|
||||
|
||||
cattr_reader :operators
|
||||
|
||||
@@operators_by_filter_type = { :list => [ "=", "!" ],
|
||||
:list_status => [ "o", "=", "!", "c", "*" ],
|
||||
:list_optional => [ "=", "!", "!*", "*" ],
|
||||
:list_one_or_more => [ "*", "=" ],
|
||||
:date => [ "<t+", ">t+", "t+", "t", ">t-", "<t-", "t-" ],
|
||||
:date_past => [ ">t-", "<t-", "t-", "t" ],
|
||||
:text => [ "~", "!~" ] }
|
||||
|
||||
cattr_reader :operators_by_filter_type
|
||||
|
||||
def initialize(attributes = nil)
|
||||
super attributes
|
||||
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
|
||||
self.is_public = true
|
||||
end
|
||||
|
||||
def validate
|
||||
filters.each_key do |field|
|
||||
errors.add field.gsub(/\_id$/, ""), :activerecord_error_blank unless
|
||||
# filter requires one or more values
|
||||
(values_for(field) and !values_for(field).first.empty?) or
|
||||
# filter doesn't require any value
|
||||
["o", "c", "!*", "*", "t"].include? operator_for(field)
|
||||
end if filters
|
||||
end
|
||||
|
||||
def available_filters
|
||||
return @available_filters if @available_filters
|
||||
@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 => Tracker.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
|
||||
"priority_id" => { :type => :list, :order => 3, :values => Enumeration.find(:all, :conditions => ['opt=?','IPRI']).collect{|s| [s.name, s.id.to_s] } },
|
||||
"subject" => { :type => :text, :order => 8 },
|
||||
"created_on" => { :type => :date_past, :order => 9 },
|
||||
"updated_on" => { :type => :date_past, :order => 10 },
|
||||
"start_date" => { :type => :date, :order => 11 },
|
||||
"due_date" => { :type => :date, :order => 12 } }
|
||||
unless project.nil?
|
||||
# project specific filters
|
||||
@available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => @project.users.collect{|s| [s.name, s.id.to_s] } }
|
||||
@available_filters["author_id"] = { :type => :list, :order => 5, :values => @project.users.collect{|s| [s.name, s.id.to_s] } }
|
||||
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
|
||||
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.collect{|s| [s.name, s.id.to_s] } }
|
||||
unless @project.children.empty?
|
||||
@available_filters["subproject_id"] = { :type => :list_one_or_more, :order => 13, :values => @project.children.collect{|s| [s.name, s.id.to_s] } }
|
||||
end
|
||||
# remove category filter if no category defined
|
||||
@available_filters.delete "category_id" if @available_filters["category_id"][:values].empty?
|
||||
end
|
||||
@available_filters
|
||||
end
|
||||
|
||||
def add_filter(field, operator, values)
|
||||
# values must be an array
|
||||
return unless values and values.is_a? Array # and !values.first.empty?
|
||||
# check if field is defined as an available filter
|
||||
if available_filters.has_key? field
|
||||
filter_options = available_filters[field]
|
||||
# check if operator is allowed for that filter
|
||||
#if @@operators_by_filter_type[filter_options[:type]].include? operator
|
||||
# allowed_values = values & ([""] + (filter_options[:values] || []).collect {|val| val[1]})
|
||||
# filters[field] = {:operator => operator, :values => allowed_values } if (allowed_values.first and !allowed_values.first.empty?) or ["o", "c", "!*", "*", "t"].include? operator
|
||||
#end
|
||||
filters[field] = {:operator => operator, :values => values }
|
||||
end
|
||||
end
|
||||
|
||||
def add_short_filter(field, expression)
|
||||
return unless expression
|
||||
parms = expression.scan(/^(o|c|\!|\*)?(.*)$/).first
|
||||
add_filter field, (parms[0] || "="), [parms[1] || ""]
|
||||
end
|
||||
|
||||
def has_filter?(field)
|
||||
filters and filters[field]
|
||||
end
|
||||
|
||||
def operator_for(field)
|
||||
has_filter?(field) ? filters[field][:operator] : nil
|
||||
end
|
||||
|
||||
def values_for(field)
|
||||
has_filter?(field) ? filters[field][:values] : nil
|
||||
end
|
||||
|
||||
def statement
|
||||
sql = "1=1"
|
||||
if has_filter?("subproject_id")
|
||||
subproject_ids = []
|
||||
if operator_for("subproject_id") == "="
|
||||
subproject_ids = values_for("subproject_id").each(&:to_i)
|
||||
else
|
||||
subproject_ids = project.children.collect{|p| p.id}
|
||||
end
|
||||
sql << " AND #{Issue.table_name}.project_id IN (%d,%s)" % [project.id, subproject_ids.join(",")] if project
|
||||
else
|
||||
sql << " AND #{Issue.table_name}.project_id=%d" % project.id if project
|
||||
end
|
||||
filters.each_key do |field|
|
||||
next if field == "subproject_id"
|
||||
v = values_for field
|
||||
next unless v and !v.empty?
|
||||
sql = sql + " AND " unless sql.empty?
|
||||
case operator_for field
|
||||
when "="
|
||||
sql = sql + "#{Issue.table_name}.#{field} IN (" + v.each(&:to_i).join(",") + ")"
|
||||
when "!"
|
||||
sql = sql + "#{Issue.table_name}.#{field} NOT IN (" + v.each(&:to_i).join(",") + ")"
|
||||
when "!*"
|
||||
sql = sql + "#{Issue.table_name}.#{field} IS NULL"
|
||||
when "*"
|
||||
sql = sql + "#{Issue.table_name}.#{field} IS NOT NULL"
|
||||
when "o"
|
||||
sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id"
|
||||
when "c"
|
||||
sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id"
|
||||
when ">t-"
|
||||
sql = sql + "#{Issue.table_name}.#{field} >= '%s'" % connection.quoted_date(Date.today - v.first.to_i)
|
||||
when "<t-"
|
||||
sql = sql + "#{Issue.table_name}.#{field} <= '" + (Date.today - v.first.to_i).strftime("%Y-%m-%d") + "'"
|
||||
when "t-"
|
||||
sql = sql + "#{Issue.table_name}.#{field} = '" + (Date.today - v.first.to_i).strftime("%Y-%m-%d") + "'"
|
||||
when ">t+"
|
||||
sql = sql + "#{Issue.table_name}.#{field} >= '" + (Date.today + v.first.to_i).strftime("%Y-%m-%d") + "'"
|
||||
when "<t+"
|
||||
sql = sql + "#{Issue.table_name}.#{field} <= '" + (Date.today + v.first.to_i).strftime("%Y-%m-%d") + "'"
|
||||
when "t+"
|
||||
sql = sql + "#{Issue.table_name}.#{field} = '" + (Date.today + v.first.to_i).strftime("%Y-%m-%d") + "'"
|
||||
when "t"
|
||||
sql = sql + "#{Issue.table_name}.#{field} = '%s'" % connection.quoted_date(Date.today)
|
||||
when "~"
|
||||
sql = sql + "#{Issue.table_name}.#{field} LIKE '%#{connection.quote_string(v.first)}%'"
|
||||
when "!~"
|
||||
sql = sql + "#{Issue.table_name}.#{field} NOT LIKE '%#{connection.quote_string(v.first)}%'"
|
||||
end
|
||||
end if filters and valid?
|
||||
sql
|
||||
end
|
||||
end
|
||||
@@ -1,88 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 Repository < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
has_many :changesets, :dependent => :destroy, :order => 'revision DESC'
|
||||
has_many :changes, :through => :changesets
|
||||
has_one :latest_changeset, :class_name => 'Changeset', :foreign_key => :repository_id, :order => 'revision DESC'
|
||||
|
||||
attr_protected :root_url
|
||||
|
||||
validates_presence_of :url
|
||||
validates_format_of :url, :with => /^(http|https|svn|file):\/\/.+/i
|
||||
|
||||
def scm
|
||||
@scm ||= SvnRepos::Base.new url, root_url, login, password
|
||||
update_attribute(:root_url, @scm.root_url) if root_url.blank?
|
||||
@scm
|
||||
end
|
||||
|
||||
def url=(str)
|
||||
super if root_url.blank?
|
||||
end
|
||||
|
||||
def changesets_with_path(path="")
|
||||
path = "/#{path}%"
|
||||
path = url.gsub(/^#{root_url}/, '') + path if root_url && root_url != url
|
||||
path.squeeze!("/")
|
||||
Changeset.with_scope(:find => { :include => :changes, :conditions => ["#{Change.table_name}.path LIKE ?", path] }) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_changesets
|
||||
scm_info = scm.info
|
||||
if scm_info
|
||||
lastrev_identifier = scm_info.lastrev.identifier.to_i
|
||||
if latest_changeset.nil? || latest_changeset.revision < lastrev_identifier
|
||||
logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug?
|
||||
identifier_from = latest_changeset ? latest_changeset.revision + 1 : 1
|
||||
while (identifier_from <= lastrev_identifier)
|
||||
# loads changesets by batches of 200
|
||||
identifier_to = [identifier_from + 199, lastrev_identifier].min
|
||||
revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true)
|
||||
transaction do
|
||||
revisions.reverse_each do |revision|
|
||||
changeset = Changeset.create(:repository => self,
|
||||
:revision => revision.identifier,
|
||||
:committer => revision.author,
|
||||
:committed_on => revision.time,
|
||||
:comment => revision.message)
|
||||
|
||||
revision.paths.each do |change|
|
||||
Change.create(:changeset => changeset,
|
||||
:action => change[:action],
|
||||
:path => change[:path],
|
||||
:from_path => change[:from_path],
|
||||
:from_revision => change[:from_revision])
|
||||
end
|
||||
end
|
||||
end unless revisions.nil?
|
||||
identifier_from = identifier_to + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# fetch new changesets for all repositories
|
||||
# can be called periodically by an external script
|
||||
# eg. ruby script/runner "Repository.fetch_changesets"
|
||||
def self.fetch_changesets
|
||||
find(:all).each(&:fetch_changesets)
|
||||
end
|
||||
end
|
||||
@@ -1,61 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 Setting < ActiveRecord::Base
|
||||
|
||||
cattr_accessor :available_settings
|
||||
@@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml"))
|
||||
|
||||
validates_uniqueness_of :name
|
||||
validates_inclusion_of :name, :in => @@available_settings.keys
|
||||
validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting| @@available_settings[setting.name]['format'] == 'int' }
|
||||
|
||||
def self.get(name)
|
||||
name = name.to_s
|
||||
setting = find_by_name(name)
|
||||
setting ||= new(:name => name, :value => @@available_settings[name]['default']) if @@available_settings.has_key? name
|
||||
setting
|
||||
end
|
||||
|
||||
def self.[](name)
|
||||
get(name).value
|
||||
end
|
||||
|
||||
def self.[]=(name, value)
|
||||
setting = get(name)
|
||||
setting.value = (value ? value.to_s : "")
|
||||
setting.save
|
||||
setting.value
|
||||
end
|
||||
|
||||
@@available_settings.each do |name, params|
|
||||
src = <<-END_SRC
|
||||
def self.#{name}
|
||||
self[:#{name}]
|
||||
end
|
||||
|
||||
def self.#{name}?
|
||||
self[:#{name}].to_s == "1"
|
||||
end
|
||||
|
||||
def self.#{name}=(value)
|
||||
self[:#{name}] = value
|
||||
end
|
||||
END_SRC
|
||||
class_eval src, __FILE__, __LINE__
|
||||
end
|
||||
end
|
||||
@@ -1,431 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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.
|
||||
|
||||
require 'rexml/document'
|
||||
require 'cgi'
|
||||
|
||||
module SvnRepos
|
||||
|
||||
class CommandFailed < StandardError #:nodoc:
|
||||
end
|
||||
|
||||
class Base
|
||||
|
||||
def initialize(url, root_url=nil, login=nil, password=nil)
|
||||
@url = url
|
||||
@login = login if login && !login.empty?
|
||||
@password = (password || "") if @login
|
||||
@root_url = root_url.blank? ? retrieve_root_url : root_url
|
||||
end
|
||||
|
||||
def root_url
|
||||
@root_url
|
||||
end
|
||||
|
||||
def url
|
||||
@url
|
||||
end
|
||||
|
||||
# get info about the svn repository
|
||||
def info
|
||||
cmd = "svn info --xml #{target('')}"
|
||||
cmd << " --username #{@login} --password #{@password}" if @login
|
||||
info = nil
|
||||
shellout(cmd) do |io|
|
||||
begin
|
||||
doc = REXML::Document.new(io)
|
||||
#root_url = doc.elements["info/entry/repository/root"].text
|
||||
info = Info.new({:root_url => doc.elements["info/entry/repository/root"].text,
|
||||
:lastrev => Revision.new({
|
||||
:identifier => doc.elements["info/entry/commit"].attributes['revision'],
|
||||
:time => Time.parse(doc.elements["info/entry/commit/date"].text),
|
||||
:author => (doc.elements["info/entry/commit/author"] ? doc.elements["info/entry/commit/author"].text : "")
|
||||
})
|
||||
})
|
||||
rescue
|
||||
end
|
||||
end
|
||||
return nil if $? && $?.exitstatus != 0
|
||||
info
|
||||
rescue Errno::ENOENT => e
|
||||
return nil
|
||||
end
|
||||
|
||||
# Returns the entry identified by path and revision identifier
|
||||
# or nil if entry doesn't exist in the repository
|
||||
def entry(path=nil, identifier=nil)
|
||||
e = entries(path, identifier)
|
||||
e ? e.first : nil
|
||||
end
|
||||
|
||||
# Returns an Entries collection
|
||||
# or nil if the given path doesn't exist in the repository
|
||||
def entries(path=nil, identifier=nil)
|
||||
path ||= ''
|
||||
identifier = 'HEAD' unless identifier and identifier > 0
|
||||
entries = Entries.new
|
||||
cmd = "svn list --xml #{target(path)}@#{identifier}"
|
||||
cmd << " --username #{@login} --password #{@password}" if @login
|
||||
shellout(cmd) do |io|
|
||||
begin
|
||||
doc = REXML::Document.new(io)
|
||||
doc.elements.each("lists/list/entry") do |entry|
|
||||
entries << Entry.new({:name => entry.elements['name'].text,
|
||||
:path => ((path.empty? ? "" : "#{path}/") + entry.elements['name'].text),
|
||||
:kind => entry.attributes['kind'],
|
||||
:size => (entry.elements['size'] and entry.elements['size'].text).to_i,
|
||||
:lastrev => Revision.new({
|
||||
:identifier => entry.elements['commit'].attributes['revision'],
|
||||
:time => Time.parse(entry.elements['commit'].elements['date'].text),
|
||||
:author => (entry.elements['commit'].elements['author'] ? entry.elements['commit'].elements['author'].text : "")
|
||||
})
|
||||
})
|
||||
end
|
||||
rescue
|
||||
end
|
||||
end
|
||||
return nil if $? && $?.exitstatus != 0
|
||||
entries.sort_by_name
|
||||
rescue Errno::ENOENT => e
|
||||
raise CommandFailed
|
||||
end
|
||||
|
||||
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
|
||||
path ||= ''
|
||||
identifier_from = 'HEAD' unless identifier_from and identifier_from.to_i > 0
|
||||
identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
|
||||
revisions = Revisions.new
|
||||
cmd = "svn log --xml -r #{identifier_from}:#{identifier_to}"
|
||||
cmd << " --username #{@login} --password #{@password}" if @login
|
||||
cmd << " --verbose " if options[:with_paths]
|
||||
cmd << target(path)
|
||||
shellout(cmd) do |io|
|
||||
begin
|
||||
doc = REXML::Document.new(io)
|
||||
doc.elements.each("log/logentry") do |logentry|
|
||||
paths = []
|
||||
logentry.elements.each("paths/path") do |path|
|
||||
paths << {:action => path.attributes['action'],
|
||||
:path => path.text,
|
||||
:from_path => path.attributes['copyfrom-path'],
|
||||
:from_revision => path.attributes['copyfrom-rev']
|
||||
}
|
||||
end
|
||||
paths.sort! { |x,y| x[:path] <=> y[:path] }
|
||||
|
||||
revisions << Revision.new({:identifier => logentry.attributes['revision'],
|
||||
:author => (logentry.elements['author'] ? logentry.elements['author'].text : ""),
|
||||
:time => Time.parse(logentry.elements['date'].text),
|
||||
:message => logentry.elements['msg'].text,
|
||||
:paths => paths
|
||||
})
|
||||
end
|
||||
rescue
|
||||
end
|
||||
end
|
||||
return nil if $? && $?.exitstatus != 0
|
||||
revisions
|
||||
rescue Errno::ENOENT => e
|
||||
raise CommandFailed
|
||||
end
|
||||
|
||||
def diff(path, identifier_from, identifier_to=nil, type="inline")
|
||||
path ||= ''
|
||||
if identifier_to and identifier_to.to_i > 0
|
||||
identifier_to = identifier_to.to_i
|
||||
else
|
||||
identifier_to = identifier_from.to_i - 1
|
||||
end
|
||||
cmd = "svn diff -r "
|
||||
cmd << "#{identifier_to}:"
|
||||
cmd << "#{identifier_from}"
|
||||
cmd << "#{target(path)}@#{identifier_from}"
|
||||
cmd << " --username #{@login} --password #{@password}" if @login
|
||||
diff = []
|
||||
shellout(cmd) do |io|
|
||||
io.each_line do |line|
|
||||
diff << line
|
||||
end
|
||||
end
|
||||
return nil if $? && $?.exitstatus != 0
|
||||
DiffTableList.new diff, type
|
||||
|
||||
rescue Errno::ENOENT => e
|
||||
raise CommandFailed
|
||||
end
|
||||
|
||||
def cat(path, identifier=nil)
|
||||
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
|
||||
cmd = "svn cat #{target(path)}@#{identifier}"
|
||||
cmd << " --username #{@login} --password #{@password}" if @login
|
||||
cat = nil
|
||||
shellout(cmd) do |io|
|
||||
cat = io.read
|
||||
end
|
||||
return nil if $? && $?.exitstatus != 0
|
||||
cat
|
||||
rescue Errno::ENOENT => e
|
||||
raise CommandFailed
|
||||
end
|
||||
|
||||
private
|
||||
def retrieve_root_url
|
||||
info = self.info
|
||||
info ? info.root_url : nil
|
||||
end
|
||||
|
||||
def target(path)
|
||||
path ||= ""
|
||||
base = path.match(/^\//) ? root_url : url
|
||||
" \"" << "#{base}/#{path}".gsub(/["'?<>\*]/, '') << "\""
|
||||
end
|
||||
|
||||
def logger
|
||||
RAILS_DEFAULT_LOGGER
|
||||
end
|
||||
|
||||
def shellout(cmd, &block)
|
||||
logger.debug "Shelling out: #{cmd}" if logger && logger.debug?
|
||||
IO.popen(cmd, "r+") do |io|
|
||||
io.close_write
|
||||
block.call(io) if block_given?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Entries < Array
|
||||
def sort_by_name
|
||||
sort {|x,y|
|
||||
if x.kind == y.kind
|
||||
x.name <=> y.name
|
||||
else
|
||||
x.kind <=> y.kind
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def revisions
|
||||
revisions ||= Revisions.new(collect{|entry| entry.lastrev})
|
||||
end
|
||||
end
|
||||
|
||||
class Info
|
||||
attr_accessor :root_url, :lastrev
|
||||
def initialize(attributes={})
|
||||
self.root_url = attributes[:root_url] if attributes[:root_url]
|
||||
self.lastrev = attributes[:lastrev]
|
||||
end
|
||||
end
|
||||
|
||||
class Entry
|
||||
attr_accessor :name, :path, :kind, :size, :lastrev
|
||||
def initialize(attributes={})
|
||||
self.name = attributes[:name] if attributes[:name]
|
||||
self.path = attributes[:path] if attributes[:path]
|
||||
self.kind = attributes[:kind] if attributes[:kind]
|
||||
self.size = attributes[:size].to_i if attributes[:size]
|
||||
self.lastrev = attributes[:lastrev]
|
||||
end
|
||||
|
||||
def is_file?
|
||||
'file' == self.kind
|
||||
end
|
||||
|
||||
def is_dir?
|
||||
'dir' == self.kind
|
||||
end
|
||||
end
|
||||
|
||||
class Revisions < Array
|
||||
def latest
|
||||
sort {|x,y| x.time <=> y.time}.last
|
||||
end
|
||||
end
|
||||
|
||||
class Revision
|
||||
attr_accessor :identifier, :author, :time, :message, :paths
|
||||
def initialize(attributes={})
|
||||
self.identifier = attributes[:identifier]
|
||||
self.author = attributes[:author]
|
||||
self.time = attributes[:time]
|
||||
self.message = attributes[:message] || ""
|
||||
self.paths = attributes[:paths]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# A line of Diff
|
||||
class Diff
|
||||
|
||||
attr_accessor :nb_line_left
|
||||
attr_accessor :line_left
|
||||
attr_accessor :nb_line_right
|
||||
attr_accessor :line_right
|
||||
attr_accessor :type_diff_right
|
||||
attr_accessor :type_diff_left
|
||||
|
||||
def initialize ()
|
||||
self.nb_line_left = ''
|
||||
self.nb_line_right = ''
|
||||
self.line_left = ''
|
||||
self.line_right = ''
|
||||
self.type_diff_right = ''
|
||||
self.type_diff_left = ''
|
||||
end
|
||||
|
||||
def inspect
|
||||
puts '### Start Line Diff ###'
|
||||
puts self.nb_line_left
|
||||
puts self.line_left
|
||||
puts self.nb_line_right
|
||||
puts self.line_right
|
||||
end
|
||||
end
|
||||
|
||||
class DiffTableList < Array
|
||||
|
||||
def initialize (diff, type="inline")
|
||||
diff_table = DiffTable.new type
|
||||
diff.each do |line|
|
||||
if line =~ /^Index: (.*)$/
|
||||
self << diff_table if diff_table.length > 1
|
||||
diff_table = DiffTable.new type
|
||||
end
|
||||
a = diff_table.add_line line
|
||||
end
|
||||
self << diff_table
|
||||
end
|
||||
end
|
||||
|
||||
# Class for create a Diff
|
||||
class DiffTable < Hash
|
||||
|
||||
attr_reader :file_name, :line_num_l, :line_num_r
|
||||
|
||||
# Initialize with a Diff file and the type of Diff View
|
||||
# The type view must be inline or sbs (side_by_side)
|
||||
def initialize (type="inline")
|
||||
@parsing = false
|
||||
@nb_line = 1
|
||||
@start = false
|
||||
@before = 'same'
|
||||
@second = true
|
||||
@type = type
|
||||
end
|
||||
|
||||
# Function for add a line of this Diff
|
||||
def add_line(line)
|
||||
unless @parsing
|
||||
if line =~ /^Index: (.*)$/
|
||||
@file_name = $1
|
||||
return false
|
||||
elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/
|
||||
@line_num_l = $2.to_i
|
||||
@line_num_r = $5.to_i
|
||||
@parsing = true
|
||||
end
|
||||
else
|
||||
if line =~ /^_+$/
|
||||
self.delete(self.keys.sort.last)
|
||||
@parsing = false
|
||||
return false
|
||||
elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/
|
||||
@line_num_l = $2.to_i
|
||||
@line_num_r = $5.to_i
|
||||
else
|
||||
@nb_line += 1 if parse_line(line, @type)
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def inspect
|
||||
puts '### DIFF TABLE ###'
|
||||
puts "file : #{file_name}"
|
||||
self.each do |d|
|
||||
d.inspect
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Test if is a Side By Side type
|
||||
def sbs?(type, func)
|
||||
if @start and type == "sbs"
|
||||
if @before == func and @second
|
||||
tmp_nb_line = @nb_line
|
||||
self[tmp_nb_line] = Diff.new
|
||||
else
|
||||
@second = false
|
||||
tmp_nb_line = @start
|
||||
@start += 1
|
||||
@nb_line -= 1
|
||||
end
|
||||
else
|
||||
tmp_nb_line = @nb_line
|
||||
@start = @nb_line
|
||||
self[tmp_nb_line] = Diff.new
|
||||
@second = true
|
||||
end
|
||||
unless self[tmp_nb_line]
|
||||
@nb_line += 1
|
||||
self[tmp_nb_line] = Diff.new
|
||||
else
|
||||
self[tmp_nb_line]
|
||||
end
|
||||
end
|
||||
|
||||
# Escape the HTML for the diff
|
||||
def escapeHTML(line)
|
||||
CGI.escapeHTML(line).gsub(/\s/, ' ')
|
||||
end
|
||||
|
||||
def parse_line (line, type="inline")
|
||||
if line[0, 1] == "+"
|
||||
diff = sbs? type, 'add'
|
||||
@before = 'add'
|
||||
diff.line_left = escapeHTML line[1..-1]
|
||||
diff.nb_line_left = @line_num_l
|
||||
diff.type_diff_left = 'diff_in'
|
||||
@line_num_l += 1
|
||||
true
|
||||
elsif line[0, 1] == "-"
|
||||
diff = sbs? type, 'remove'
|
||||
@before = 'remove'
|
||||
diff.line_right = escapeHTML line[1..-1]
|
||||
diff.nb_line_right = @line_num_r
|
||||
diff.type_diff_right = 'diff_out'
|
||||
@line_num_r += 1
|
||||
true
|
||||
elsif line[0, 1] =~ /\s/
|
||||
@before = 'same'
|
||||
@start = false
|
||||
diff = Diff.new
|
||||
diff.line_right = escapeHTML line[1..-1]
|
||||
diff.nb_line_right = @line_num_r
|
||||
diff.line_left = escapeHTML line[1..-1]
|
||||
diff.nb_line_left = @line_num_l
|
||||
self[@nb_line] = diff
|
||||
@line_num_l += 1
|
||||
@line_num_r += 1
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,33 +0,0 @@
|
||||
class TimeEntry < ActiveRecord::Base
|
||||
# could have used polymorphic association
|
||||
# project association here allows easy loading of time entries at project level with one database trip
|
||||
belongs_to :project
|
||||
belongs_to :issue
|
||||
belongs_to :user
|
||||
belongs_to :activity, :class_name => 'Enumeration', :foreign_key => :activity_id
|
||||
|
||||
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
|
||||
|
||||
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
|
||||
validates_numericality_of :hours, :allow_nil => true
|
||||
validates_length_of :comment, :maximum => 255
|
||||
|
||||
def before_validation
|
||||
self.project = issue.project if issue && project.nil?
|
||||
end
|
||||
|
||||
def validate
|
||||
errors.add :hours, :activerecord_error_invalid if hours && (hours < 0 || hours >= 1000)
|
||||
errors.add :project_id, :activerecord_error_invalid if project.nil?
|
||||
errors.add :issue_id, :activerecord_error_invalid if (issue_id && !issue) || (issue && project!=issue.project)
|
||||
end
|
||||
|
||||
# tyear, tmonth, tweek assigned where setting spent_on attributes
|
||||
# these attributes make time aggregations easier
|
||||
def spent_on=(date)
|
||||
super
|
||||
self.tyear = spent_on ? spent_on.year : nil
|
||||
self.tmonth = spent_on ? spent_on.month : nil
|
||||
self.tweek = spent_on ? spent_on.cweek : nil
|
||||
end
|
||||
end
|
||||
@@ -1,44 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 Token < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
@@validity_time = 1.day
|
||||
|
||||
def before_create
|
||||
self.value = Token.generate_token_value
|
||||
end
|
||||
|
||||
# Return true if token has expired
|
||||
def expired?
|
||||
return Time.now > self.created_on + @@validity_time
|
||||
end
|
||||
|
||||
# Delete all expired tokens
|
||||
def self.destroy_expired
|
||||
Token.delete_all ["action <> 'feeds' AND created_on < ?", Time.now - @@validity_time]
|
||||
end
|
||||
|
||||
private
|
||||
def self.generate_token_value
|
||||
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
||||
token_value = ''
|
||||
40.times { |i| token_value << chars[rand(chars.size-1)] }
|
||||
token_value
|
||||
end
|
||||
end
|
||||
@@ -1,154 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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.
|
||||
|
||||
require "digest/sha1"
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :dependent => :delete_all
|
||||
has_many :projects, :through => :memberships
|
||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
|
||||
has_one :rss_key, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'"
|
||||
belongs_to :auth_source
|
||||
|
||||
attr_accessor :password, :password_confirmation
|
||||
attr_accessor :last_before_login_on
|
||||
# Prevents unauthorized assignments
|
||||
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
|
||||
|
||||
validates_presence_of :login, :firstname, :lastname, :mail
|
||||
validates_uniqueness_of :login, :mail
|
||||
# Login must contain lettres, numbers, underscores only
|
||||
validates_format_of :login, :with => /^[a-z0-9_\-@\.]+$/i
|
||||
validates_length_of :login, :maximum => 30
|
||||
validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-]*$/i
|
||||
validates_length_of :firstname, :lastname, :maximum => 30
|
||||
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
||||
validates_length_of :mail, :maximum => 60
|
||||
# Password length between 4 and 12
|
||||
validates_length_of :password, :in => 4..12, :allow_nil => true
|
||||
validates_confirmation_of :password, :allow_nil => true
|
||||
validates_associated :custom_values, :on => :update
|
||||
|
||||
# Account statuses
|
||||
STATUS_ACTIVE = 1
|
||||
STATUS_REGISTERED = 2
|
||||
STATUS_LOCKED = 3
|
||||
|
||||
def before_save
|
||||
# update hashed_password if password was set
|
||||
self.hashed_password = User.hash_password(self.password) if self.password
|
||||
end
|
||||
|
||||
def self.active
|
||||
with_scope :find => { :conditions => [ "status = ?", STATUS_ACTIVE ] } do
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_active(*args)
|
||||
active do
|
||||
find(*args)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the user that matches provided login and password, or nil
|
||||
def self.try_to_login(login, password)
|
||||
user = find(:first, :conditions => ["login=?", login])
|
||||
if user
|
||||
# user is already in local database
|
||||
return nil if !user.active?
|
||||
if user.auth_source
|
||||
# user has an external authentication method
|
||||
return nil unless user.auth_source.authenticate(login, password)
|
||||
else
|
||||
# authentication with local password
|
||||
return nil unless User.hash_password(password) == user.hashed_password
|
||||
end
|
||||
else
|
||||
# user is not yet registered, try to authenticate with available sources
|
||||
attrs = AuthSource.authenticate(login, password)
|
||||
if attrs
|
||||
onthefly = new(*attrs)
|
||||
onthefly.login = login
|
||||
onthefly.language = Setting.default_language
|
||||
if onthefly.save
|
||||
user = find(:first, :conditions => ["login=?", login])
|
||||
logger.info("User '#{user.login}' created on the fly.") if logger
|
||||
end
|
||||
end
|
||||
end
|
||||
user.update_attribute(:last_login_on, Time.now) if user
|
||||
user
|
||||
|
||||
rescue => text
|
||||
raise text
|
||||
end
|
||||
|
||||
# Return user's full name for display
|
||||
def display_name
|
||||
firstname + " " + lastname
|
||||
end
|
||||
|
||||
def name
|
||||
display_name
|
||||
end
|
||||
|
||||
def active?
|
||||
self.status == STATUS_ACTIVE
|
||||
end
|
||||
|
||||
def registered?
|
||||
self.status == STATUS_REGISTERED
|
||||
end
|
||||
|
||||
def locked?
|
||||
self.status == STATUS_LOCKED
|
||||
end
|
||||
|
||||
def check_password?(clear_password)
|
||||
User.hash_password(clear_password) == self.hashed_password
|
||||
end
|
||||
|
||||
def role_for_project(project)
|
||||
member = memberships.detect {|m| m.project_id == project.id}
|
||||
member ? member.role : nil
|
||||
end
|
||||
|
||||
def pref
|
||||
self.preference ||= UserPreference.new(:user => self)
|
||||
end
|
||||
|
||||
def get_or_create_rss_key
|
||||
self.rss_key || Token.create(:user => self, :action => 'feeds')
|
||||
end
|
||||
|
||||
def self.find_by_rss_key(key)
|
||||
token = Token.find_by_value(key)
|
||||
token && token.user.active? ? token.user : nil
|
||||
end
|
||||
|
||||
def <=>(user)
|
||||
lastname <=> user.lastname
|
||||
end
|
||||
|
||||
private
|
||||
# Return password digest
|
||||
def self.hash_password(clear_password)
|
||||
Digest::SHA1.hexdigest(clear_password || "")
|
||||
end
|
||||
end
|
||||
@@ -1,23 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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 UserCustomField < CustomField
|
||||
def type_name
|
||||
:label_user_plural
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 Wiki < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
has_many :pages, :class_name => 'WikiPage', :dependent => :destroy
|
||||
|
||||
validates_presence_of :start_page
|
||||
|
||||
# find the page with the given title
|
||||
# if page doesn't exist, return a new page
|
||||
def find_or_new_page(title)
|
||||
title = Wiki.titleize(title || start_page)
|
||||
find_page(title) || WikiPage.new(:wiki => self, :title => title)
|
||||
end
|
||||
|
||||
# find the page with the given title
|
||||
def find_page(title)
|
||||
pages.find_by_title(Wiki.titleize(title || start_page))
|
||||
end
|
||||
|
||||
# turn a string into a valid page title
|
||||
def self.titleize(title)
|
||||
# replace spaces with _ and remove unwanted caracters
|
||||
title = title.gsub(/\s+/, '_').delete(',;|') if title
|
||||
# upcase the first letter
|
||||
title = title[0..0].upcase + title[1..-1] if title
|
||||
title
|
||||
end
|
||||
end
|
||||
@@ -1,58 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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.
|
||||
|
||||
require 'zlib'
|
||||
|
||||
class WikiContent < ActiveRecord::Base
|
||||
belongs_to :page, :class_name => 'WikiPage', :foreign_key => 'page_id'
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
validates_presence_of :text
|
||||
|
||||
acts_as_versioned
|
||||
class Version
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
attr_protected :data
|
||||
|
||||
def text=(plain)
|
||||
case Setting.wiki_compression
|
||||
when 'gzip'
|
||||
begin
|
||||
self.data = Zlib::Deflate.deflate(plain, Zlib::BEST_COMPRESSION)
|
||||
self.compression = 'gzip'
|
||||
rescue
|
||||
self.data = plain
|
||||
self.compression = ''
|
||||
end
|
||||
else
|
||||
self.data = plain
|
||||
self.compression = ''
|
||||
end
|
||||
plain
|
||||
end
|
||||
|
||||
def text
|
||||
@text ||= case compression
|
||||
when 'gzip'
|
||||
Zlib::Inflate.inflate(data)
|
||||
else
|
||||
# uncompressed data
|
||||
data
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,44 +0,0 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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 WikiPage < ActiveRecord::Base
|
||||
belongs_to :wiki
|
||||
has_one :content, :class_name => 'WikiContent', :foreign_key => 'page_id', :dependent => :destroy
|
||||
|
||||
validates_presence_of :title
|
||||
validates_format_of :title, :with => /^[^,\s]*$/
|
||||
validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false
|
||||
validates_associated :content
|
||||
|
||||
def before_save
|
||||
self.title = Wiki.titleize(title)
|
||||
end
|
||||
|
||||
def pretty_title
|
||||
WikiPage.pretty_title(title)
|
||||
end
|
||||
|
||||
def content_for_version(version=nil)
|
||||
result = content.versions.find_by_version(version.to_i) if version
|
||||
result ||= content
|
||||
result
|
||||
end
|
||||
|
||||
def self.pretty_title(str)
|
||||
(str && str.is_a?(String)) ? str.tr('_', ' ') : str
|
||||
end
|
||||
end
|
||||
@@ -1,24 +0,0 @@
|
||||
<center>
|
||||
<div class="box login">
|
||||
<h2 class="icon22 icon22-authent"><%=l(:label_please_login)%></h2>
|
||||
|
||||
<% form_tag({:action=> "login"}, :class => "tabular") do %>
|
||||
<p><label for="login"><%=l(:field_login)%>:</label>
|
||||
<%= text_field_tag 'login', nil, :size => 25 %></p>
|
||||
|
||||
<p><label for="password"><%=l(:field_password)%>:</label>
|
||||
<%= password_field_tag 'password', nil, :size => 25 %></p>
|
||||
|
||||
<p><center><input type="submit" name="login" value="<%=l(:button_login)%> »" class="primary" /></center>
|
||||
<% end %>
|
||||
|
||||
<br>
|
||||
<% links = []
|
||||
links << link_to(l(:label_register), :action => 'register') if Setting.self_registration?
|
||||
links << link_to(l(:label_password_lost), :action => 'lost_password') if Setting.lost_password?
|
||||
%>
|
||||
<%= links.join(" | ") %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</center>
|
||||
@@ -1,14 +0,0 @@
|
||||
<center>
|
||||
<div class="box login">
|
||||
<h2><%=l(:label_password_lost)%></h2>
|
||||
|
||||
<% 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 %></p>
|
||||
|
||||
<p><center><%= submit_tag l(:button_submit) %></center></p>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
</center>
|
||||
@@ -1,22 +0,0 @@
|
||||
<center>
|
||||
<div class="box login">
|
||||
<h2><%=l(:label_password_lost)%></h2>
|
||||
|
||||
<p><%=l(:field_login)%>: <strong><%= @user.login %></strong><br />
|
||||
|
||||
<%= error_messages_for 'user' %>
|
||||
|
||||
<% form_tag({:token => @token.value}, :class => "tabular") do %>
|
||||
|
||||
<p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'new_password', nil, :size => 25 %><br />
|
||||
<em><%= l(:text_length_between, 4, 12) %></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>
|
||||
|
||||
<p><center><%= submit_tag l(:button_save) %></center></p>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</center>
|
||||
@@ -1,46 +0,0 @@
|
||||
<h2><%=l(:label_register)%></h2>
|
||||
|
||||
<% form_tag({:action => 'register'}, :class => "tabular") do %>
|
||||
<%= error_messages_for 'user' %>
|
||||
|
||||
<div class="box">
|
||||
<!--[form:user]-->
|
||||
<p><label for="user_login"><%=l(:field_login)%> <span class="required">*</span></label>
|
||||
<%= text_field 'user', 'login', :size => 25 %></p>
|
||||
|
||||
<p><label for="password"><%=l(:field_password)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'password', nil, :size => 25 %></p>
|
||||
|
||||
<p><label for="password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
|
||||
<%= password_field_tag 'password_confirmation', nil, :size => 25 %></p>
|
||||
|
||||
<p><label for="user_firstname"><%=l(:field_firstname)%> <span class="required">*</span></label>
|
||||
<%= text_field 'user', 'firstname' %></p>
|
||||
|
||||
<p><label for="user_lastname"><%=l(:field_lastname)%> <span class="required">*</span></label>
|
||||
<%= text_field 'user', 'lastname' %></p>
|
||||
|
||||
<p><label for="user_mail"><%=l(:field_mail)%> <span class="required">*</span></label>
|
||||
<%= text_field 'user', 'mail' %></p>
|
||||
|
||||
<p><label for="user_language"><%=l(:field_language)%></label>
|
||||
<%= select("user", "language", lang_options_for_select) %></p>
|
||||
|
||||
<% for @custom_value in @custom_values %>
|
||||
<p><%= custom_field_tag_with_label @custom_value %></p>
|
||||
<% end %>
|
||||
|
||||
<p><label for="user_mail_notification"><%=l(:field_mail_notification)%></label>
|
||||
<%= check_box 'user', 'mail_notification' %></p>
|
||||
<!--[eoform:user]-->
|
||||
</div>
|
||||
|
||||
<%= submit_tag l(:button_submit) %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'calendar/calendar' %>
|
||||
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
|
||||
<%= javascript_include_tag 'calendar/calendar-setup' %>
|
||||
<%= stylesheet_link_tag 'calendar' %>
|
||||
<% end %>
|
||||
@@ -1,26 +0,0 @@
|
||||
<h2><%= @user.display_name %></h2>
|
||||
|
||||
<p>
|
||||
<%= mail_to @user.mail unless @user.pref.hide_mail %>
|
||||
<ul>
|
||||
<li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
|
||||
<% for custom_value in @custom_values %>
|
||||
<% if !custom_value.value.empty? %>
|
||||
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h3><%=l(:label_project_plural)%></h3>
|
||||
<p>
|
||||
<% for membership in @user.memberships %>
|
||||
<%= membership.project.name %> (<%= membership.role.name %>, <%= format_date(membership.created_on) %>)
|
||||
<br />
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<h3><%=l(:label_activity)%></h3>
|
||||
<p>
|
||||
<%=l(:label_reported_issues)%>: <%= Issue.count(["author_id=?", @user.id]) %>
|
||||
</p>
|
||||
@@ -1,25 +0,0 @@
|
||||
<div id="menuAdmin" class="menu" onmouseover="menuMouseover(event)">
|
||||
<a class="menuItem" href="#" onmouseover="menuItemMouseover(event,'menuProjects');" onclick="this.blur(); return false;"><span class="menuItemText"><%=l(:label_project_plural)%></span><span class="menuItemArrow">▶</span></a>
|
||||
<a class="menuItem" href="#" onmouseover="menuItemMouseover(event,'menuUsers');" onclick="this.blur(); return false;"><span class="menuItemText"><%=l(:label_user_plural)%></span><span class="menuItemArrow">▶</span></a>
|
||||
<%= link_to l(:label_role_and_permissions), {:controller => 'roles' }, :class => "menuItem" %>
|
||||
<a class="menuItem" href="#" onmouseover="menuItemMouseover(event,'menuTrackers');" onclick="this.blur(); return false;"><span class="menuItemText"><%=l(:label_issue_tracking)%></span><span class="menuItemArrow">▶</span></a>
|
||||
<%= link_to l(:label_custom_field_plural), {:controller => 'custom_fields' }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_enumerations), {:controller => 'enumerations' }, :class => "menuItem" %>
|
||||
<%= link_to l(:field_mail_notification), {:controller => 'admin', :action => 'mail_options' }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_authentication), {:controller => 'auth_sources' }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_settings), {:controller => 'settings' }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_information_plural), {:controller => 'admin', :action => 'info' }, :class => "menuItem" %>
|
||||
</div>
|
||||
<div id="menuTrackers" class="menu">
|
||||
<%= link_to l(:label_tracker_plural), {:controller => 'trackers' }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_issue_status_plural), {:controller => 'issue_statuses' }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_workflow), {:controller => 'roles', :action => 'workflow' }, :class => "menuItem" %>
|
||||
</div>
|
||||
<div id="menuProjects" class="menu">
|
||||
<%= link_to l(:button_list), {:controller => 'admin', :action => 'projects' }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_new), {:controller => 'projects', :action => 'add' }, :class => "menuItem" %>
|
||||
</div>
|
||||
<div id="menuUsers" class="menu">
|
||||
<%= link_to l(:button_list), {:controller => 'users' }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_new), {:controller => 'users', :action => 'add' }, :class => "menuItem" %>
|
||||
</div>
|
||||
@@ -1,45 +0,0 @@
|
||||
<h2><%=l(:label_administration)%></h2>
|
||||
|
||||
<p class="icon22 icon22-projects">
|
||||
<%= link_to l(:label_project_plural), :controller => 'admin', :action => 'projects' %> |
|
||||
<%= link_to l(:label_new), :controller => 'projects', :action => 'add' %>
|
||||
</p>
|
||||
|
||||
<p class="icon22 icon22-users">
|
||||
<%= link_to l(:label_user_plural), :controller => 'users' %> |
|
||||
<%= link_to l(:label_new), :controller => 'users', :action => 'add' %>
|
||||
</p>
|
||||
|
||||
<p class="icon22 icon22-role">
|
||||
<%= link_to l(:label_role_and_permissions), :controller => 'roles' %>
|
||||
</p>
|
||||
|
||||
<p class="icon22 icon22-tracker">
|
||||
<%= link_to l(:label_tracker_plural), :controller => 'trackers' %> |
|
||||
<%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses' %> |
|
||||
<%= link_to l(:label_workflow), :controller => 'roles', :action => 'workflow' %>
|
||||
</p>
|
||||
|
||||
<p class="icon22 icon22-workflow">
|
||||
<%= link_to l(:label_custom_field_plural), :controller => 'custom_fields' %>
|
||||
</p>
|
||||
|
||||
<p class="icon22 icon22-options">
|
||||
<%= link_to l(:label_enumerations), :controller => 'enumerations' %>
|
||||
</p>
|
||||
|
||||
<p class="icon22 icon22-notifications">
|
||||
<%= link_to l(:field_mail_notification), :controller => 'admin', :action => 'mail_options' %>
|
||||
</p>
|
||||
|
||||
<p class="icon22 icon22-authent">
|
||||
<%= link_to l(:label_authentication), :controller => 'auth_sources' %>
|
||||
</p>
|
||||
|
||||
<p class="icon22 icon22-settings">
|
||||
<%= link_to l(:label_settings), :controller => 'settings' %>
|
||||
</p>
|
||||
|
||||
<p class="icon22 icon22-info">
|
||||
<%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>
|
||||
</p>
|
||||
@@ -1,9 +0,0 @@
|
||||
<h2><%=l(:label_information_plural)%></h2>
|
||||
|
||||
<p><%=l(:field_version)%>: <strong>redMine <%= Redmine::VERSION %></strong> (<%= @db_adapter_name %>)</p>
|
||||
|
||||
<table class="list">
|
||||
<tr class="odd"><td>File repository writable</td><td><%= image_tag (@flags[:file_repository_writable] ? 'true.png' : 'false.png'), :style => "vertical-align:bottom;" %></td></tr>
|
||||
<tr class="even"><td>Default administrator account changed</td><td><%= image_tag (@flags[:default_admin_changed] ? 'true.png' : 'false.png'), :style => "vertical-align:bottom;" %></td></tr>
|
||||
<tr class="odd"><td>Textile available</td><td><%= image_tag (@flags[:textile_available] ? 'true.png' : 'false.png'), :style => "vertical-align:bottom;" %></td></tr>
|
||||
</table>
|
||||
@@ -1,25 +0,0 @@
|
||||
<h2><%=l(:field_mail_notification)%></h2>
|
||||
|
||||
<% form_tag({:action => 'mail_options'}, :id => 'mail_options_form') do %>
|
||||
|
||||
<div class="box">
|
||||
<p><%=l(:text_select_mail_notifications)%></p>
|
||||
|
||||
<% actions = @actions.group_by {|p| p.group_id } %>
|
||||
<% actions.keys.sort.each do |group_id| %>
|
||||
<fieldset style="margin-top: 6px;"><legend><strong><%= l(Permission::GROUPS[group_id]) %></strong></legend>
|
||||
<% actions[group_id].each do |p| %>
|
||||
<div style="width:170px;float:left;"><%= check_box_tag "action_ids[]", p.id, p.mail_enabled? %>
|
||||
<%= l(p.description.to_sym) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="clear"></div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
<br />
|
||||
<p><%= check_all_links('mail_options_form') %></p>
|
||||
</div>
|
||||
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
@@ -1,33 +0,0 @@
|
||||
<div class="contextual">
|
||||
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'add'}, :class => 'icon icon-add' %>
|
||||
</div>
|
||||
|
||||
<h2><%=l(:label_project_plural)%></h2>
|
||||
|
||||
<table class="list">
|
||||
<thead><tr>
|
||||
<%= sort_header_tag('name', :caption => l(:label_project)) %>
|
||||
<th><%=l(:field_description)%></th>
|
||||
<th><%=l(:field_is_public)%></th>
|
||||
<th><%=l(:label_subproject_plural)%></th>
|
||||
<%= sort_header_tag('created_on', :caption => l(:field_created_on)) %>
|
||||
<th></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% for project in @projects %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td><%= link_to project.name, :controller => 'projects', :action => 'settings', :id => project %>
|
||||
<td><%=h project.description %>
|
||||
<td align="center"><%= image_tag 'true.png' if project.is_public? %>
|
||||
<td align="center"><%= project.children.size %>
|
||||
<td align="center"><%= format_date(project.created_on) %>
|
||||
<td align="center">
|
||||
<%= button_to l(:button_delete), { :controller => 'projects', :action => 'destroy', :id => project }, :class => "button-small" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><%= pagination_links_full @project_pages %>
|
||||
[ <%= @project_pages.current.first_item %> - <%= @project_pages.current.last_item %> / <%= @project_count %> ]</p>
|
||||
@@ -1,45 +0,0 @@
|
||||
<%= error_messages_for 'auth_source' %>
|
||||
|
||||
<div class="box">
|
||||
<!--[form:auth_source]-->
|
||||
<p><label for="auth_source_name"><%=l(:field_name)%> <span class="required">*</span></label>
|
||||
<%= text_field 'auth_source', 'name' %></p>
|
||||
|
||||
<p><label for="auth_source_host"><%=l(:field_host)%> <span class="required">*</span></label>
|
||||
<%= text_field 'auth_source', 'host' %></p>
|
||||
|
||||
<p><label for="auth_source_port"><%=l(:field_port)%> <span class="required">*</span></label>
|
||||
<%= text_field 'auth_source', 'port', :size => 6 %></p>
|
||||
|
||||
<p><label for="auth_source_account"><%=l(:field_account)%></label>
|
||||
<%= text_field 'auth_source', 'account' %></p>
|
||||
|
||||
<p><label for="auth_source_account_password"><%=l(:field_password)%></label>
|
||||
<%= password_field 'auth_source', 'account_password' %></p>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<p><label for="auth_source_onthefly_register"><%=l(:field_onthefly)%></label>
|
||||
<%= check_box 'auth_source', 'onthefly_register' %></p>
|
||||
|
||||
<p>
|
||||
<fieldset><legend><%=l(:label_attribute_plural)%></legend>
|
||||
<p><label for="auth_source_attr_login"><%=l(:field_login)%> <span class="required">*</span></label>
|
||||
<%= text_field 'auth_source', 'attr_login', :size => 20 %></p>
|
||||
|
||||
<p><label for="auth_source_attr_firstname"><%=l(:field_firstname)%></label>
|
||||
<%= text_field 'auth_source', 'attr_firstname', :size => 20 %></p>
|
||||
|
||||
<p><label for="auth_source_attr_lastname"><%=l(:field_lastname)%></label>
|
||||
<%= text_field 'auth_source', 'attr_lastname', :size => 20 %></p>
|
||||
|
||||
<p><label for="auth_source_attr_mail"><%=l(:field_mail)%></label>
|
||||
<%= text_field 'auth_source', 'attr_mail', :size => 20 %></p>
|
||||
</fieldset>
|
||||
</p>
|
||||
</div>
|
||||
<!--[eoform:auth_source]-->
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<h2><%=l(:label_auth_source)%> (<%= @auth_source.auth_method_name %>)</h2>
|
||||
|
||||
<% form_tag({:action => 'update', :id => @auth_source}, :class => "tabular") do %>
|
||||
<%= render :partial => 'form' %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<div class="contextual">
|
||||
<%= link_to l(:label_auth_source_new), {:action => 'new'}, :class => 'icon icon-add' %>
|
||||
</div>
|
||||
|
||||
<h2><%=l(:label_auth_source_plural)%></h2>
|
||||
|
||||
<table class="list">
|
||||
<thead><tr>
|
||||
<th><%=l(:field_name)%></th>
|
||||
<th><%=l(:field_type)%></th>
|
||||
<th><%=l(:field_host)%></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% for source in @auth_sources %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td><%= link_to source.name, :action => 'edit', :id => source%></td>
|
||||
<td align="center"><%= source.auth_method_name %></td>
|
||||
<td align="center"><%= source.host %></td>
|
||||
<td align="center"><%= link_to l(:button_test), :action => 'test_connection', :id => source %></td>
|
||||
<td align="center"><%= button_to l(:button_delete), { :action => 'destroy', :id => source }, :confirm => l(:text_are_you_sure), :class => "button-small" %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= pagination_links_full @auth_source_pages %>
|
||||
@@ -1,6 +0,0 @@
|
||||
<h2><%=l(:label_auth_source_new)%> (<%= @auth_source.auth_method_name %>)</h2>
|
||||
|
||||
<% form_tag({:action => 'create'}, :class => "tabular") do %>
|
||||
<%= render :partial => 'form' %>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<% end %>
|
||||
@@ -1,4 +0,0 @@
|
||||
<h2>404</h2>
|
||||
|
||||
<p><%= l(:notice_file_not_found) %></p>
|
||||
<p><a href="javascript:history.back()">Back</a></p>
|
||||
@@ -1,95 +0,0 @@
|
||||
<%= 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");
|
||||
switch (format.value) {
|
||||
case "list":
|
||||
Element.hide(p_length.parentNode);
|
||||
Element.hide(p_regexp.parentNode);
|
||||
Element.show(p_values);
|
||||
break;
|
||||
case "int":
|
||||
case "string":
|
||||
case "text":
|
||||
Element.show(p_length.parentNode);
|
||||
Element.show(p_regexp.parentNode);
|
||||
Element.hide(p_values);
|
||||
break;
|
||||
case "date":
|
||||
case "bool":
|
||||
Element.hide(p_length.parentNode);
|
||||
Element.hide(p_regexp.parentNode);
|
||||
Element.hide(p_values);
|
||||
break;
|
||||
default:
|
||||
Element.show(p_length.parentNode);
|
||||
Element.show(p_regexp.parentNode);
|
||||
Element.show(p_values);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function addValueField() {
|
||||
var f = $$('p#custom_field_possible_values span');
|
||||
p = document.getElementById("custom_field_possible_values");
|
||||
var v = f[0].cloneNode(true);
|
||||
v.childNodes[0].value = "";
|
||||
p.appendChild(v);
|
||||
}
|
||||
|
||||
function deleteValueField(e) {
|
||||
var f = $$('p#custom_field_possible_values span');
|
||||
if (f.length == 1) {
|
||||
e.parentNode.childNodes[0].value = "";
|
||||
} else {
|
||||
Element.remove(e.parentNode);
|
||||
}
|
||||
}
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<!--[form:custom_field]-->
|
||||
<div class="box">
|
||||
<p><%= f.text_field :name, :required => true %></p>
|
||||
<p><%= f.select :field_format, custom_field_formats_for_select, {}, :onchange => "toggle_custom_field_format();" %></p>
|
||||
<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>
|
||||
<p id="custom_field_possible_values"><label><%= l(:field_possible_values) %> <%= image_to_function "add.png", "addValueField();return false" %></label>
|
||||
<% (@custom_field.possible_values.to_a + [""]).each do |value| %>
|
||||
<span><%= text_field_tag 'custom_field[possible_values][]', value, :size => 30 %> <%= image_to_function "delete.png", "deleteValueField(this);return false" %><br /></span>
|
||||
<% end %>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
<%= javascript_tag "toggle_custom_field_format();" %>
|
||||
<!--[eoform:custom_field]-->
|
||||
|
||||
<div class="box">
|
||||
<% case @custom_field.type.to_s
|
||||
when "IssueCustomField" %>
|
||||
|
||||
<fieldset><legend><%=l(:label_tracker_plural)%></legend>
|
||||
<% for tracker in @trackers %>
|
||||
<%= check_box_tag "tracker_ids[]", tracker.id, (@custom_field.trackers.include? tracker) %> <%= tracker.name %>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
|
||||
<p><%= f.check_box :is_required %></p>
|
||||
<p><%= f.check_box :is_for_all %></p>
|
||||
|
||||
<% when "UserCustomField" %>
|
||||
<p><%= f.check_box :is_required %></p>
|
||||
|
||||
<% when "ProjectCustomField" %>
|
||||
<p><%= f.check_box :is_required %></p>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -1,6 +0,0 @@
|
||||
<h2><%=l(:label_custom_field)%> (<%=l(@custom_field.type_name)%>)</h2>
|
||||
|
||||
<% labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "edit", :id => @custom_field } do |f| %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
@@ -1,46 +0,0 @@
|
||||
<h2><%=l(:label_custom_field_plural)%></h2>
|
||||
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li><%= link_to l(:label_issue_plural), {}, :id=> "tab-IssueCustomField", :onclick => "showTab('IssueCustomField'); this.blur(); return false;" %></li>
|
||||
<li><%= link_to l(:label_project_plural), {}, :id=> "tab-ProjectCustomField", :onclick => "showTab('ProjectCustomField'); this.blur(); return false;" %></li>
|
||||
<li><%= link_to l(:label_user_plural), {}, :id=> "tab-UserCustomField", :onclick => "showTab('UserCustomField'); this.blur(); return false;" %></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% %w(IssueCustomField ProjectCustomField UserCustomField).each do |type| %>
|
||||
<div id="tab-content-<%= type %>" class="tab-content">
|
||||
<table class="list">
|
||||
<thead><tr>
|
||||
<th width="30%"><%=l(:field_name)%></th>
|
||||
<th><%=l(:field_field_format)%></th>
|
||||
<th><%=l(:field_is_required)%></th>
|
||||
<% if type == 'IssueCustomField' %>
|
||||
<th><%=l(:field_is_for_all)%></th>
|
||||
<th><%=l(:label_used_by)%></th>
|
||||
<% end %>
|
||||
<th width="10%"></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% for custom_field in (@custom_fields_by_type[type] || []) %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>
|
||||
<td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %></td>
|
||||
<td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td>
|
||||
<% if type == 'IssueCustomField' %>
|
||||
<td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
|
||||
<td align="center"><%= custom_field.projects.count.to_s + ' ' + lwr(:label_project, custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
|
||||
<% end %>
|
||||
<td align="center">
|
||||
<%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end; reset_cycle %>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
<%= link_to l(:label_custom_field_new), {:action => 'new', :type => type}, :class => 'icon icon-add' %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= javascript_tag "showTab('#{@tab}');" %>
|
||||
@@ -1,7 +0,0 @@
|
||||
<h2><%=l(:label_custom_field_new)%> (<%=l(@custom_field.type_name)%>)</h2>
|
||||
|
||||
<% labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "new" } do |f| %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
<%= hidden_field_tag 'type', @custom_field.type %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
@@ -1,3 +0,0 @@
|
||||
<p><%= link_to h(document.title), :controller => 'documents', :action => 'show', :id => document %><br />
|
||||
<% unless document.description.empty? %><%=h(truncate(document.description, 250)) %><br /><% end %>
|
||||
<em><%= format_time(document.created_on) %></em></p>
|
||||
@@ -1,29 +0,0 @@
|
||||
<%= error_messages_for 'document' %>
|
||||
<div class="box">
|
||||
<!--[form:document]-->
|
||||
<p><label for="document_category_id"><%=l(:field_category)%></label>
|
||||
<select name="document[category_id]">
|
||||
<%= options_from_collection_for_select @categories, "id", "name", @document.category_id %>
|
||||
</select></p>
|
||||
|
||||
<p><label for="document_title"><%=l(:field_title)%> <span class="required">*</span></label>
|
||||
<%= text_field 'document', 'title', :size => 60 %></p>
|
||||
|
||||
<p><label for="document_description"><%=l(:field_description)%></label>
|
||||
<%= text_area 'document', 'description', :cols => 60, :rows => 15, :class => 'wiki-edit' %></p>
|
||||
<!--[eoform:document]-->
|
||||
</div>
|
||||
|
||||
<% if Setting.text_formatting == 'textile' %>
|
||||
<%= javascript_include_tag 'jstoolbar' %>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
if (document.getElementById) {
|
||||
if (document.getElementById('document_description')) {
|
||||
var commentTb = new jsToolBar(document.getElementById('document_description'));
|
||||
commentTb.draw();
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<% end %>
|
||||
@@ -1,8 +0,0 @@
|
||||
<h2><%=l(:label_document)%></h2>
|
||||
|
||||
<% form_tag({:action => 'edit', :id => @document}, :class => "tabular") do %>
|
||||
<%= render :partial => 'form' %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<div class="contextual">
|
||||
<%= link_to_if_authorized l(:button_edit), {:controller => 'documents', :action => 'edit', :id => @document}, :class => 'icon icon-edit' %>
|
||||
<%= link_to_if_authorized l(:button_delete), {:controller => 'documents', :action => 'destroy', :id => @document}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
|
||||
</div>
|
||||
|
||||
<h2><%= @document.title %></h2>
|
||||
|
||||
<p><em><%= @document.category.name %><br />
|
||||
<%= format_date @document.created_on %></em></p>
|
||||
<%= textilizable @document.description %>
|
||||
<br />
|
||||
|
||||
<h3><%= l(:label_attachment_plural) %></h3>
|
||||
<ul class="documents">
|
||||
<% for attachment in @attachments %>
|
||||
<li>
|
||||
<div class="contextual">
|
||||
<%= link_to_if_authorized l(:button_delete), {:controller => 'documents', :action => 'destroy_attachment', :id => @document, :attachment_id => attachment}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
|
||||
</div>
|
||||
<%= link_to attachment.filename, :action => 'download', :id => @document, :attachment_id => attachment %>
|
||||
(<%= number_to_human_size attachment.filesize %>)<br />
|
||||
<em><%= attachment.author.display_name %>, <%= format_date(attachment.created_on) %></em><br />
|
||||
<%= lwr(:label_download, attachment.downloads) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<br />
|
||||
|
||||
|
||||
<% if authorize_for('documents', 'add_attachment') %>
|
||||
<p><%= toggle_link l(:label_attachment_new), "add_attachment_form" %></p>
|
||||
<% form_tag ({ :controller => 'documents', :action => 'add_attachment', :id => @document }, :multipart => true, :class => "tabular", :id => "add_attachment_form", :style => "display:none;") do %>
|
||||
<p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>
|
||||
<%= image_to_function "add.png", "addFileField();return false" %></label>
|
||||
<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
|
||||
<%= submit_tag l(:button_add) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -1,10 +0,0 @@
|
||||
<h2><%=l(:label_enumerations)%></h2>
|
||||
|
||||
<% form_tag({:action => 'update', :id => @enumeration}, :class => "tabular") do %>
|
||||
<%= render :partial => 'form' %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
|
||||
<% form_tag({:action => 'destroy', :id => @enumeration}) do %>
|
||||
<%= submit_tag l(:button_delete) %>
|
||||
<% end %>
|
||||
@@ -1,19 +0,0 @@
|
||||
<h2><%=l(:label_enumerations)%></h2>
|
||||
|
||||
<% Enumeration::OPTIONS.each do |option, name| %>
|
||||
|
||||
<% if params[:opt]==option %>
|
||||
|
||||
<h3><%= l(name) %></h3>
|
||||
<ul>
|
||||
<% for value in Enumeration.find(:all, :conditions => ["opt = ?", option]) %>
|
||||
<li><%= link_to value.name, :action => 'edit', :id => value %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<p><%= link_to l(:label_enumeration_new), { :action => 'new', :opt => option }, :class => "icon icon-add" %></p>
|
||||
|
||||
<% else %>
|
||||
<h3><%= link_to l(name), :opt => option %></h3>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
@@ -1,6 +0,0 @@
|
||||
<h2><%= l(@enumeration.option_name) %>: <%=l(:label_enumeration_new)%></h2>
|
||||
|
||||
<% form_tag({:action => 'create'}, :class => "tabular") do %>
|
||||
<%= render :partial => 'form' %>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<% end %>
|
||||
@@ -1,28 +0,0 @@
|
||||
xml.instruct!
|
||||
xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
|
||||
xml.channel do
|
||||
xml.title @title
|
||||
xml.link url_for(:controller => 'welcome', :only_path => false)
|
||||
xml.pubDate CGI.rfc1123_date(@journals.first ? @journals.first.created_on : Time.now)
|
||||
xml.description l(:label_reported_issues)
|
||||
@journals.each do |journal|
|
||||
issue = journal.issue
|
||||
xml.item do
|
||||
xml.title "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}"
|
||||
url = url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
|
||||
xml.link url
|
||||
xml.description do
|
||||
xml.text! h(journal.notes)
|
||||
xml.text! "<ul>"
|
||||
journal.details.each do |detail|
|
||||
xml.text! "<li>" + show_detail(detail, false) + "</li>"
|
||||
end
|
||||
xml.text! "</ul>"
|
||||
end
|
||||
xml.pubDate CGI.rfc1123_date(journal.created_on)
|
||||
xml.guid url
|
||||
xml.author h(journal.user.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,28 +0,0 @@
|
||||
xml.instruct!
|
||||
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
|
||||
xml.title @title
|
||||
xml.link "rel" => "self", "href" => url_for(:controller => 'feeds', :action => 'history', :format => 'atom', :only_path => false)
|
||||
xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
|
||||
xml.id url_for(:controller => 'welcome', :only_path => false)
|
||||
xml.updated CGI.rfc1123_date(@journals.first.created_on) if @journals.any?
|
||||
xml.author { xml.name "#{Setting.app_title}" }
|
||||
@journals.each do |journal|
|
||||
issue = journal.issue
|
||||
xml.entry do
|
||||
xml.title "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}"
|
||||
xml.link "rel" => "alternate", "href" => url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
|
||||
xml.id url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
|
||||
xml.updated CGI.rfc1123_date(journal.created_on)
|
||||
xml.author { xml.name journal.user.name }
|
||||
xml.summary journal.notes
|
||||
xml.content "type" => "html" do
|
||||
xml.text! journal.notes
|
||||
xml.text! "<ul>"
|
||||
journal.details.each do |detail|
|
||||
xml.text! "<li>" + show_detail(detail, false) + "</li>"
|
||||
end
|
||||
xml.text! "</ul>"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
xml.instruct!
|
||||
xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
|
||||
xml.channel do
|
||||
xml.title @title
|
||||
xml.link url_for(:controller => 'welcome', :only_path => false)
|
||||
xml.pubDate CGI.rfc1123_date(@issues.first ? @issues.first.created_on : Time.now)
|
||||
xml.description l(:label_reported_issues)
|
||||
@issues.each do |issue|
|
||||
xml.item do
|
||||
xml.title "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}"
|
||||
url = url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
|
||||
xml.link url
|
||||
xml.description h(issue.description)
|
||||
xml.pubDate CGI.rfc1123_date(issue.created_on)
|
||||
xml.guid url
|
||||
xml.author h(issue.author.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,22 +0,0 @@
|
||||
xml.instruct!
|
||||
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
|
||||
xml.title @title
|
||||
xml.link "rel" => "self", "href" => url_for(:controller => 'feeds', :action => 'issues', :format => 'atom', :only_path => false)
|
||||
xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
|
||||
xml.id url_for(:controller => 'welcome', :only_path => false)
|
||||
xml.updated CGI.rfc1123_date(@issues.first.updated_on) if @issues.any?
|
||||
xml.author { xml.name "#{Setting.app_title}" }
|
||||
@issues.each do |issue|
|
||||
xml.entry do
|
||||
xml.title "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}"
|
||||
xml.link "rel" => "alternate", "href" => url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
|
||||
xml.id url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
|
||||
xml.updated CGI.rfc1123_date(issue.updated_on)
|
||||
xml.author { xml.name issue.author.name }
|
||||
xml.summary issue.description
|
||||
xml.content "type" => "html" do
|
||||
xml.text! issue.description
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
xml.instruct!
|
||||
xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
|
||||
xml.channel do
|
||||
xml.title "#{Setting.app_title}: #{l(:label_news_latest)}"
|
||||
xml.link url_for(:controller => 'welcome', :only_path => false)
|
||||
xml.pubDate CGI.rfc1123_date(@news.first ? @news.first.created_on : Time.now)
|
||||
xml.description l(:label_news_latest)
|
||||
@news.each do |news|
|
||||
xml.item do
|
||||
xml.title "#{news.project.name}: #{news.title}"
|
||||
news_url = url_for(:controller => 'news' , :action => 'show', :id => news, :only_path => false)
|
||||
xml.link news_url
|
||||
xml.description h(news.summary)
|
||||
xml.pubDate CGI.rfc1123_date(news.created_on)
|
||||
xml.guid news_url
|
||||
xml.author h(news.author.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,22 +0,0 @@
|
||||
xml.instruct!
|
||||
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
|
||||
xml.title "#{Setting.app_title}: #{l(:label_news_latest)}"
|
||||
xml.link "rel" => "self", "href" => url_for(:controller => 'feeds', :action => 'news', :format => 'atom', :only_path => false)
|
||||
xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
|
||||
xml.id url_for(:controller => 'welcome', :only_path => false)
|
||||
xml.updated CGI.rfc1123_date(@news.first.created_on) if @news.any?
|
||||
xml.author { xml.name "#{Setting.app_title}" }
|
||||
@news.each do |news|
|
||||
xml.entry do
|
||||
xml.title news.title
|
||||
xml.link "rel" => "alternate", "href" => url_for(:controller => 'news' , :action => 'show', :id => news, :only_path => false)
|
||||
xml.id url_for(:controller => 'news' , :action => 'show', :id => news, :only_path => false)
|
||||
xml.updated CGI.rfc1123_date(news.created_on)
|
||||
xml.author { xml.name news.author.name }
|
||||
xml.summary h(news.summary)
|
||||
xml.content "type" => "html" do
|
||||
xml.text! news.description
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
<h2><%=l(:label_issue_category)%></h2>
|
||||
|
||||
<% form_tag({:action => 'edit', :id => @category}, :class => "tabular") do %>
|
||||
<%= render :partial => 'form' %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
@@ -1,18 +0,0 @@
|
||||
<%= error_messages_for 'issue_status' %>
|
||||
|
||||
<div class="box">
|
||||
<!--[form:issue_status]-->
|
||||
<p><label for="issue_status_name"><%=l(:field_name)%><span class="required"> *</span></label>
|
||||
<%= text_field 'issue_status', 'name' %></p>
|
||||
|
||||
<p><label for="issue_status_is_closed"><%=l(:field_is_closed)%></label>
|
||||
<%= check_box 'issue_status', 'is_closed' %></p>
|
||||
|
||||
<p><label for="issue_status_is_default"><%=l(:field_is_default)%></label>
|
||||
<%= check_box 'issue_status', 'is_default' %></p>
|
||||
|
||||
<p><label for="issue_status_html_color"><%=l(:field_html_color)%><span class="required"> *</span></label>
|
||||
#<%= text_field 'issue_status', 'html_color', :maxlength => 6 %></p>
|
||||
|
||||
<!--[eoform:issue_status]-->
|
||||
</div>
|
||||
@@ -1,6 +0,0 @@
|
||||
<h2><%=l(:label_issue_status)%></h2>
|
||||
|
||||
<% form_tag({:action => 'update', :id => @issue_status}, :class => "tabular") do %>
|
||||
<%= render :partial => 'form' %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
@@ -1,35 +0,0 @@
|
||||
<div class="contextual">
|
||||
<%= link_to l(:label_issue_status_new), {:action => 'new'}, :class => 'icon icon-add' %>
|
||||
</div>
|
||||
|
||||
<h2><%=l(:label_issue_status_plural)%></h2>
|
||||
|
||||
<table class="list">
|
||||
<thead><tr>
|
||||
<th><%=l(:field_status)%></th>
|
||||
<th><%=l(:field_is_default)%></th>
|
||||
<th><%=l(:field_is_closed)%></th>
|
||||
<th><%=l(:button_sort)%></th>
|
||||
<th></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% for status in @issue_statuses %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td><div class="square" style="background:#<%= status.html_color %>;"></div> <%= link_to status.name, :action => 'edit', :id => status %></td>
|
||||
<td align="center"><%= image_tag 'true.png' if status.is_default? %></td>
|
||||
<td align="center"><%= image_tag 'true.png' if status.is_closed? %></td>
|
||||
<td align="center" style="width:15%;">
|
||||
<%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => status, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
|
||||
<%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => status, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
|
||||
<%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => status, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
|
||||
<%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => status, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
|
||||
</td>
|
||||
<td align="center" style="width:10%;">
|
||||
<%= button_to l(:button_delete), { :action => 'destroy', :id => status }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= pagination_links_full @issue_status_pages %>
|
||||
@@ -1,6 +0,0 @@
|
||||
<h2><%=l(:label_issue_status_new)%></h2>
|
||||
|
||||
<% form_tag({:action => 'create'}, :class => "tabular") do %>
|
||||
<%= render :partial => 'form' %>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<% end %>
|
||||
@@ -1,5 +0,0 @@
|
||||
<% if authorize_for('projects', 'add_issue') %>
|
||||
<% form_tag({ :controller => 'projects', :action => 'add_issue', :id => @project }, :method => 'get') do %>
|
||||
<%= l(:label_issue_new) %>: <%= select_tag 'tracker_id', ("<option></option>" + options_from_collection_for_select(trackers, 'id', 'name')), :onchange => "if (this.value!='') {this.form.submit();}" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -1,11 +0,0 @@
|
||||
<% for journal in journals %>
|
||||
<h4><%= format_time(journal.created_on) %> - <%= journal.user.name %></h4>
|
||||
<ul>
|
||||
<% for detail in journal.details %>
|
||||
<li><%= show_detail(detail) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% if journal.notes? %>
|
||||
<%= textilizable(journal.notes) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -1,25 +0,0 @@
|
||||
<% if issues.length > 0 %>
|
||||
<table class="list">
|
||||
<thead><tr>
|
||||
<th>#</th>
|
||||
<th><%=l(:field_tracker)%></th>
|
||||
<th><%=l(:field_subject)%></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% for issue in issues %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<th align="center">
|
||||
<%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %>
|
||||
</th>
|
||||
<td><div class="square" style="background:#<%= issue.status.html_color %>;"></div> <p class="small"><%= issue.project.name %> - <%= issue.tracker.name %><br />
|
||||
<%= issue.status.name %> - <%= format_time(issue.updated_on) %></p></td>
|
||||
<td>
|
||||
<p class="small"><%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %></p>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<i><%=l(:label_no_data)%></i>
|
||||
<% end %>
|
||||
@@ -1,100 +0,0 @@
|
||||
<% pdf.SetFontStyle('B',11)
|
||||
pdf.Cell(190,10, "#{issue.project.name} - #{issue.tracker.name} # #{issue.long_id} - #{issue.subject}")
|
||||
pdf.Ln
|
||||
|
||||
y0 = pdf.GetY
|
||||
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_status) + ":","LT")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, issue.status.name,"RT")
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_priority) + ":","LT")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, issue.priority.name,"RT")
|
||||
pdf.Ln
|
||||
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_author) + ":","L")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, issue.author.name,"R")
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_category) + ":","L")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, (issue.category ? issue.category.name : "-"),"R")
|
||||
pdf.Ln
|
||||
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_created_on) + ":","L")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, format_date(issue.created_on),"R")
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_assigned_to) + ":","L")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, (issue.assigned_to ? issue.assigned_to.name : "-"),"R")
|
||||
pdf.Ln
|
||||
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_updated_on) + ":","LB")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, format_date(issue.updated_on),"RB")
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_due_date) + ":","LB")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, format_date(issue.due_date),"RB")
|
||||
pdf.Ln
|
||||
|
||||
for custom_value in issue.custom_values
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, custom_value.custom_field.name + ":","L")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.MultiCell(155,5, (show_value custom_value),"R")
|
||||
end
|
||||
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_subject) + ":","LTB")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(155,5, issue.subject,"RTB")
|
||||
pdf.Ln
|
||||
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_description) + ":")
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.MultiCell(155,5, issue.description,"BR")
|
||||
|
||||
pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
|
||||
pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY)
|
||||
|
||||
pdf.Ln
|
||||
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(190,5, l(:label_history), "B")
|
||||
pdf.Ln
|
||||
for journal in issue.journals.find(:all, :include => :user, :order => "journals.created_on desc")
|
||||
pdf.SetFontStyle('B',8)
|
||||
pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name)
|
||||
pdf.Ln
|
||||
pdf.SetFontStyle('I',8)
|
||||
for detail in journal.details
|
||||
pdf.Cell(190,5, "- " + show_detail(detail, true))
|
||||
pdf.Ln
|
||||
end
|
||||
if journal.notes?
|
||||
pdf.SetFontStyle('',8)
|
||||
pdf.MultiCell(190,5, journal.notes)
|
||||
end
|
||||
pdf.Ln
|
||||
end
|
||||
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(190,5, l(:label_attachment_plural), "B")
|
||||
pdf.Ln
|
||||
for attachment in issue.attachments
|
||||
pdf.SetFontStyle('',8)
|
||||
pdf.Cell(80,5, attachment.filename)
|
||||
pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R")
|
||||
pdf.Cell(25,5, format_date(attachment.created_on),0,0,"R")
|
||||
pdf.Cell(65,5, attachment.author.name,0,0,"R")
|
||||
pdf.Ln
|
||||
end
|
||||
%>
|
||||
@@ -1,6 +0,0 @@
|
||||
<%= link_to_issue issue %></strong>: <%=h issue.subject %><br />
|
||||
<br />
|
||||
<strong><%= l(:field_start_date) %></strong>: <%= format_date(issue.start_date) %><br />
|
||||
<strong><%= l(:field_due_date) %></strong>: <%= format_date(issue.due_date) %><br />
|
||||
<strong><%= l(:field_assigned_to) %></strong>: <%= issue.assigned_to ? issue.assigned_to.name : "-" %><br />
|
||||
<strong><%= l(:field_priority) %></strong>: <%= issue.priority.name %>
|
||||
@@ -1,27 +0,0 @@
|
||||
<h2><%=l(:label_issue)%> #<%= @issue.id %>: <%=h @issue.subject %></h2>
|
||||
|
||||
<%= error_messages_for 'issue' %>
|
||||
<% labelled_tabular_form_for(:issue, @issue, :url => {:action => 'change_status', :id => @issue}, :html => {:multipart => true}) do |f| %>
|
||||
|
||||
<%= hidden_field_tag 'confirm', 1 %>
|
||||
<%= hidden_field_tag 'new_status_id', @new_status.id %>
|
||||
<%= f.hidden_field :lock_version %>
|
||||
|
||||
<div class="box">
|
||||
<p><label><%=l(:label_issue_status_new)%></label> <%= @new_status.name %></p>
|
||||
<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
|
||||
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
|
||||
<p><%= f.select :fixed_version_id, (@project.versions.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p>
|
||||
|
||||
<p><label for="notes"><%= l(:field_notes) %></label>
|
||||
<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %></p>
|
||||
|
||||
<% if authorize_for('issues', 'add_attachment') %>
|
||||
<p id="attachments_p"><label><%=l(:label_attachment_new)%>
|
||||
<%= image_to_function "add.png", "addFileField();return false" %></label>
|
||||
<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
@@ -1,55 +0,0 @@
|
||||
<h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%=h @issue.subject %></h2>
|
||||
|
||||
<% labelled_tabular_form_for :issue, @issue, :url => {:action => 'edit'} do |f| %>
|
||||
<%= error_messages_for 'issue' %>
|
||||
<div class="box">
|
||||
<!--[form:issue]-->
|
||||
<div class="splitcontentleft">
|
||||
<p><label><%=l(:field_status)%></label> <%= @issue.status.name %></p>
|
||||
<p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
|
||||
<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
|
||||
<p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %></p>
|
||||
</div>
|
||||
|
||||
<div class="splitcontentright">
|
||||
<p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p>
|
||||
<p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p>
|
||||
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
|
||||
</div>
|
||||
|
||||
<div class="clear">
|
||||
<p><%= f.text_field :subject, :size => 80, :required => true %></p>
|
||||
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => [[10, @issue.description.length / 50].max, 100].min, :class => 'wiki-edit' %></p>
|
||||
|
||||
<% for @custom_value in @custom_values %>
|
||||
<p><%= custom_field_tag_with_label @custom_value %></p>
|
||||
<% end %>
|
||||
|
||||
<p><%= f.select :fixed_version_id, (@project.versions.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p>
|
||||
</div>
|
||||
<!--[eoform:issue]-->
|
||||
</div>
|
||||
<%= f.hidden_field :lock_version %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
|
||||
<% if Setting.text_formatting == 'textile' %>
|
||||
<%= javascript_include_tag 'jstoolbar' %>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
if (document.getElementById) {
|
||||
if (document.getElementById('issue_description')) {
|
||||
var commentTb = new jsToolBar(document.getElementById('issue_description'));
|
||||
commentTb.draw();
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'calendar/calendar' %>
|
||||
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
|
||||
<%= javascript_include_tag 'calendar/calendar-setup' %>
|
||||
<%= stylesheet_link_tag 'calendar' %>
|
||||
<% end %>
|
||||
@@ -1,10 +0,0 @@
|
||||
<% pdf=IfpdfHelper::IFPDF.new(current_language)
|
||||
pdf.SetTitle("#{@project.name} - ##{@issue.tracker.name} #{@issue.id}")
|
||||
pdf.AliasNbPages
|
||||
pdf.footer_date = format_date(Date.today)
|
||||
pdf.AddPage
|
||||
|
||||
render :partial => 'issues/pdf', :locals => { :pdf => pdf, :issue => @issue }
|
||||
%>
|
||||
|
||||
<%= pdf.Output %>
|
||||
@@ -1,6 +0,0 @@
|
||||
<h3><%=l(:label_history)%></h3>
|
||||
<div id="history">
|
||||
<%= render :partial => 'history', :locals => { :journals => @journals } %>
|
||||
</div>
|
||||
<br />
|
||||
<p><%= link_to l(:button_back), :action => 'show', :id => @issue %></p>
|
||||
@@ -1,113 +0,0 @@
|
||||
<div class="contextual">
|
||||
<%= l(:label_export_to) %><%= link_to 'PDF', {:action => 'export_pdf', :id => @issue}, :class => 'icon icon-pdf' %>
|
||||
</div>
|
||||
|
||||
<h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%=h @issue.subject %></h2>
|
||||
|
||||
<div class="box">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td style="width:15%"><b><%=l(:field_status)%> :</b></td><td style="width:35%"><%= @issue.status.name %></td>
|
||||
<td style="width:15%"><b><%=l(:field_priority)%> :</b></td><td style="width:35%"><%= @issue.priority.name %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><%=l(:field_assigned_to)%> :</b></td><td><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td>
|
||||
<td><b><%=l(:field_category)%> :</b></td><td><%=h @issue.category ? @issue.category.name : "-" %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><%=l(:field_author)%> :</b></td><td><%= link_to_user @issue.author %></td>
|
||||
<td><b><%=l(:field_start_date)%> :</b></td><td><%= format_date(@issue.start_date) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><%=l(:field_created_on)%> :</b></td><td><%= format_date(@issue.created_on) %></td>
|
||||
<td><b><%=l(:field_due_date)%> :</b></td><td><%= format_date(@issue.due_date) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><%=l(:field_updated_on)%> :</b></td><td><%= format_date(@issue.updated_on) %></td>
|
||||
<td><b><%=l(:field_done_ratio)%> :</b></td><td><%= @issue.done_ratio %> %</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><%=l(:field_fixed_version)%> :</b></td><td><%= @issue.fixed_version ? @issue.fixed_version.name : "-" %></td>
|
||||
<td><b><%=l(:label_spent_time)%> :</b></td>
|
||||
<td><%= @issue.spent_hours > 0 ? (link_to lwr(:label_f_hour, @issue.spent_hours), {:controller => 'timelog', :action => 'details', :issue_id => @issue}, :class => 'icon icon-time') : "-" %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<% n = 0
|
||||
for custom_value in @custom_values %>
|
||||
<td><b><%= custom_value.custom_field.name %> :</b></td><td><%= h(show_value(custom_value)) %></td>
|
||||
<% n = n + 1
|
||||
if (n > 1)
|
||||
n = 0 %>
|
||||
</tr><tr>
|
||||
<%end
|
||||
end %>
|
||||
</tr>
|
||||
</table>
|
||||
<hr />
|
||||
<br />
|
||||
|
||||
<b><%=l(:field_description)%> :</b><br /><br />
|
||||
<%= textilizable @issue.description %>
|
||||
<br />
|
||||
|
||||
<div class="contextual">
|
||||
<%= link_to_if_authorized l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon icon-edit' %>
|
||||
<%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %>
|
||||
<%= link_to_if_authorized l(:button_move), {:controller => 'projects', :action => 'move_issues', :id => @project, "issue_ids[]" => @issue.id }, :class => 'icon icon-move' %>
|
||||
<%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
|
||||
</div>
|
||||
|
||||
<% if authorize_for('issues', 'change_status') and @status_options and !@status_options.empty? %>
|
||||
<% form_tag ({:controller => 'issues', :action => 'change_status', :id => @issue}) do %>
|
||||
<%=l(:label_change_status)%> :
|
||||
<select name="new_status_id">
|
||||
<%= options_from_collection_for_select @status_options, "id", "name" %>
|
||||
</select>
|
||||
<%= submit_tag l(:button_change) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="history" class="box">
|
||||
<h3><%=l(:label_history)%>
|
||||
<% if @journals_count > @journals.length %>(<%= l(:label_last_changes, @journals.length) %>)<% end %></h3>
|
||||
<%= render :partial => 'history', :locals => { :journals => @journals } %>
|
||||
<% if @journals_count > @journals.length %>
|
||||
<p><center><small><%= link_to l(:label_change_view_all), :action => 'history', :id => @issue %></small></center></p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<h3><%=l(:label_attachment_plural)%></h3>
|
||||
<table width="100%">
|
||||
<% for attachment in @issue.attachments %>
|
||||
<tr>
|
||||
<td><%= link_to attachment.filename, { :action => 'download', :id => @issue, :attachment_id => attachment }, :class => 'icon icon-attachment' %> (<%= number_to_human_size(attachment.filesize) %>)</td>
|
||||
<td><%= format_date(attachment.created_on) %></td>
|
||||
<td><%= attachment.author.display_name %></td>
|
||||
<td><div class="contextual"><%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy_attachment', :id => @issue, :attachment_id => attachment }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></div></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<br />
|
||||
<% if authorize_for('issues', 'add_attachment') %>
|
||||
<% form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") do %>
|
||||
<p id="attachments_p"><label><%=l(:label_attachment_new)%>
|
||||
<%= image_to_function "add.png", "addFileField();return false" %></label>
|
||||
<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
|
||||
<%= submit_tag l(:button_add) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if authorize_for('issues', 'add_note') %>
|
||||
<div class="box">
|
||||
<h3><%= l(:label_add_note) %></h3>
|
||||
<% form_tag ({:controller => 'issues', :action => 'add_note', :id => @issue}, :class => "tabular" ) do %>
|
||||
<p><label for="notes"><%=l(:field_notes)%></label>
|
||||
<%= text_area_tag 'notes', '', :cols => 60, :rows => 10, :class => 'wiki-edit' %></p>
|
||||
<%= submit_tag l(:button_add) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,130 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title><%= Setting.app_title + (@html_title ? ": #{@html_title}" : "") %></title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="description" content="redMine" />
|
||||
<meta name="keywords" content="issue,bug,tracker" />
|
||||
<!--[if IE]>
|
||||
<style type="text/css">
|
||||
body {behavior: url(<%= stylesheet_path "csshover.htc" %>);}
|
||||
</style>
|
||||
<![endif]-->
|
||||
<%= stylesheet_link_tag "application" %>
|
||||
<%= stylesheet_link_tag "print", :media => "print" %>
|
||||
<%= javascript_include_tag :defaults %>
|
||||
<%= javascript_include_tag 'menu' %>
|
||||
<%= stylesheet_link_tag 'jstoolbar' %>
|
||||
<!-- page specific tags --><%= yield :header_tags %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container" >
|
||||
|
||||
<div id="header">
|
||||
<div style="float: left;">
|
||||
<h1><%= Setting.app_title %></h1>
|
||||
<h2><%= Setting.app_subtitle %></h2>
|
||||
</div>
|
||||
<div style="float: right; padding-right: 1em; padding-top: 0.2em;">
|
||||
<% if loggedin? %><small><%=l(:label_logged_as)%> <b><%= @logged_in_user.login %></b></small><% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="navigation">
|
||||
<ul>
|
||||
<li><%= link_to l(:label_home), { :controller => 'welcome' }, :class => "icon icon-home" %></li>
|
||||
<li><%= link_to l(:label_my_page), { :controller => 'my', :action => 'page'}, :class => "icon icon-mypage" %></li>
|
||||
<li><%= link_to l(:label_project_plural), { :controller => 'projects' }, :class => "icon icon-projects" %></li>
|
||||
|
||||
<% unless @project.nil? || @project.id.nil? %>
|
||||
<li class="submenu"><%= link_to @project.name, { :controller => 'projects', :action => 'show', :id => @project }, :class => "icon icon-projects", :onmouseover => "buttonMouseover(event, 'menuProject');" %></li>
|
||||
<% end %>
|
||||
|
||||
<% if loggedin? %>
|
||||
<li><%= link_to l(:label_my_account), { :controller => 'my', :action => 'account' }, :class => "icon icon-user" %></li>
|
||||
<% end %>
|
||||
|
||||
<% if admin_loggedin? %>
|
||||
<li class="submenu"><%= link_to l(:label_administration), { :controller => 'admin' }, :class => "icon icon-admin", :onmouseover => "buttonMouseover(event, 'menuAdmin');" %></li>
|
||||
<% end %>
|
||||
|
||||
<li class="right"><%= link_to l(:label_help), { :controller => 'help', :ctrl => params[:controller], :page => params[:action] }, :onclick => "window.open(this.href); return false;", :class => "icon icon-help" %></li>
|
||||
|
||||
<% if loggedin? %>
|
||||
<li class="right"><%= link_to l(:label_logout), { :controller => 'account', :action => 'logout' }, :class => "icon icon-user" %></li>
|
||||
<% else %>
|
||||
<li class="right"><%= link_to l(:label_login), { :controller => 'account', :action => 'login' }, :class => "icon icon-user" %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% if admin_loggedin? %>
|
||||
<%= render :partial => 'admin/menu' %>
|
||||
<% end %>
|
||||
|
||||
<% unless @project.nil? || @project.id.nil? %>
|
||||
<div id="menuProject" class="menu" onmouseover="menuMouseover(event)">
|
||||
<%= link_to l(:label_calendar), {:controller => 'projects', :action => 'calendar', :id => @project }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_gantt), {:controller => 'projects', :action => 'gantt', :id => @project }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_issue_plural), {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_report_plural), {:controller => 'reports', :action => 'issue_report', :id => @project }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'activity', :id => @project }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_news_plural), {:controller => 'projects', :action => 'list_news', :id => @project }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_change_log), {:controller => 'projects', :action => 'changelog', :id => @project }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_roadmap), {:controller => 'projects', :action => 'roadmap', :id => @project }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_document_plural), {:controller => 'projects', :action => 'list_documents', :id => @project }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_wiki), {:controller => 'wiki', :id => @project, :page => nil }, :class => "menuItem" if @project.wiki and !@project.wiki.new_record? %>
|
||||
<%= link_to l(:label_attachment_plural), {:controller => 'projects', :action => 'list_files', :id => @project }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_search), {:controller => 'projects', :action => 'search', :id => @project }, :class => "menuItem" %>
|
||||
<%= link_to l(:label_repository), {:controller => 'repositories', :action => 'show', :id => @project}, :class => "menuItem" if @project.repository and !@project.repository.new_record? %>
|
||||
<%= link_to_if_authorized l(:label_settings), {:controller => 'projects', :action => 'settings', :id => @project }, :class => "menuItem" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
<div id="subcontent">
|
||||
|
||||
<% unless @project.nil? || @project.id.nil? %>
|
||||
<h2><%= @project.name %></h2>
|
||||
<ul class="menublock">
|
||||
<li><%= link_to l(:label_overview), :controller => 'projects', :action => 'show', :id => @project %></li>
|
||||
<li><%= link_to l(:label_calendar), :controller => 'projects', :action => 'calendar', :id => @project %></li>
|
||||
<li><%= link_to l(:label_gantt), :controller => 'projects', :action => 'gantt', :id => @project %></li>
|
||||
<li><%= link_to l(:label_issue_plural), :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 %></li>
|
||||
<li><%= link_to l(:label_report_plural), :controller => 'reports', :action => 'issue_report', :id => @project %></li>
|
||||
<li><%= link_to l(:label_activity), :controller => 'projects', :action => 'activity', :id => @project %></li>
|
||||
<li><%= link_to l(:label_news_plural), :controller => 'projects', :action => 'list_news', :id => @project %></li>
|
||||
<li><%= link_to l(:label_change_log), :controller => 'projects', :action => 'changelog', :id => @project %></li>
|
||||
<li><%= link_to l(:label_roadmap), :controller => 'projects', :action => 'roadmap', :id => @project %></li>
|
||||
<li><%= link_to l(:label_document_plural), :controller => 'projects', :action => 'list_documents', :id => @project %></li>
|
||||
<li><%= link_to l(:label_wiki), :controller => 'wiki', :id => @project, :page => nil if @project.wiki and !@project.wiki.new_record? %></li>
|
||||
<li><%= link_to l(:label_attachment_plural), :controller => 'projects', :action => 'list_files', :id => @project %></li>
|
||||
<li><%= link_to l(:label_search), :controller => 'projects', :action => 'search', :id => @project %></li>
|
||||
<li><%= link_to l(:label_repository), :controller => 'repositories', :action => 'show', :id => @project if @project.repository and !@project.repository.new_record? %></li>
|
||||
<li><%= link_to_if_authorized l(:label_settings), :controller => 'projects', :action => 'settings', :id => @project %></li>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if loggedin? and @logged_in_user.memberships.length > 0 %>
|
||||
<h2><%=l(:label_my_projects) %></h2>
|
||||
<ul class="menublock">
|
||||
<% for membership in @logged_in_user.memberships %>
|
||||
<li><%= link_to membership.project.name, :controller => 'projects', :action => 'show', :id => membership.project %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<% if flash[:notice] %><p style="color: green"><%= flash[:notice] %></p><% end %>
|
||||
<%= yield %>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<p><a href="http://redmine.rubyforge.org/">redMine</a> <small><%= Redmine::VERSION %> © 2006-2007 Jean-Philippe Lang</small></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +0,0 @@
|
||||
<%=l(:label_issue)%> #<%= issue.id %> - <%= issue.subject %>
|
||||
<%=l(:field_author)%>: <%= issue.author.display_name %>
|
||||
<%=l(:field_status)%>: <%= issue.status.name %>
|
||||
|
||||
<%= issue.description %>
|
||||
|
||||
http://<%= Setting.host_name %>/issues/show/<%= issue.id %>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user