Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66866954f6 | ||
|
|
c9ed3fdae3 | ||
|
|
7b164b5cd4 | ||
|
|
dd54b1aacb | ||
|
|
8fa96feb1f | ||
|
|
ddd0796e40 | ||
|
|
4ef86b965b | ||
|
|
1cc6dd871b | ||
|
|
4564519a56 | ||
|
|
5a241fd12e | ||
|
|
840fcf2fa9 | ||
|
|
75e3ab737c | ||
|
|
516cedaa47 | ||
|
|
3881ade96d | ||
|
|
f4842d6eed | ||
|
|
10e77d865b | ||
|
|
92725e5803 | ||
|
|
73510949ba | ||
|
|
08ff4dfb21 | ||
|
|
2e72f2eca8 | ||
|
|
9845bbddce | ||
|
|
81b3ad5b87 | ||
|
|
6c4f196f6e | ||
|
|
022b4ae57c | ||
|
|
d185e2f9e0 | ||
|
|
2b7c31feb5 | ||
|
|
7dd312b1ac | ||
|
|
4ff7b395dd | ||
|
|
66044c620b | ||
|
|
52c1718ee8 | ||
|
|
8b180aa606 | ||
|
|
ccaf6c8df0 | ||
|
|
879a614cde | ||
|
|
8c3dc34359 | ||
|
|
f82654f158 | ||
|
|
c365614548 | ||
|
|
a3c2c4a48a | ||
|
|
8316e78667 | ||
|
|
4a988b0f92 | ||
|
|
b5e80bf90f | ||
|
|
da426fa652 | ||
|
|
39e65a41a2 | ||
|
|
1eb17b08f9 | ||
|
|
318c8717b8 | ||
|
|
7184632b84 | ||
|
|
1e4a7d55e0 | ||
|
|
5101c55e10 | ||
|
|
c1537b5291 | ||
|
|
4c767d636a | ||
|
|
aa91ca0a8d | ||
|
|
d3b831bf7b | ||
|
|
fa688d48e6 | ||
|
|
671a0fa101 | ||
|
|
99f006f2c9 | ||
|
|
f9c400a727 | ||
|
|
fe22797d69 | ||
|
|
d29ba0b80f | ||
|
|
18fd46ab6b | ||
|
|
ec7ac956e4 | ||
|
|
99c560295f | ||
|
|
90c7cf9763 | ||
|
|
3dc9ceaadf | ||
|
|
23f6185bfe | ||
|
|
1cb0294388 | ||
|
|
2d47a6d71c | ||
|
|
22c2209cf9 | ||
|
|
471679b0f0 | ||
|
|
862c9d76e6 | ||
|
|
2c187c43bf | ||
|
|
486b4e9ea2 | ||
|
|
5f361e71df | ||
|
|
13881f5a5b | ||
|
|
c38a2112c6 | ||
|
|
a9fc777b20 | ||
|
|
ab15456119 | ||
|
|
0d55613359 | ||
|
|
845460b165 | ||
|
|
7c27fb7c1d | ||
|
|
e51c20c496 | ||
|
|
190fef513f | ||
|
|
b9ef10fe3f | ||
|
|
2b9777555f | ||
|
|
1f79394ac4 | ||
|
|
e2e111f95e | ||
|
|
8985d05a66 | ||
|
|
4e03668eec | ||
|
|
2789b08dd0 | ||
|
|
66a02688ad | ||
|
|
681bbf02ae | ||
|
|
c80de840d1 | ||
|
|
bd3458da6e | ||
|
|
4ccbc65628 | ||
|
|
9a2753931b | ||
|
|
0b4d4db131 | ||
|
|
a1b12335ab | ||
|
|
a8137d5d17 | ||
|
|
1e5362b1f7 | ||
|
|
51ea8b0295 | ||
|
|
f35194e604 | ||
|
|
3ef57c1ac3 | ||
|
|
69b7f9e9a2 | ||
|
|
220641909c | ||
|
|
31bc6054a3 | ||
|
|
94391723c0 | ||
|
|
5fd3decb16 | ||
|
|
d7c015a884 | ||
|
|
8ed55e8d7a | ||
|
|
979892a109 | ||
|
|
776d5ce554 | ||
|
|
28ea323791 | ||
|
|
18787caab9 | ||
|
|
390d6023c6 | ||
|
|
e1ef9a5c72 | ||
|
|
f3babef54a | ||
|
|
2dc3850798 | ||
|
|
18001e5a5b | ||
|
|
32f6cb7c13 | ||
|
|
9f76b4d2ef | ||
|
|
a9efe82117 | ||
|
|
4ee55dc456 | ||
|
|
470ef4d11e | ||
|
|
57d4e698fe | ||
|
|
f50544bb15 | ||
|
|
e3becc7c3c | ||
|
|
e7caec6e7d | ||
|
|
6487c1803f | ||
|
|
ff65a5b22a | ||
|
|
7a03cf92ba | ||
|
|
e6fa690d65 | ||
|
|
95cc65f14e | ||
|
|
b3a3d3e2fa | ||
|
|
0820e745d6 | ||
|
|
2197fa3120 | ||
|
|
b4d4b80dcd | ||
|
|
3bfaa20c05 | ||
|
|
58f8a23d58 | ||
|
|
1f3380bfad | ||
|
|
451ec23060 | ||
|
|
4c84165aa0 | ||
|
|
a6c8feea21 | ||
|
|
718de6c7fd | ||
|
|
d81a135704 | ||
|
|
1a90fbee8b | ||
|
|
2ac30707d2 | ||
|
|
58a36e3604 | ||
|
|
676fe403ab | ||
|
|
13611bf0ab | ||
|
|
ad02b3fb7b | ||
|
|
d3600e729f | ||
|
|
6c8e1514aa | ||
|
|
bc44158501 | ||
|
|
918123cd06 | ||
|
|
2b86ef8e28 | ||
|
|
3e28dc669b | ||
|
|
bee3f353fc | ||
|
|
005f4baaa4 | ||
|
|
2b0142580f | ||
|
|
236c735d08 | ||
|
|
e5562afcd3 | ||
|
|
256eb6250e | ||
|
|
e50ba150c3 | ||
|
|
bab9c40dcc | ||
|
|
55ed70529a | ||
|
|
28c6aa4e6d | ||
|
|
ab88b27622 | ||
|
|
2c335dbf32 | ||
|
|
d6d1502200 | ||
|
|
4bb61ade27 | ||
|
|
96f83cc8f0 | ||
|
|
eabc04d836 | ||
|
|
b3be8745b0 | ||
|
|
aa28c3d7ba | ||
|
|
948e2190f8 | ||
|
|
362633d486 | ||
|
|
120e39ba80 | ||
|
|
98d4bdb7df | ||
|
|
2c6e3cb02d | ||
|
|
9c70084ea5 | ||
|
|
9b2bd72e1f | ||
|
|
707360169e | ||
|
|
418b8d861a | ||
|
|
42181112ff | ||
|
|
67e81b0ae9 | ||
|
|
51317b350c | ||
|
|
c83e794871 | ||
|
|
26ec775854 | ||
|
|
5e9e01bf7f | ||
|
|
f7df1b7d55 | ||
|
|
abb5d019cd | ||
|
|
474b5a52d6 | ||
|
|
63d3b12bb5 | ||
|
|
7136b85f21 | ||
|
|
6707034768 | ||
|
|
ef99d3c4ce | ||
|
|
4c9f27e550 | ||
|
|
55dded8e5f | ||
|
|
0778ac8c1b | ||
|
|
3628515b31 | ||
|
|
51e0989c49 | ||
|
|
79cbe8d199 | ||
|
|
a2d4ca095a | ||
|
|
7473be4072 | ||
|
|
6a0022d7a1 | ||
|
|
e4d4a12c6a | ||
|
|
4a1cfb3df9 | ||
|
|
b00769f606 | ||
|
|
6e367354e9 | ||
|
|
e5e8318c70 | ||
|
|
d9135ce1e7 | ||
|
|
aa17905081 | ||
|
|
fbafa95791 | ||
|
|
dc26a9cd39 | ||
|
|
5f185b6c05 | ||
|
|
893a433165 | ||
|
|
552d99d664 | ||
|
|
54aeec7b5f | ||
|
|
d2b89f5f9b | ||
|
|
6b08e1b315 | ||
|
|
18ee1fef41 | ||
|
|
2a96f56956 | ||
|
|
3903eddded | ||
|
|
b862c447f1 | ||
|
|
5b47d7bfcc | ||
|
|
310a0f924a | ||
|
|
7e57db1edb | ||
|
|
71c3ad642c | ||
|
|
bc51f529e9 | ||
|
|
a573da3b98 |
@@ -0,0 +1,131 @@
|
|||||||
|
# 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
|
||||||
@@ -31,10 +31,12 @@ class AdminController < ApplicationController
|
|||||||
@project_count = Project.count
|
@project_count = Project.count
|
||||||
@project_pages = Paginator.new self, @project_count,
|
@project_pages = Paginator.new self, @project_count,
|
||||||
15,
|
15,
|
||||||
@params['page']
|
params['page']
|
||||||
@projects = Project.find :all, :order => sort_clause,
|
@projects = Project.find :all, :order => sort_clause,
|
||||||
:limit => @project_pages.items_per_page,
|
:limit => @project_pages.items_per_page,
|
||||||
:offset => @project_pages.current.offset
|
:offset => @project_pages.current.offset
|
||||||
|
|
||||||
|
render :action => "projects", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def mail_options
|
def mail_options
|
||||||
@@ -44,11 +46,10 @@ class AdminController < ApplicationController
|
|||||||
a.mail_enabled = (params[:action_ids] || []).include? a.id.to_s
|
a.mail_enabled = (params[:action_ids] || []).include? a.id.to_s
|
||||||
a.save
|
a.save
|
||||||
}
|
}
|
||||||
flash[:notice] = "Mail options were successfully updated."
|
flash.now[:notice] = l(:notice_successful_update)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def info
|
def info
|
||||||
@adapter_name = ActiveRecord::Base.connection.adapter_name
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
@user_membership ||= Member.find(:first, :conditions => ["user_id=? and project_id=?", self.logged_in_user.id, @project.id])
|
||||||
|
if @user_membership and Permission.allowed_to_role( "%s/%s" % [ ctrl, action ], @user_membership.role_id )
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
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
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
# 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
|
||||||
+22
-16
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# redMine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -16,16 +16,17 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class DocumentsController < ApplicationController
|
class DocumentsController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :find_project, :authorize
|
before_filter :find_project, :authorize
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@attachments = @document.attachments.find(:all, :order => "created_on DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@categories = Enumeration::get_values('DCAT')
|
@categories = Enumeration::get_values('DCAT')
|
||||||
if request.post? and @document.update_attributes(params[:document])
|
if request.post? and @document.update_attributes(params[:document])
|
||||||
flash[:notice] = 'Document was successfully updated.'
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'show', :id => @document
|
redirect_to :action => 'show', :id => @document
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -39,27 +40,32 @@ class DocumentsController < ApplicationController
|
|||||||
@attachment = @document.attachments.find(params[:attachment_id])
|
@attachment = @document.attachments.find(params[:attachment_id])
|
||||||
@attachment.increment_download
|
@attachment.increment_download
|
||||||
send_file @attachment.diskfile, :filename => @attachment.filename
|
send_file @attachment.diskfile, :filename => @attachment.filename
|
||||||
|
rescue
|
||||||
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_attachment
|
def add_attachment
|
||||||
# Save the attachment
|
# Save the attachments
|
||||||
if params[:attachment][:file].size > 0
|
@attachments = []
|
||||||
@attachment = @document.attachments.build(params[:attachment])
|
params[:attachments].each { |file|
|
||||||
@attachment.author_id = session[:user].id unless session[:user].nil?
|
next unless file.size > 0
|
||||||
@attachment.save
|
a = Attachment.create(:container => @document, :file => file, :author => logged_in_user)
|
||||||
end
|
@attachments << a unless a.new_record?
|
||||||
render :action => 'show'
|
} 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 :action => 'show', :id => @document
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_attachment
|
def destroy_attachment
|
||||||
@document.attachments.find(params[:attachment_id]).destroy
|
@document.attachments.find(params[:attachment_id]).destroy
|
||||||
render :action => 'show'
|
redirect_to :action => 'show', :id => @document
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@document = Document.find(params[:id])
|
@document = Document.find(params[:id])
|
||||||
@project = @document.project
|
@project = @document.project
|
||||||
end
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
+3
-2
@@ -38,7 +38,7 @@ class EnumerationsController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@enumeration = Enumeration.new(params[:enumeration])
|
@enumeration = Enumeration.new(params[:enumeration])
|
||||||
if @enumeration.save
|
if @enumeration.save
|
||||||
flash[:notice] = 'Enumeration was successfully created.'
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'list', :opt => @enumeration.opt
|
redirect_to :action => 'list', :opt => @enumeration.opt
|
||||||
else
|
else
|
||||||
render :action => 'new'
|
render :action => 'new'
|
||||||
@@ -52,7 +52,7 @@ class EnumerationsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
@enumeration = Enumeration.find(params[:id])
|
@enumeration = Enumeration.find(params[:id])
|
||||||
if @enumeration.update_attributes(params[:enumeration])
|
if @enumeration.update_attributes(params[:enumeration])
|
||||||
flash[:notice] = 'Enumeration was successfully updated.'
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'list', :opt => @enumeration.opt
|
redirect_to :action => 'list', :opt => @enumeration.opt
|
||||||
else
|
else
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
@@ -61,6 +61,7 @@ class EnumerationsController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
Enumeration.find(params[:id]).destroy
|
Enumeration.find(params[:id]).destroy
|
||||||
|
flash[:notice] = l(:notice_successful_delete)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
rescue
|
rescue
|
||||||
flash[:notice] = "Unable to delete enumeration"
|
flash[:notice] = "Unable to delete enumeration"
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# 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 FeedsController < ApplicationController
|
||||||
|
session :off
|
||||||
|
|
||||||
|
def news
|
||||||
|
@news = News.find :all, :order => 'news.created_on DESC', :limit => 10, :include => [ :author, :project ]
|
||||||
|
headers["Content-Type"] = "application/rss+xml"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -23,20 +23,20 @@ class HelpController < ApplicationController
|
|||||||
# displays help page for the requested controller/action
|
# displays help page for the requested controller/action
|
||||||
def index
|
def index
|
||||||
# select help page to display
|
# select help page to display
|
||||||
if @params[:ctrl] and @help_config['pages'][@params[:ctrl]]
|
if params[:ctrl] and @help_config['pages'][params[:ctrl]]
|
||||||
if @params[:page] and @help_config['pages'][@params[:ctrl]][@params[:page]]
|
if params[:page] and @help_config['pages'][params[:ctrl]][params[:page]]
|
||||||
template = @help_config['pages'][@params[:ctrl]][@params[:page]]
|
template = @help_config['pages'][params[:ctrl]][params[:page]]
|
||||||
else
|
else
|
||||||
template = @help_config['pages'][@params[:ctrl]]['index']
|
template = @help_config['pages'][params[:ctrl]]['index']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# choose language according to available help translations
|
# choose language according to available help translations
|
||||||
lang = (@help_config['langs'].include? Localization.lang) ? Localization.lang : @help_config['langs'].first
|
lang = (@help_config['langs'].include? current_language.to_s) ? current_language.to_s : @help_config['langs'].first
|
||||||
|
|
||||||
if template
|
if template
|
||||||
redirect_to "/manual/#{lang}/#{template}"
|
redirect_to "/manual/#{lang}/#{template}"
|
||||||
else
|
else
|
||||||
redirect_to "/manual/#{lang}/"
|
redirect_to "/manual/#{lang}/index.html"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
+11
-9
@@ -16,27 +16,29 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class IssueCategoriesController < ApplicationController
|
class IssueCategoriesController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :find_project, :authorize
|
before_filter :find_project, :authorize
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
if request.post? and @category.update_attributes(params[:category])
|
if request.post? and @category.update_attributes(params[:category])
|
||||||
flash[:notice] = 'Issue category was successfully updated.'
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@category.destroy
|
@category.destroy
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
|
||||||
rescue
|
rescue
|
||||||
flash[:notice] = "Categorie can't be deleted"
|
flash[:notice] = "Categorie can't be deleted"
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@category = IssueCategory.find(params[:id])
|
@category = IssueCategory.find(params[:id])
|
||||||
@project = @category.project
|
@project = @category.project
|
||||||
end
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
+25
-8
@@ -16,16 +16,20 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class IssueStatusesController < ApplicationController
|
class IssueStatusesController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
|
|
||||||
|
verify :method => :post, :only => [ :destroy, :create, :update, :move ],
|
||||||
|
:redirect_to => { :action => :list }
|
||||||
|
|
||||||
def index
|
def index
|
||||||
list
|
list
|
||||||
render :action => 'list'
|
render :action => 'list' unless request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def list
|
def list
|
||||||
@issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 10
|
@issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
|
||||||
|
render :action => "list", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@@ -35,7 +39,7 @@ class IssueStatusesController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@issue_status = IssueStatus.new(params[:issue_status])
|
@issue_status = IssueStatus.new(params[:issue_status])
|
||||||
if @issue_status.save
|
if @issue_status.save
|
||||||
flash[:notice] = 'IssueStatus was successfully created.'
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
else
|
else
|
||||||
render :action => 'new'
|
render :action => 'new'
|
||||||
@@ -49,13 +53,28 @@ class IssueStatusesController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
@issue_status = IssueStatus.find(params[:id])
|
@issue_status = IssueStatus.find(params[:id])
|
||||||
if @issue_status.update_attributes(params[:issue_status])
|
if @issue_status.update_attributes(params[:issue_status])
|
||||||
flash[:notice] = 'IssueStatus was successfully updated.'
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
else
|
else
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def move
|
||||||
|
@issue_status = IssueStatus.find(params[:id])
|
||||||
|
case params[:position]
|
||||||
|
when 'highest'
|
||||||
|
@issue_status.move_to_top
|
||||||
|
when 'higher'
|
||||||
|
@issue_status.move_higher
|
||||||
|
when 'lower'
|
||||||
|
@issue_status.move_lower
|
||||||
|
when 'lowest'
|
||||||
|
@issue_status.move_to_bottom
|
||||||
|
end if params[:position]
|
||||||
|
redirect_to :action => 'list'
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
IssueStatus.find(params[:id]).destroy
|
IssueStatus.find(params[:id]).destroy
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
@@ -63,6 +82,4 @@ class IssueStatusesController < ApplicationController
|
|||||||
flash[:notice] = "Unable to delete issue status"
|
flash[:notice] = "Unable to delete issue status"
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
# 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.workflows.find(:all, :order => 'position', :include => :new_status, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.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 => "journals.created_on desc")
|
||||||
|
end
|
||||||
|
|
||||||
|
def history
|
||||||
|
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "journals.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])
|
||||||
|
#@history = @issue.histories.build(params[:history])
|
||||||
|
#@history.author_id = self.logged_in_user.id if self.logged_in_user
|
||||||
|
#@history.status = @issue.status
|
||||||
|
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
|
||||||
|
#@history = @issue.histories.build(params[:history])
|
||||||
|
@status_options = @issue.status.workflows.find(:all, :order => 'position', :include => :new_status, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user
|
||||||
|
@new_status = IssueStatus.find(params[:new_status_id])
|
||||||
|
if params[:confirm]
|
||||||
|
begin
|
||||||
|
#@history.author_id = self.logged_in_user.id if self.logged_in_user
|
||||||
|
#@issue.status = @history.status
|
||||||
|
#@issue.fixed_version_id = (params[:issue][:fixed_version_id])
|
||||||
|
#@issue.assigned_to_id = (params[:issue][:assigned_to_id])
|
||||||
|
#@issue.done_ratio = (params[:issue][:done_ratio])
|
||||||
|
#@issue.lock_version = (params[:issue][:lock_version])
|
||||||
|
journal = @issue.init_journal(self.logged_in_user, params[:notes])
|
||||||
|
@issue.status = @new_status
|
||||||
|
if @issue.update_attributes(params[:issue])
|
||||||
|
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 = []
|
||||||
|
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?
|
||||||
|
} 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 :action => 'show', :id => @issue
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy_attachment
|
||||||
|
@issue.attachments.find(params[:attachment_id]).destroy
|
||||||
|
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
|
||||||
+18
-17
@@ -16,26 +16,27 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class MembersController < ApplicationController
|
class MembersController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :find_project, :authorize
|
before_filter :find_project, :authorize
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
if request.post? and @member.update_attributes(params[:member])
|
if request.post? and @member.update_attributes(params[:member])
|
||||||
flash[:notice] = 'Member was successfully updated.'
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@member.destroy
|
@member.destroy
|
||||||
flash[:notice] = 'Member was successfully removed.'
|
flash[:notice] = l(:notice_successful_delete)
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@member = Member.find(params[:id])
|
@member = Member.find(params[:id])
|
||||||
@project = @member.project
|
@project = @member.project
|
||||||
end
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
# 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
|
||||||
|
@user = self.logged_in_user
|
||||||
|
block = params[:block]
|
||||||
|
# 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
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,578 @@
|
|||||||
|
# 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 '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 => ["is_public=?", true],
|
||||||
|
: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 @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 = @project.members.find(:all, :include => [:user, :role])
|
||||||
|
@subprojects = @project.children if @project.children.size > 0
|
||||||
|
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
|
||||||
|
@trackers = Tracker.find(:all, :order => 'position')
|
||||||
|
@open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN issue_statuses ON issue_statuses.id = issues.status_id", :conditions => ["project_id=? and issue_statuses.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.attributes = params[:repository]
|
||||||
|
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')
|
||||||
|
@issue = Issue.new(:project => @project, :tracker => @tracker)
|
||||||
|
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]
|
||||||
|
@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 'issues.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 => [ :author, :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 'issues.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, {:custom_values => :custom_field} ],
|
||||||
|
:conditions => @query.statement,
|
||||||
|
:limit => Setting.issues_export_limit
|
||||||
|
|
||||||
|
ic = Iconv.new('ISO-8859-1', '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_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.author.display_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 'issues.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_id)}
|
||||||
|
# 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.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')
|
||||||
|
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 ||= []
|
||||||
|
@fixed_issues = @project.issues.find(:all,
|
||||||
|
:include => [ :fixed_version, :status, :tracker ],
|
||||||
|
:conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
|
||||||
|
:order => "versions.effective_date DESC, issues.id DESC"
|
||||||
|
) unless @selected_tracker_ids.empty?
|
||||||
|
@fixed_issues ||= []
|
||||||
|
end
|
||||||
|
|
||||||
|
def roadmap
|
||||||
|
@trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position')
|
||||||
|
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 ||= []
|
||||||
|
@versions = @project.versions.find(:all,
|
||||||
|
:conditions => [ "versions.effective_date>?", Date.today],
|
||||||
|
:order => "versions.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, :status], :conditions => ["issues.created_on>=? and issues.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.created_on>=? and news.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 => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.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 => ["documents.created_on>=? and documents.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 documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.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
|
||||||
|
|
||||||
|
render :layout => false if request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
|
def calendar
|
||||||
|
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)
|
||||||
|
|
||||||
|
@issues = @project.issues.find(:all, :include => [:tracker, :status, :assigned_to, :priority], :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to])
|
||||||
|
render :layout => false if request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
|
def gantt
|
||||||
|
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
|
||||||
|
@issues = @project.issues.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)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to])
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
# 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"
|
||||||
|
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 }
|
||||||
|
issues_by_tracker
|
||||||
|
issues_by_priority
|
||||||
|
issues_by_category
|
||||||
|
issues_by_author
|
||||||
|
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
|
||||||
|
issues i, issue_statuses s, trackers 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
|
||||||
|
issues i, issue_statuses s, enumerations 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
|
||||||
|
issues i, issue_statuses s, issue_categories 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
|
||||||
|
issues i, issue_statuses s, users 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
|
||||||
|
end
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# 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 RepositoriesController < ApplicationController
|
||||||
|
layout 'base'
|
||||||
|
before_filter :find_project, :authorize
|
||||||
|
|
||||||
|
def show
|
||||||
|
@entries = @repository.scm.entries('')
|
||||||
|
show_error and return unless @entries
|
||||||
|
@latest_revision = @entries.revisions.latest
|
||||||
|
end
|
||||||
|
|
||||||
|
def browse
|
||||||
|
@entries = @repository.scm.entries(@path, @rev)
|
||||||
|
show_error and return unless @entries
|
||||||
|
end
|
||||||
|
|
||||||
|
def revisions
|
||||||
|
@entry = @repository.scm.entry(@path, @rev)
|
||||||
|
@revisions = @repository.scm.revisions(@path, @rev)
|
||||||
|
show_error and return unless @entry && @revisions
|
||||||
|
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
|
||||||
|
@revisions = @repository.scm.revisions '', @rev, @rev, :with_paths => true
|
||||||
|
show_error and return unless @revisions
|
||||||
|
@revision = @revisions.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def diff
|
||||||
|
@rev_to = params[:rev_to] || (@rev-1)
|
||||||
|
@diff = @repository.scm.diff(params[:path], @rev, @rev_to)
|
||||||
|
show_error and return unless @diff
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_project
|
||||||
|
@project = Project.find(params[:id])
|
||||||
|
@repository = @project.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
|
||||||
|
end
|
||||||
@@ -16,39 +16,43 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class RolesController < ApplicationController
|
class RolesController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
|
|
||||||
|
verify :method => :post, :only => [ :destroy, :move ],
|
||||||
|
:redirect_to => { :action => :list }
|
||||||
|
|
||||||
def index
|
def index
|
||||||
list
|
list
|
||||||
render :action => 'list'
|
render :action => 'list' unless request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def list
|
def list
|
||||||
@role_pages, @roles = paginate :roles, :per_page => 10
|
@role_pages, @roles = paginate :roles, :per_page => 10, :order => "position"
|
||||||
|
render :action => "list", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@role = Role.new(params[:role])
|
@role = Role.new(params[:role])
|
||||||
if request.post?
|
if request.post?
|
||||||
@role.permissions = Permission.find(@params[:permission_ids]) if @params[:permission_ids]
|
@role.permissions = Permission.find(params[:permission_ids]) if params[:permission_ids]
|
||||||
if @role.save
|
if @role.save
|
||||||
flash[:notice] = 'Role was successfully created.'
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@permissions = Permission.find(:all, :order => 'sort ASC')
|
@permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC')
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@role = Role.find(params[:id])
|
@role = Role.find(params[:id])
|
||||||
if request.post? and @role.update_attributes(params[:role])
|
if request.post? and @role.update_attributes(params[:role])
|
||||||
@role.permissions = Permission.find(@params[:permission_ids] || [])
|
@role.permissions = Permission.find(params[:permission_ids] || [])
|
||||||
Permission.allowed_to_role_expired
|
Permission.allowed_to_role_expired
|
||||||
flash[:notice] = 'Role was successfully updated.'
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
@permissions = Permission.find(:all, :order => 'sort ASC')
|
@permissions = Permission.find(:all, :conditions => ["is_public=?", false], :order => 'sort ASC')
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@@ -61,8 +65,22 @@ class RolesController < ApplicationController
|
|||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
|
|
||||||
def workflow
|
def move
|
||||||
|
@role = Role.find(params[:id])
|
||||||
|
case params[:position]
|
||||||
|
when 'highest'
|
||||||
|
@role.move_to_top
|
||||||
|
when 'higher'
|
||||||
|
@role.move_higher
|
||||||
|
when 'lower'
|
||||||
|
@role.move_lower
|
||||||
|
when 'lowest'
|
||||||
|
@role.move_to_bottom
|
||||||
|
end if params[:position]
|
||||||
|
redirect_to :action => 'list'
|
||||||
|
end
|
||||||
|
|
||||||
|
def workflow
|
||||||
@role = Role.find_by_id(params[:role_id])
|
@role = Role.find_by_id(params[:role_id])
|
||||||
@tracker = Tracker.find_by_id(params[:tracker_id])
|
@tracker = Tracker.find_by_id(params[:tracker_id])
|
||||||
|
|
||||||
@@ -74,11 +92,11 @@ class RolesController < ApplicationController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if @role.save
|
if @role.save
|
||||||
flash[:notice] = 'Workflow was successfully updated.'
|
flash[:notice] = l(:notice_successful_update)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@roles = Role.find_all
|
@roles = Role.find(:all, :order => 'position')
|
||||||
@trackers = Tracker.find_all
|
@trackers = Tracker.find(:all, :order => 'position')
|
||||||
@statuses = IssueStatus.find(:all, :include => :workflows)
|
@statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# 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
|
||||||
+23
-8
@@ -16,25 +16,26 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class TrackersController < ApplicationController
|
class TrackersController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
list
|
list
|
||||||
render :action => 'list'
|
render :action => 'list' unless request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
|
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
|
||||||
verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :list }
|
verify :method => :post, :only => [ :destroy, :move ], :redirect_to => { :action => :list }
|
||||||
|
|
||||||
def list
|
def list
|
||||||
@tracker_pages, @trackers = paginate :trackers, :per_page => 10
|
@tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position'
|
||||||
|
render :action => "list", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@tracker = Tracker.new(params[:tracker])
|
@tracker = Tracker.new(params[:tracker])
|
||||||
if request.post? and @tracker.save
|
if request.post? and @tracker.save
|
||||||
flash[:notice] = 'Tracker was successfully created.'
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -42,11 +43,26 @@ class TrackersController < ApplicationController
|
|||||||
def edit
|
def edit
|
||||||
@tracker = Tracker.find(params[:id])
|
@tracker = Tracker.find(params[:id])
|
||||||
if request.post? and @tracker.update_attributes(params[:tracker])
|
if request.post? and @tracker.update_attributes(params[:tracker])
|
||||||
flash[:notice] = 'Tracker was successfully updated.'
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def move
|
||||||
|
@tracker = Tracker.find(params[:id])
|
||||||
|
case params[:position]
|
||||||
|
when 'highest'
|
||||||
|
@tracker.move_to_top
|
||||||
|
when 'higher'
|
||||||
|
@tracker.move_higher
|
||||||
|
when 'lower'
|
||||||
|
@tracker.move_lower
|
||||||
|
when 'lowest'
|
||||||
|
@tracker.move_to_bottom
|
||||||
|
end if params[:position]
|
||||||
|
redirect_to :action => 'list'
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@tracker = Tracker.find(params[:id])
|
@tracker = Tracker.find(params[:id])
|
||||||
unless @tracker.issues.empty?
|
unless @tracker.issues.empty?
|
||||||
@@ -56,5 +72,4 @@ class TrackersController < ApplicationController
|
|||||||
end
|
end
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
# 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
|
||||||
|
@user_count = User.count
|
||||||
|
@user_pages = Paginator.new self, @user_count,
|
||||||
|
15,
|
||||||
|
params['page']
|
||||||
|
@users = User.find :all,:order => sort_clause,
|
||||||
|
: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
|
||||||
+20
-18
@@ -16,41 +16,43 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class VersionsController < ApplicationController
|
class VersionsController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :find_project, :authorize
|
before_filter :find_project, :authorize
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
if request.post? and @version.update_attributes(params[:version])
|
if request.post? and @version.update_attributes(params[:version])
|
||||||
flash[:notice] = 'Version was successfully updated.'
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@version.destroy
|
@version.destroy
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||||
rescue
|
rescue
|
||||||
flash[:notice] = "Unable to delete version"
|
flash[:notice] = "Unable to delete version"
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
def download
|
def download
|
||||||
@attachment = @version.attachments.find(params[:attachment_id])
|
@attachment = @version.attachments.find(params[:attachment_id])
|
||||||
@attachment.increment_download
|
@attachment.increment_download
|
||||||
send_file @attachment.diskfile, :filename => @attachment.filename
|
send_file @attachment.diskfile, :filename => @attachment.filename
|
||||||
rescue
|
rescue
|
||||||
flash[:notice]="Requested file doesn't exist or has been deleted."
|
render_404
|
||||||
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_file
|
def destroy_file
|
||||||
@version.attachments.find(params[:attachment_id]).destroy
|
@version.attachments.find(params[:attachment_id]).destroy
|
||||||
|
flash[:notice] = l(:notice_successful_delete)
|
||||||
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@version = Version.find(params[:id])
|
@version = Version.find(params[:id])
|
||||||
@project = @version.project
|
@project = @version.project
|
||||||
end
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
+5
-6
@@ -16,11 +16,10 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class WelcomeController < ApplicationController
|
class WelcomeController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
|
|
||||||
def index
|
|
||||||
@news = News.latest
|
|
||||||
@projects = Project.latest
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def index
|
||||||
|
@news = News.latest logged_in_user
|
||||||
|
@projects = Project.latest logged_in_user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,193 @@
|
|||||||
|
# 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.id) ) )
|
||||||
|
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 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) 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 => { :page => paginator.current.previous }},
|
||||||
|
{:href => url_for(:action => 'list', :params => params.merge({:page => paginator.current.previous}))}) + ' ' if paginator.current.previous
|
||||||
|
|
||||||
|
html << (pagination_links_each(paginator, options) do |n|
|
||||||
|
link_to_remote(n.to_s,
|
||||||
|
{:url => {:action => 'list', :params => params.merge({:page => n})}, :update => 'content'},
|
||||||
|
{:href => url_for(:action => 'list', :params => params.merge({:page => n}))})
|
||||||
|
end || '')
|
||||||
|
|
||||||
|
html << ' ' + link_to_remote((l(:label_next) + ' »'),
|
||||||
|
{:update => "content", :url => { :page => paginator.current.next }},
|
||||||
|
{:href => url_for(:action => 'list', :params => params.merge({:page => paginator.current.next}))}) if paginator.current.next
|
||||||
|
html
|
||||||
|
end
|
||||||
|
|
||||||
|
def textilizable(text)
|
||||||
|
(Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") ? RedCloth.new(h(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?
|
||||||
|
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?
|
||||||
|
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
|
||||||
|
|
||||||
@@ -15,5 +15,5 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
module IssuesHelper
|
module AuthSourcesHelper
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# 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 FeedsHelper
|
||||||
|
end
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# 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'
|
||||||
|
|
||||||
|
module IfpdfHelper
|
||||||
|
|
||||||
|
class IFPDF < FPDF
|
||||||
|
|
||||||
|
attr_accessor :footer_date
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
super
|
||||||
|
SetCreator("redMine #{Redmine::VERSION}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
|
||||||
|
@ic ||= Iconv.new('ISO-8859-1', 'UTF-8')
|
||||||
|
txt = begin
|
||||||
|
@ic.iconv(txt)
|
||||||
|
rescue
|
||||||
|
txt
|
||||||
|
end
|
||||||
|
super w,h,txt,border,ln,align,fill,link
|
||||||
|
end
|
||||||
|
|
||||||
|
def Footer
|
||||||
|
SetFont('Helvetica', '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
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# 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
|
||||||
|
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?
|
||||||
|
if old_value
|
||||||
|
label + " " + l(:text_journal_changed, old_value, value)
|
||||||
|
else
|
||||||
|
label + " " + l(:text_journal_set_to, value)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
label + " " + l(:text_journal_deleted) + " (#{old_value})"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
module QueriesHelper
|
||||||
|
|
||||||
|
def operators_for_select(filter_type)
|
||||||
|
Query.operators_by_filter_type[filter_type].collect {|o| [l(Query.operators[o]), o]}
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# 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 RepositoriesHelper
|
||||||
|
end
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# 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
|
||||||
@@ -61,7 +61,7 @@ module SortHelper
|
|||||||
# defaults to '<controller_name>_sort'.
|
# defaults to '<controller_name>_sort'.
|
||||||
#
|
#
|
||||||
def sort_init(default_key, default_order='asc', name=nil)
|
def sort_init(default_key, default_order='asc', name=nil)
|
||||||
@sort_name = name || @params[:controller] + @params[:action] + '_sort'
|
@sort_name = name || params[:controller] + params[:action] + '_sort'
|
||||||
@sort_default = {:key => default_key, :order => default_order}
|
@sort_default = {:key => default_key, :order => default_order}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -69,21 +69,21 @@ module SortHelper
|
|||||||
# sort_clause.
|
# sort_clause.
|
||||||
#
|
#
|
||||||
def sort_update()
|
def sort_update()
|
||||||
if @params[:sort_key]
|
if params[:sort_key]
|
||||||
sort = {:key => @params[:sort_key], :order => @params[:sort_order]}
|
sort = {:key => params[:sort_key], :order => params[:sort_order]}
|
||||||
elsif @session[@sort_name]
|
elsif session[@sort_name]
|
||||||
sort = @session[@sort_name] # Previous sort.
|
sort = session[@sort_name] # Previous sort.
|
||||||
else
|
else
|
||||||
sort = @sort_default
|
sort = @sort_default
|
||||||
end
|
end
|
||||||
@session[@sort_name] = sort
|
session[@sort_name] = sort
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an SQL sort clause corresponding to the current sort state.
|
# Returns an SQL sort clause corresponding to the current sort state.
|
||||||
# Use this to sort the controller's table items collection.
|
# Use this to sort the controller's table items collection.
|
||||||
#
|
#
|
||||||
def sort_clause()
|
def sort_clause()
|
||||||
@session[@sort_name][:key] + ' ' + @session[@sort_name][:order]
|
session[@sort_name][:key] + ' ' + session[@sort_name][:order]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a link which sorts by the named column.
|
# Returns a link which sorts by the named column.
|
||||||
@@ -93,13 +93,13 @@ module SortHelper
|
|||||||
# - A sort icon image is positioned to the right of the sort link.
|
# - A sort icon image is positioned to the right of the sort link.
|
||||||
#
|
#
|
||||||
def sort_link(column, caption=nil)
|
def sort_link(column, caption=nil)
|
||||||
key, order = @session[@sort_name][:key], @session[@sort_name][:order]
|
key, order = session[@sort_name][:key], session[@sort_name][:order]
|
||||||
if key == column
|
if key == column
|
||||||
if order.downcase == 'asc'
|
if order.downcase == 'asc'
|
||||||
icon = 'sort_asc'
|
icon = 'sort_asc.png'
|
||||||
order = 'desc'
|
order = 'desc'
|
||||||
else
|
else
|
||||||
icon = 'sort_desc'
|
icon = 'sort_desc.png'
|
||||||
order = 'asc'
|
order = 'asc'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -108,7 +108,10 @@ module SortHelper
|
|||||||
end
|
end
|
||||||
caption = titleize(Inflector::humanize(column)) unless caption
|
caption = titleize(Inflector::humanize(column)) unless caption
|
||||||
params = {:params => {:sort_key => column, :sort_order => order}}
|
params = {:params => {:sort_key => column, :sort_order => order}}
|
||||||
link_to(caption, params) + (icon ? nbsp(2) + image_tag(icon) : '')
|
link_to_remote(caption,
|
||||||
|
{:update => "content", :url => { :sort_key => column, :sort_order => order}},
|
||||||
|
{:href => url_for(:params => { :sort_key => column, :sort_order => order})}) +
|
||||||
|
(icon ? nbsp(2) + image_tag(icon) : '')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a table header <th> tag with a sort link for the named column
|
# Returns a table header <th> tag with a sort link for the named column
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# redMine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -21,7 +21,14 @@ class Attachment < ActiveRecord::Base
|
|||||||
belongs_to :container, :polymorphic => true
|
belongs_to :container, :polymorphic => true
|
||||||
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
||||||
|
|
||||||
validates_presence_of :filename
|
validates_presence_of :container, :filename
|
||||||
|
|
||||||
|
cattr_accessor :storage_path
|
||||||
|
@@storage_path = "#{RAILS_ROOT}/files"
|
||||||
|
|
||||||
|
def validate
|
||||||
|
errors.add_to_base :too_long if self.filesize > Setting.attachment_max_size.to_i.kilobytes
|
||||||
|
end
|
||||||
|
|
||||||
def file=(incomming_file)
|
def file=(incomming_file)
|
||||||
unless incomming_file.nil?
|
unless incomming_file.nil?
|
||||||
@@ -35,6 +42,10 @@ class Attachment < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def file
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
# Copy temp file to its final location
|
# Copy temp file to its final location
|
||||||
def before_save
|
def before_save
|
||||||
if @temp_file && (@temp_file.size > 0)
|
if @temp_file && (@temp_file.size > 0)
|
||||||
@@ -55,7 +66,7 @@ class Attachment < ActiveRecord::Base
|
|||||||
|
|
||||||
# Returns file's location on disk
|
# Returns file's location on disk
|
||||||
def diskfile
|
def diskfile
|
||||||
"#{RDM_STORAGE_PATH}/#{self.disk_filename}"
|
"#{@@storage_path}/#{self.disk_filename}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def increment_download
|
def increment_download
|
||||||
@@ -15,22 +15,33 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class Mailer < ActionMailer::Base
|
class AuthSource < ActiveRecord::Base
|
||||||
|
has_many :users
|
||||||
|
|
||||||
def issue_change_status(issue)
|
validates_presence_of :name
|
||||||
# Sends to all project members
|
validates_uniqueness_of :name
|
||||||
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
|
|
||||||
@from = 'redmine@somenet.foo'
|
|
||||||
@subject = "Issue ##{issue.id} has been updated"
|
|
||||||
@body['issue'] = issue
|
|
||||||
end
|
|
||||||
|
|
||||||
def issue_add(issue)
|
def authenticate(login, password)
|
||||||
# Sends to all project members
|
end
|
||||||
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
|
|
||||||
@from = 'redmine@somenet.foo'
|
|
||||||
@subject = "Issue ##{issue.id} has been reported"
|
|
||||||
@body['issue'] = issue
|
|
||||||
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
|
end
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
# 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
|
||||||
@@ -15,14 +15,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class News < ActiveRecord::Base
|
class Comment < ActiveRecord::Base
|
||||||
belongs_to :project
|
belongs_to :commented, :polymorphic => true, :counter_cache => true
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
|
|
||||||
validates_presence_of :title, :shortdescr, :descr
|
validates_presence_of :commented, :author, :comment
|
||||||
|
|
||||||
# returns last created news
|
|
||||||
def self.latest
|
|
||||||
find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
class Document < ActiveRecord::Base
|
class Document < ActiveRecord::Base
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :category, :class_name => "Enumeration", :foreign_key => "category_id"
|
belongs_to :category, :class_name => "Enumeration", :foreign_key => "category_id"
|
||||||
has_many :attachments, :as => :container, :dependent => true
|
has_many :attachments, :as => :container, :dependent => :destroy
|
||||||
|
|
||||||
validates_presence_of :title
|
validates_presence_of :project, :title, :category
|
||||||
end
|
end
|
||||||
@@ -18,20 +18,21 @@
|
|||||||
class Enumeration < ActiveRecord::Base
|
class Enumeration < ActiveRecord::Base
|
||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
|
|
||||||
validates_presence_of :opt, :name
|
validates_presence_of :opt, :name
|
||||||
validates_uniqueness_of :name, :scope => [:opt]
|
validates_uniqueness_of :name, :scope => [:opt]
|
||||||
|
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||||
|
|
||||||
OPTIONS = [
|
OPTIONS = {
|
||||||
["Issue priorities", "IPRI"],
|
"IPRI" => :enumeration_issue_priorities,
|
||||||
["Document categories", "DCAT"]
|
"DCAT" => :enumeration_doc_categories
|
||||||
].freeze
|
}.freeze
|
||||||
|
|
||||||
def self.get_values(option)
|
def self.get_values(option)
|
||||||
find(:all, :conditions => ['opt=?', option])
|
find(:all, :conditions => ['opt=?', option])
|
||||||
end
|
end
|
||||||
|
|
||||||
def name
|
def option_name
|
||||||
_ self.attributes['name']
|
OPTIONS[self.opt]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
# 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 :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 new_record?
|
||||||
|
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
|
||||||
|
|
||||||
|
private
|
||||||
|
# Creates an history for the issue
|
||||||
|
#def build_history
|
||||||
|
# @history = self.histories.build
|
||||||
|
# @history.status = self.status
|
||||||
|
# @history.author = self.author
|
||||||
|
#end
|
||||||
|
end
|
||||||
@@ -15,22 +15,13 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
module CustomFieldsHelper
|
class IssueCustomField < CustomField
|
||||||
def custom_field_tag(custom_value)
|
has_and_belongs_to_many :projects, :join_table => "custom_fields_projects", :foreign_key => "custom_field_id"
|
||||||
|
has_and_belongs_to_many :trackers, :join_table => "custom_fields_trackers", :foreign_key => "custom_field_id"
|
||||||
|
has_many :issues, :through => :issue_custom_values
|
||||||
|
|
||||||
custom_field = custom_value.custom_field
|
def type_name
|
||||||
|
:label_issue_plural
|
||||||
field_name = "custom_fields[#{custom_field.id}]"
|
end
|
||||||
|
|
||||||
case custom_field.typ
|
|
||||||
when 0 .. 2
|
|
||||||
text_field_tag field_name, custom_value.value
|
|
||||||
when 3
|
|
||||||
check_box field_name
|
|
||||||
when 4
|
|
||||||
select_tag field_name,
|
|
||||||
options_for_select(custom_field.possible_values.split('|'),
|
|
||||||
custom_value.value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
class IssueHistory < ActiveRecord::Base
|
class IssueHistory < ActiveRecord::Base
|
||||||
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
|
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
|
belongs_to :issue
|
||||||
|
|
||||||
validates_presence_of :status
|
validates_presence_of :status
|
||||||
end
|
end
|
||||||
@@ -18,12 +18,18 @@
|
|||||||
class IssueStatus < ActiveRecord::Base
|
class IssueStatus < ActiveRecord::Base
|
||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
has_many :workflows, :foreign_key => "old_status_id"
|
has_many :workflows, :foreign_key => "old_status_id"
|
||||||
|
acts_as_list
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name
|
validates_uniqueness_of :name
|
||||||
validates_length_of :html_color, :is=>6
|
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||||
|
validates_length_of :html_color, :is => 6
|
||||||
validates_format_of :html_color, :with => /^[a-f0-9]*$/i
|
validates_format_of :html_color, :with => /^[a-f0-9]*$/i
|
||||||
|
|
||||||
|
def before_save
|
||||||
|
IssueStatus.update_all "is_default=#{connection.quoted_false}" if self.is_default?
|
||||||
|
end
|
||||||
|
|
||||||
# Returns the default status for new issues
|
# Returns the default status for new issues
|
||||||
def self.default
|
def self.default
|
||||||
find(:first, :conditions =>["is_default=?", true])
|
find(:first, :conditions =>["is_default=?", true])
|
||||||
@@ -38,12 +44,8 @@ class IssueStatus < ActiveRecord::Base
|
|||||||
statuses
|
statuses
|
||||||
end
|
end
|
||||||
|
|
||||||
def name
|
|
||||||
_ self.attributes['name']
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_integrity
|
def check_integrity
|
||||||
raise "Can't delete status" if Issue.find(:first, :conditions => ["status_id=?", self.id]) or IssueHistory.find(:first, :conditions => ["status_id=?", self.id])
|
raise "Can't delete status" if Issue.find(:first, :conditions => ["status_id=?", self.id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# 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
|
||||||
|
belongs_to :user
|
||||||
|
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
|
||||||
|
end
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
# 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
|
||||||
@@ -16,14 +16,14 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class Member < ActiveRecord::Base
|
class Member < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :role
|
belongs_to :role
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
|
||||||
validates_presence_of :role, :user, :project
|
validates_presence_of :role, :user, :project
|
||||||
validates_uniqueness_of :user_id, :scope => :project_id
|
validates_uniqueness_of :user_id, :scope => :project_id
|
||||||
|
|
||||||
def name
|
def name
|
||||||
self.user.display_name
|
self.user.display_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# 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 News < ActiveRecord::Base
|
||||||
|
belongs_to :project
|
||||||
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
|
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
|
||||||
|
|
||||||
|
validates_presence_of :title, :description
|
||||||
|
|
||||||
|
# returns latest news for projects visible by user
|
||||||
|
def self.latest(user=nil, count=5)
|
||||||
|
find(:all, :limit => count, :conditions => Project.visible_by(user), :include => [ :author, :project ], :order => "news.created_on DESC")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -16,27 +16,29 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class Permission < ActiveRecord::Base
|
class Permission < ActiveRecord::Base
|
||||||
has_and_belongs_to_many :roles
|
has_and_belongs_to_many :roles
|
||||||
|
|
||||||
validates_presence_of :controller, :action, :descr
|
validates_presence_of :controller, :action, :description
|
||||||
|
|
||||||
GROUPS = {
|
GROUPS = {
|
||||||
100 => "Project",
|
100 => :label_project,
|
||||||
200 => "Membres",
|
200 => :label_member_plural,
|
||||||
300 => "Versions",
|
300 => :label_version_plural,
|
||||||
400 => "Issue categories",
|
400 => :label_issue_category_plural,
|
||||||
1000 => "Issues",
|
600 => :label_query_plural,
|
||||||
1100 => "News",
|
1000 => :label_issue_plural,
|
||||||
1200 => "Documents",
|
1100 => :label_news_plural,
|
||||||
1300 => "Files",
|
1200 => :label_document_plural,
|
||||||
}.freeze
|
1300 => :label_attachment_plural,
|
||||||
|
1400 => :label_repository
|
||||||
|
}.freeze
|
||||||
|
|
||||||
@@cached_perms_for_public = nil
|
@@cached_perms_for_public = nil
|
||||||
@@cached_perms_for_roles = nil
|
@@cached_perms_for_roles = nil
|
||||||
|
|
||||||
def name
|
def name
|
||||||
self.controller + "/" + self.action
|
self.controller + "/" + self.action
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_id
|
def group_id
|
||||||
(self.sort / 100)*100
|
(self.sort / 100)*100
|
||||||
@@ -54,7 +56,7 @@ class Permission < ActiveRecord::Base
|
|||||||
find(:all, :include => :roles).each {|p| perms.store "#{p.controller}/#{p.action}", p.roles.collect {|r| r.id } }
|
find(:all, :include => :roles).each {|p| perms.store "#{p.controller}/#{p.action}", p.roles.collect {|r| r.id } }
|
||||||
perms
|
perms
|
||||||
end
|
end
|
||||||
@@cached_perms_for_roles[action] and @@cached_perms_for_roles[action].include? role
|
allowed_to_public(action) or (@@cached_perms_for_roles[action] and @@cached_perms_for_roles[action].include? role)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.allowed_to_role_expired
|
def self.allowed_to_role_expired
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
# 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 => "versions.effective_date DESC, versions.name DESC"
|
||||||
|
has_many :members, :dependent => :delete_all, :include => :user, :conditions => "users.status=#{User::STATUS_ACTIVE}"
|
||||||
|
has_many :users, :through => :members
|
||||||
|
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||||
|
has_many :issues, :dependent => :destroy, :order => "issues.created_on DESC", :include => [:status, :tracker]
|
||||||
|
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 => "issue_categories.name"
|
||||||
|
has_one :repository, :dependent => :destroy
|
||||||
|
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => 'custom_fields_projects', :association_foreign_key => 'custom_field_id'
|
||||||
|
acts_as_tree :order => "name", :counter_cache => true
|
||||||
|
|
||||||
|
validates_presence_of :name, :description
|
||||||
|
validates_uniqueness_of :name
|
||||||
|
validates_associated :custom_values, :on => :update
|
||||||
|
validates_associated :repository
|
||||||
|
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||||
|
|
||||||
|
# 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 => "projects.created_on DESC")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.visible_by(user=nil)
|
||||||
|
if user && !user.memberships.empty?
|
||||||
|
return ["projects.is_public = ? or projects.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')})", true]
|
||||||
|
else
|
||||||
|
return ["projects.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)
|
||||||
|
tracker.custom_fields.find(:all, :include => :projects,
|
||||||
|
:conditions => ["is_for_all=? or project_id=?", true, self.id])
|
||||||
|
#(CustomField.for_all + custom_fields).uniq
|
||||||
|
end
|
||||||
|
|
||||||
|
def all_custom_fields
|
||||||
|
@all_custom_fields ||= IssueCustomField.find(:all, :include => :projects,
|
||||||
|
:conditions => ["is_for_all=? or project_id=?", true, self.id])
|
||||||
|
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
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
# 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 => [ "=", "!", "!*", "*" ],
|
||||||
|
: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] } }
|
||||||
|
# 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"
|
||||||
|
sql << " AND issues.project_id=%d" % project.id if project
|
||||||
|
filters.each_key do |field|
|
||||||
|
v = values_for field
|
||||||
|
next unless v and !v.empty?
|
||||||
|
sql = sql + " AND " unless sql.empty?
|
||||||
|
case operator_for field
|
||||||
|
when "="
|
||||||
|
sql = sql + "issues.#{field} IN (" + v.each(&:to_i).join(",") + ")"
|
||||||
|
when "!"
|
||||||
|
sql = sql + "issues.#{field} NOT IN (" + v.each(&:to_i).join(",") + ")"
|
||||||
|
when "!*"
|
||||||
|
sql = sql + "issues.#{field} IS NULL"
|
||||||
|
when "*"
|
||||||
|
sql = sql + "issues.#{field} IS NOT NULL"
|
||||||
|
when "o"
|
||||||
|
sql = sql + "issue_statuses.is_closed=#{connection.quoted_false}" if field == "status_id"
|
||||||
|
when "c"
|
||||||
|
sql = sql + "issue_statuses.is_closed=#{connection.quoted_true}" if field == "status_id"
|
||||||
|
when ">t-"
|
||||||
|
sql = sql + "issues.#{field} >= '%s'" % connection.quoted_date(Date.today - v.first.to_i)
|
||||||
|
when "<t-"
|
||||||
|
sql = sql + "issues.#{field} <= '" + (Date.today - v.first.to_i).strftime("%Y-%m-%d") + "'"
|
||||||
|
when "t-"
|
||||||
|
sql = sql + "issues.#{field} = '" + (Date.today - v.first.to_i).strftime("%Y-%m-%d") + "'"
|
||||||
|
when ">t+"
|
||||||
|
sql = sql + "issues.#{field} >= '" + (Date.today + v.first.to_i).strftime("%Y-%m-%d") + "'"
|
||||||
|
when "<t+"
|
||||||
|
sql = sql + "issues.#{field} <= '" + (Date.today + v.first.to_i).strftime("%Y-%m-%d") + "'"
|
||||||
|
when "t+"
|
||||||
|
sql = sql + "issues.#{field} = '" + (Date.today + v.first.to_i).strftime("%Y-%m-%d") + "'"
|
||||||
|
when "t"
|
||||||
|
sql = sql + "issues.#{field} = '%s'" % connection.quoted_date(Date.today)
|
||||||
|
when "~"
|
||||||
|
sql = sql + "issues.#{field} LIKE '%#{connection.quote_string(v.first)}%'"
|
||||||
|
when "!~"
|
||||||
|
sql = sql + "issues.#{field} NOT LIKE '%#{connection.quote_string(v.first)}%'"
|
||||||
|
end
|
||||||
|
end if filters and valid?
|
||||||
|
sql
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# 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 Repository < ActiveRecord::Base
|
||||||
|
belongs_to :project
|
||||||
|
validates_presence_of :url
|
||||||
|
validates_format_of :url, :with => /^(http|https|svn|file):\/\/.+/i
|
||||||
|
|
||||||
|
@scm = nil
|
||||||
|
|
||||||
|
def scm
|
||||||
|
@scm ||= SvnRepos::Base.new url
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -17,12 +17,14 @@
|
|||||||
|
|
||||||
class Role < ActiveRecord::Base
|
class Role < ActiveRecord::Base
|
||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
has_and_belongs_to_many :permissions
|
has_and_belongs_to_many :permissions
|
||||||
has_many :workflows, :dependent => true
|
has_many :workflows, :dependent => :delete_all
|
||||||
has_many :members
|
has_many :members
|
||||||
|
acts_as_list
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name
|
validates_uniqueness_of :name
|
||||||
|
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_integrity
|
def check_integrity
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
# 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 'rexml/document'
|
||||||
|
|
||||||
|
module SvnRepos
|
||||||
|
|
||||||
|
class CommandFailed < StandardError #:nodoc:
|
||||||
|
end
|
||||||
|
|
||||||
|
class Base
|
||||||
|
@url = nil
|
||||||
|
@login = nil
|
||||||
|
@password = nil
|
||||||
|
|
||||||
|
def initialize(url, login=nil, password=nil)
|
||||||
|
@url = url
|
||||||
|
@login = login if login && !login.empty?
|
||||||
|
@password = (password || "") if @login
|
||||||
|
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}"
|
||||||
|
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 : "anonymous")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
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 << "--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
|
||||||
|
}
|
||||||
|
end
|
||||||
|
paths.sort! { |x,y| x[:path] <=> y[:path] }
|
||||||
|
|
||||||
|
revisions << Revision.new({:identifier => logentry.attributes['revision'],
|
||||||
|
:author => (logentry.elements['author'] ? logentry.elements['author'].text : "anonymous"),
|
||||||
|
: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)
|
||||||
|
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}"
|
||||||
|
diff = []
|
||||||
|
shellout(cmd) do |io|
|
||||||
|
io.each_line do |line|
|
||||||
|
diff << line
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil if $? && $?.exitstatus != 0
|
||||||
|
diff
|
||||||
|
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}"
|
||||||
|
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 target(path)
|
||||||
|
" \"" << "#{@url}/#{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) do |io|
|
||||||
|
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 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
|
||||||
|
end
|
||||||
@@ -15,28 +15,30 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class NewsController < ApplicationController
|
class Token < ActiveRecord::Base
|
||||||
layout 'base'
|
belongs_to :user
|
||||||
before_filter :find_project, :authorize
|
|
||||||
|
|
||||||
def show
|
@@validity_time = 1.day
|
||||||
|
|
||||||
|
def before_create
|
||||||
|
self.value = Token.generate_token_value
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
# Return true if token has expired
|
||||||
if request.post? and @news.update_attributes(params[:news])
|
def expired?
|
||||||
flash[:notice] = 'News was successfully updated.'
|
return Time.now > self.created_on + @@validity_time
|
||||||
redirect_to :action => 'show', :id => @news
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
# Delete all expired tokens
|
||||||
@news.destroy
|
def self.destroy_expired
|
||||||
redirect_to :controller => 'projects', :action => 'list_news', :id => @project
|
Token.delete_all ["created_on < ?", Time.now - @@validity_time]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def self.generate_token_value
|
||||||
@news = News.find(params[:id])
|
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
||||||
@project = @news.project
|
token_value = ''
|
||||||
end
|
40.times { |i| token_value << chars[rand(chars.size-1)] }
|
||||||
|
token_value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -18,14 +18,13 @@
|
|||||||
class Tracker < ActiveRecord::Base
|
class Tracker < ActiveRecord::Base
|
||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
has_many :issues
|
has_many :issues
|
||||||
has_many :workflows, :dependent => true
|
has_many :workflows, :dependent => :delete_all
|
||||||
|
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => 'custom_fields_trackers', :association_foreign_key => 'custom_field_id'
|
||||||
|
acts_as_list
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name
|
validates_uniqueness_of :name
|
||||||
|
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||||
def name
|
|
||||||
_ self.attributes['name']
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_integrity
|
def check_integrity
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# redMine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@@ -18,7 +18,11 @@
|
|||||||
require "digest/sha1"
|
require "digest/sha1"
|
||||||
|
|
||||||
class User < ActiveRecord::Base
|
class User < ActiveRecord::Base
|
||||||
has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :dependent => true
|
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'
|
||||||
|
belongs_to :auth_source
|
||||||
|
|
||||||
attr_accessor :password, :password_confirmation
|
attr_accessor :password, :password_confirmation
|
||||||
attr_accessor :last_before_login_on
|
attr_accessor :last_before_login_on
|
||||||
@@ -28,25 +32,67 @@ class User < ActiveRecord::Base
|
|||||||
validates_presence_of :login, :firstname, :lastname, :mail
|
validates_presence_of :login, :firstname, :lastname, :mail
|
||||||
validates_uniqueness_of :login, :mail
|
validates_uniqueness_of :login, :mail
|
||||||
# Login must contain lettres, numbers, underscores only
|
# Login must contain lettres, numbers, underscores only
|
||||||
validates_format_of :login, :with => /^[a-z0-9_]+$/i
|
validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-]*$/i
|
||||||
|
validates_format_of :login, :with => /^[a-z0-9_\-@\.]+$/i
|
||||||
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
||||||
# Password length between 4 and 12
|
# Password length between 4 and 12
|
||||||
validates_length_of :password, :in => 4..12, :allow_nil => true
|
validates_length_of :password, :in => 4..12, :allow_nil => true
|
||||||
validates_confirmation_of :password, :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
|
def before_save
|
||||||
# update hashed_password if password was set
|
# update hashed_password if password was set
|
||||||
self.hashed_password = User.hash_password(self.password) if self.password
|
self.hashed_password = User.hash_password(self.password) if self.password
|
||||||
end
|
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
|
# Returns the user that matches provided login and password, or nil
|
||||||
def self.try_to_login(login, password)
|
def self.try_to_login(login, password)
|
||||||
user = find(:first, :conditions => ["login=? and hashed_password=? and locked=?", login, User.hash_password(password), false])
|
user = find(:first, :conditions => ["login=?", login])
|
||||||
if user
|
if user
|
||||||
user.last_before_login_on = user.last_login_on
|
# user is already in local database
|
||||||
user.update_attribute(:last_login_on, Time.now)
|
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
|
end
|
||||||
|
user.update_attribute(:last_login_on, Time.now) if user
|
||||||
user
|
user
|
||||||
|
|
||||||
|
rescue => text
|
||||||
|
raise text
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return user's full name for display
|
# Return user's full name for display
|
||||||
@@ -54,11 +100,26 @@ class User < ActiveRecord::Base
|
|||||||
firstname + " " + lastname
|
firstname + " " + lastname
|
||||||
end
|
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)
|
def check_password?(clear_password)
|
||||||
User.hash_password(clear_password) == self.hashed_password
|
User.hash_password(clear_password) == self.hashed_password
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def role_for_project(project_id)
|
def role_for_project(project_id)
|
||||||
@role_for_projects ||=
|
@role_for_projects ||=
|
||||||
begin
|
begin
|
||||||
@@ -69,6 +130,10 @@ class User < ActiveRecord::Base
|
|||||||
@role_for_projects[project_id]
|
@role_for_projects[project_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pref
|
||||||
|
self.preference ||= UserPreference.new(:user => self)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# Return password digest
|
# Return password digest
|
||||||
def self.hash_password(clear_password)
|
def self.hash_password(clear_password)
|
||||||
@@ -15,24 +15,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class CustomField < ActiveRecord::Base
|
class UserCustomField < CustomField
|
||||||
|
def type_name
|
||||||
has_and_belongs_to_many :projects
|
:label_user_plural
|
||||||
has_many :custom_values, :dependent => true
|
end
|
||||||
has_many :issues, :through => :issue_custom_values
|
|
||||||
|
|
||||||
validates_presence_of :name, :typ
|
|
||||||
validates_uniqueness_of :name
|
|
||||||
|
|
||||||
TYPES = [
|
|
||||||
[ "Integer", 0 ],
|
|
||||||
[ "String", 1 ],
|
|
||||||
[ "Date", 2 ],
|
|
||||||
[ "Boolean", 3 ],
|
|
||||||
[ "List", 4 ]
|
|
||||||
].freeze
|
|
||||||
|
|
||||||
def self.for_all
|
|
||||||
find(:all, :conditions => ["is_for_all=?", true])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# 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 UserPreference < ActiveRecord::Base
|
||||||
|
belongs_to :user
|
||||||
|
serialize :others
|
||||||
|
|
||||||
|
attr_protected :others
|
||||||
|
|
||||||
|
def initialize(attributes = nil)
|
||||||
|
super
|
||||||
|
self.others ||= {}
|
||||||
|
end
|
||||||
|
|
||||||
|
def [](attr_name)
|
||||||
|
if attribute_present? attr_name
|
||||||
|
super
|
||||||
|
else
|
||||||
|
others[attr_name]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def []=(attr_name, value)
|
||||||
|
if attribute_present? attr_name
|
||||||
|
super
|
||||||
|
else
|
||||||
|
others.store attr_name, value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -19,10 +19,11 @@ class Version < ActiveRecord::Base
|
|||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
|
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
|
||||||
has_many :attachments, :as => :container, :dependent => true
|
has_many :attachments, :as => :container, :dependent => :destroy
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name, :scope => [:project_id]
|
validates_uniqueness_of :name, :scope => [:project_id]
|
||||||
|
validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_integrity
|
def check_integrity
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<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>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<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>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<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 %></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>
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<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 %>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<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>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<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>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<h2><%=l(:label_information_plural)%></h2>
|
||||||
|
|
||||||
|
<p><%=l(:field_version)%>: <strong>redMine <%= Redmine::VERSION %></strong></p>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<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 %>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<p><%= check_all_links 'mail_options_form' %></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= submit_tag l(:button_save) %>
|
||||||
|
<% end %>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<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>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<%= 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]-->
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<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 %>
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<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 %>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<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 %>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<h2>404</h2>
|
||||||
|
|
||||||
|
<p><%= l(:notice_file_not_found) %></p>
|
||||||
|
<p><a href="javascript:history.back()">Back</a></p>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user