Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
366d46c701 | ||
|
|
7363428703 | ||
|
|
25f8c64f92 | ||
|
|
fd2839c833 | ||
|
|
1cb5fc747f | ||
|
|
4670426e4e | ||
|
|
05c1888703 | ||
|
|
e94e88e3ad | ||
|
|
9c38458f8b | ||
|
|
98cf33070f | ||
|
|
5e20417e6d | ||
|
|
bf74efcd11 | ||
|
|
384aa50be3 | ||
|
|
8687401d65 | ||
|
|
7eba6786d3 | ||
|
|
65be9d3c86 | ||
|
|
87bad767c6 | ||
|
|
f816d4f378 | ||
|
|
184be9d0e3 | ||
|
|
7eb3b186c4 | ||
|
|
ba1b857197 | ||
|
|
faa3d984ab | ||
|
|
6d7a855ca2 | ||
|
|
600018d5ad | ||
|
|
ec44c94c12 | ||
|
|
48c2a690c2 | ||
|
|
1a2aee84b2 | ||
|
|
1c44600c62 | ||
|
|
5332c4362c | ||
|
|
f2acb56041 | ||
|
|
ff1343882a | ||
|
|
2dbb397818 | ||
|
|
136a2a614b | ||
|
|
a681d8bf4d | ||
|
|
438161ad1f | ||
|
|
4dddb606a6 | ||
|
|
22c7419a70 | ||
|
|
7fb03b1ca3 | ||
|
|
97f6315bd0 | ||
|
|
e7ff47cff5 | ||
|
|
4a20ece43e | ||
|
|
b2d4666bf1 | ||
|
|
515caa8f37 | ||
|
|
4cf1b68969 | ||
|
|
413247ee5b | ||
|
|
70374d084e | ||
|
|
f335e943ad | ||
|
|
f04225321c | ||
|
|
f12315075f | ||
|
|
c99da15445 | ||
|
|
ef39db234b | ||
|
|
8af6d24a36 | ||
|
|
f8ef65e8f6 | ||
|
|
6446c312be | ||
|
|
4a524ff911 | ||
|
|
9fe0dd051d | ||
|
|
3782501275 | ||
|
|
d34ea9a569 | ||
|
|
bb1fccb7b7 | ||
|
|
777c9acae8 | ||
|
|
7b13b58a2f | ||
|
|
b11dd1f213 | ||
|
|
7ca7e4bad5 | ||
|
|
bca5bd9c62 | ||
|
|
b90e84b9fe | ||
|
|
75582f80f8 | ||
|
|
270e3a4345 | ||
|
|
0fab627a3c | ||
|
|
599e49e4d0 | ||
|
|
cff3950e6b | ||
|
|
42193960f2 | ||
|
|
98d08439dc | ||
|
|
8614c00c8a | ||
|
|
df0a49ff14 | ||
|
|
50429d0819 | ||
|
|
5c88c1f50b | ||
|
|
d85f5518d9 | ||
|
|
8e24c6458d | ||
|
|
b748455d96 | ||
|
|
7eb6471559 | ||
|
|
56513a8c66 | ||
|
|
8b1455c945 | ||
|
|
b9be1d1268 | ||
|
|
71e6f22670 | ||
|
|
0dbbf776c6 | ||
|
|
3eed7e622c | ||
|
|
a6a181c70c | ||
|
|
92b02014d2 | ||
|
|
987e843cd1 | ||
|
|
5050586a9e | ||
|
|
da4fd6b71a | ||
|
|
e07c44543f | ||
|
|
78b5e57a4a | ||
|
|
10a49d476d | ||
|
|
0759212a44 | ||
|
|
7eda64e464 | ||
|
|
124cca3af0 | ||
|
|
7faf77804d | ||
|
|
d94bcd285a | ||
|
|
9af49e07f3 | ||
|
|
0f0ab74560 | ||
|
|
5288b8550b | ||
|
|
66d789229d | ||
|
|
bba9be6a4d | ||
|
|
ebe10fa645 | ||
|
|
833c5035a6 | ||
|
|
aa3445bdb6 | ||
|
|
66fe12db71 | ||
|
|
5db3396c07 | ||
|
|
c1a18a2889 | ||
|
|
89db185726 | ||
|
|
a301d0eb4e | ||
|
|
076655cdd8 | ||
|
|
8e4a5996b0 | ||
|
|
52547466f0 | ||
|
|
4967fa8733 | ||
|
|
8065001c0d | ||
|
|
72a5839931 | ||
|
|
c995be94d9 | ||
|
|
018b81a46a | ||
|
|
941a240535 | ||
|
|
ed5b5d0559 | ||
|
|
104b7d457d | ||
|
|
feb973b970 | ||
|
|
e02068eb2a | ||
|
|
eea1878a3b | ||
|
|
4499c7a030 | ||
|
|
2f1d8630f1 | ||
|
|
cf59496957 | ||
|
|
32de29ea35 | ||
|
|
8d7de50ca8 | ||
|
|
3d685f7bec | ||
|
|
05b08ae38f | ||
|
|
623d2f25b1 | ||
|
|
634d3557f2 | ||
|
|
6957eceee0 | ||
|
|
5097f6394d | ||
|
|
77cfc1cc59 | ||
|
|
5d8200b9fc | ||
|
|
18255881ca | ||
|
|
2fb84af3e9 | ||
|
|
907f906ec6 | ||
|
|
acfb87a07b | ||
|
|
c10541feb7 | ||
|
|
e72778ea84 | ||
|
|
a824017d8c | ||
|
|
d570bc5cc5 | ||
|
|
559b2069ac | ||
|
|
6c5e89ede0 | ||
|
|
6a8ddc954f | ||
|
|
8f1c0eb2dd | ||
|
|
8c01275ee9 | ||
|
|
d6f4208a15 | ||
|
|
2e78bc1bc4 | ||
|
|
20feb44564 | ||
|
|
1506d3ddab | ||
|
|
5cb64fff91 | ||
|
|
1adf56664d | ||
|
|
183ede84fd | ||
|
|
bd9a44c225 | ||
|
|
30734ba8e8 | ||
|
|
cf4651b6bb | ||
|
|
14314b77ee | ||
|
|
ef71edd331 | ||
|
|
708c3c9ec6 | ||
|
|
c1a5c5b9f8 | ||
|
|
1cc7006555 | ||
|
|
3f87f3c47a | ||
|
|
f3a1b4e38c | ||
|
|
7eb4abae80 | ||
|
|
0ea1b712be | ||
|
|
9cf96580bf | ||
|
|
46d67cb349 | ||
|
|
f7d5141251 | ||
|
|
8e11dac375 | ||
|
|
adee6de140 | ||
|
|
4ed89dc2d3 | ||
|
|
8e6d575d4e | ||
|
|
e227b92972 | ||
|
|
a9a082f05c | ||
|
|
be54cb9531 | ||
|
|
18a6b8e101 | ||
|
|
52ced19e2e | ||
|
|
1c0971b12c | ||
|
|
2db9bdf7a2 | ||
|
|
a09b2a23b9 | ||
|
|
6d2ecefca0 | ||
|
|
568c22016a | ||
|
|
6e1b9326e4 | ||
|
|
3c8a38212e | ||
|
|
eba4af7a9f | ||
|
|
f8a5725214 | ||
|
|
791077c240 | ||
|
|
bd8de9a6f8 | ||
|
|
0a82489ddc | ||
|
|
006b8716ed | ||
|
|
4ff8386e3d | ||
|
|
cb6c8bee47 | ||
|
|
3a35883250 | ||
|
|
2a00565bc4 | ||
|
|
5e0e951867 | ||
|
|
4c75bd404b | ||
|
|
2b70760594 | ||
|
|
d8ce97f766 | ||
|
|
cf221c8f75 | ||
|
|
b938c60396 | ||
|
|
3a28fa01b0 | ||
|
|
8a84884d50 | ||
|
|
b103052ff0 | ||
|
|
71b6dd232e | ||
|
|
1f7863e323 | ||
|
|
e951209d68 | ||
|
|
0ef114e006 | ||
|
|
887f11435b | ||
|
|
d7f1b873c8 | ||
|
|
16f9f50f50 | ||
|
|
6f1dcdc08f | ||
|
|
3cd50da3b0 | ||
|
|
0125ec3b48 | ||
|
|
7611f52faf | ||
|
|
669b2342ff | ||
|
|
1493c2a9b4 | ||
|
|
724ca74f51 | ||
|
|
76d4ac17a2 | ||
|
|
8d54d97007 | ||
|
|
7cf2d889d8 | ||
|
|
59a2d1c974 | ||
|
|
5108a9c6fe | ||
|
|
6e98df0e28 | ||
|
|
f3f75f557a | ||
|
|
8bf5759d26 | ||
|
|
cbf797ed95 | ||
|
|
17c4d733d0 | ||
|
|
dd52fb7e2e | ||
|
|
b1f5103c75 | ||
|
|
f19e8af33b | ||
|
|
a559c0cfc2 | ||
|
|
5132252daa | ||
|
|
dfb81dd89c | ||
|
|
59e3802c74 | ||
|
|
a1d2acd574 | ||
|
|
8bb60b6474 | ||
|
|
143be7ee02 | ||
|
|
d967bb4a54 | ||
|
|
fd37f37ee4 | ||
|
|
db3e8616c8 | ||
|
|
8fdef1f820 | ||
|
|
b481e76ee2 | ||
|
|
3477f9bfe0 | ||
|
|
10cf1ccc1a | ||
|
|
22b42dc90a | ||
|
|
e6f58e4dcc | ||
|
|
192b9008bd | ||
|
|
56d0af472d | ||
|
|
85f32b956f | ||
|
|
027bf93849 | ||
|
|
071f8e18d0 | ||
|
|
19d962c3aa | ||
|
|
dae2d4686e | ||
|
|
fc3ee67b1f | ||
|
|
a54a15523b | ||
|
|
5b135c07d0 | ||
|
|
dd83445fd7 | ||
|
|
290485b144 | ||
|
|
c514316a2e | ||
|
|
8b98ceb92c | ||
|
|
7a20a4d32b | ||
|
|
8cbb78bb1d | ||
|
|
ef84339003 | ||
|
|
909954ac34 | ||
|
|
d996643540 | ||
|
|
074a4a6e0e | ||
|
|
a6248cba19 | ||
|
|
6a875eb691 | ||
|
|
83c96d4f3e | ||
|
|
1fcc9e977f | ||
|
|
c56b95ed68 | ||
|
|
bb3a5bcfd7 | ||
|
|
35678a1c09 | ||
|
|
c622ad0b50 | ||
|
|
75324e4859 | ||
|
|
93f07c78d6 | ||
|
|
59a619ebbb | ||
|
|
77938cc11e | ||
|
|
ae998984a0 | ||
|
|
2e31311e3c | ||
|
|
32782a7f9f | ||
|
|
4f2d74e25f | ||
|
|
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 |
@@ -0,0 +1,25 @@
|
|||||||
|
# redMine - project management software
|
||||||
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class SysApi < ActionWebService::API::Base
|
||||||
|
api_method :projects,
|
||||||
|
:expects => [],
|
||||||
|
:returns => [[Project]]
|
||||||
|
api_method :repository_created,
|
||||||
|
:expects => [:int, :string],
|
||||||
|
:returns => [:int]
|
||||||
|
end
|
||||||
@@ -1,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
|
||||||
@@ -22,12 +22,17 @@ class AccountController < ApplicationController
|
|||||||
|
|
||||||
# prevents login action to be filtered by check_if_login_required application scope filter
|
# prevents login action to be filtered by check_if_login_required application scope filter
|
||||||
skip_before_filter :check_if_login_required, :only => [:login, :lost_password, :register]
|
skip_before_filter :check_if_login_required, :only => [:login, :lost_password, :register]
|
||||||
before_filter :require_login, :except => [:show, :login, :lost_password, :register]
|
before_filter :require_login, :only => :logout
|
||||||
|
|
||||||
# Show user's account
|
# Show user's account
|
||||||
def show
|
def show
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
@custom_values = @user.custom_values.find(:all, :include => :custom_field)
|
@custom_values = @user.custom_values.find(:all, :include => :custom_field)
|
||||||
|
|
||||||
|
# show only public projects and private projects that the logged in user is also a member of
|
||||||
|
@memberships = @user.memberships.select do |membership|
|
||||||
|
membership.project.is_public? || (logged_in_user && logged_in_user.role_for_project(membership.project))
|
||||||
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
@@ -42,6 +47,11 @@ class AccountController < ApplicationController
|
|||||||
user = User.try_to_login(params[:login], params[:password])
|
user = User.try_to_login(params[:login], params[:password])
|
||||||
if user
|
if user
|
||||||
self.logged_in_user = user
|
self.logged_in_user = user
|
||||||
|
# generate a key and set cookie if autologin
|
||||||
|
if params[:autologin] && Setting.autologin?
|
||||||
|
token = Token.create(:user => user, :action => 'autologin')
|
||||||
|
cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }
|
||||||
|
end
|
||||||
redirect_back_or_default :controller => 'my', :action => 'page'
|
redirect_back_or_default :controller => 'my', :action => 'page'
|
||||||
else
|
else
|
||||||
flash.now[:notice] = l(:notice_account_invalid_creditentials)
|
flash.now[:notice] = l(:notice_account_invalid_creditentials)
|
||||||
@@ -51,15 +61,18 @@ class AccountController < ApplicationController
|
|||||||
|
|
||||||
# Log out current user and redirect to welcome page
|
# Log out current user and redirect to welcome page
|
||||||
def logout
|
def logout
|
||||||
|
cookies.delete :autologin
|
||||||
|
Token.delete_all(["user_id = ? AND action = ?", logged_in_user.id, "autologin"]) if logged_in_user
|
||||||
self.logged_in_user = nil
|
self.logged_in_user = nil
|
||||||
redirect_to :controller => ''
|
redirect_to :controller => 'welcome'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Enable user to choose a new password
|
# Enable user to choose a new password
|
||||||
def lost_password
|
def lost_password
|
||||||
|
redirect_to :controller => 'welcome' and return unless Setting.lost_password?
|
||||||
if params[:token]
|
if params[:token]
|
||||||
@token = Token.find_by_action_and_value("recovery", params[:token])
|
@token = Token.find_by_action_and_value("recovery", params[:token])
|
||||||
redirect_to :controller => '' and return unless @token and !@token.expired?
|
redirect_to :controller => 'welcome' and return unless @token and !@token.expired?
|
||||||
@user = @token.user
|
@user = @token.user
|
||||||
if request.post?
|
if request.post?
|
||||||
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
||||||
@@ -82,8 +95,6 @@ class AccountController < ApplicationController
|
|||||||
# create a new token for password recovery
|
# create a new token for password recovery
|
||||||
token = Token.new(:user => user, :action => "recovery")
|
token = Token.new(:user => user, :action => "recovery")
|
||||||
if token.save
|
if token.save
|
||||||
# send token to user via email
|
|
||||||
Mailer.set_language_if_valid(user.language)
|
|
||||||
Mailer.deliver_lost_password(token)
|
Mailer.deliver_lost_password(token)
|
||||||
flash[:notice] = l(:notice_account_lost_email_sent)
|
flash[:notice] = l(:notice_account_lost_email_sent)
|
||||||
redirect_to :action => 'login'
|
redirect_to :action => 'login'
|
||||||
@@ -95,12 +106,12 @@ class AccountController < ApplicationController
|
|||||||
|
|
||||||
# User self-registration
|
# User self-registration
|
||||||
def register
|
def register
|
||||||
redirect_to :controller => '' and return if $RDM_SELF_REGISTRATION == false
|
redirect_to :controller => 'welcome' and return unless Setting.self_registration?
|
||||||
if params[:token]
|
if params[:token]
|
||||||
token = Token.find_by_action_and_value("register", params[:token])
|
token = Token.find_by_action_and_value("register", params[:token])
|
||||||
redirect_to :controller => '' and return unless token and !token.expired?
|
redirect_to :controller => 'welcome' and return unless token and !token.expired?
|
||||||
user = token.user
|
user = token.user
|
||||||
redirect_to :controller => '' and return unless user.status == User::STATUS_REGISTERED
|
redirect_to :controller => 'welcome' and return unless user.status == User::STATUS_REGISTERED
|
||||||
user.status = User::STATUS_ACTIVE
|
user.status = User::STATUS_ACTIVE
|
||||||
if user.save
|
if user.save
|
||||||
token.destroy
|
token.destroy
|
||||||
@@ -110,7 +121,7 @@ class AccountController < ApplicationController
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
if request.get?
|
if request.get?
|
||||||
@user = User.new(:language => $RDM_DEFAULT_LANG)
|
@user = User.new(:language => Setting.default_language)
|
||||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
|
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
|
||||||
else
|
else
|
||||||
@user = User.new(params[:user])
|
@user = User.new(params[:user])
|
||||||
@@ -122,10 +133,9 @@ class AccountController < ApplicationController
|
|||||||
@user.custom_values = @custom_values
|
@user.custom_values = @custom_values
|
||||||
token = Token.new(:user => @user, :action => "register")
|
token = Token.new(:user => @user, :action => "register")
|
||||||
if @user.save and token.save
|
if @user.save and token.save
|
||||||
Mailer.set_language_if_valid(@user.language)
|
|
||||||
Mailer.deliver_register(token)
|
Mailer.deliver_register(token)
|
||||||
flash[:notice] = l(:notice_account_register_done)
|
flash[:notice] = l(:notice_account_register_done)
|
||||||
redirect_to :controller => ''
|
redirect_to :controller => 'welcome' and return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,11 +28,17 @@ class AdminController < ApplicationController
|
|||||||
def projects
|
def projects
|
||||||
sort_init 'name', 'asc'
|
sort_init 'name', 'asc'
|
||||||
sort_update
|
sort_update
|
||||||
@project_count = Project.count
|
|
||||||
|
@status = params[:status] ? params[:status].to_i : 0
|
||||||
|
conditions = nil
|
||||||
|
conditions = ["status=?", @status] unless @status == 0
|
||||||
|
|
||||||
|
@project_count = Project.count(:conditions => conditions)
|
||||||
@project_pages = Paginator.new self, @project_count,
|
@project_pages = Paginator.new self, @project_count,
|
||||||
15,
|
25,
|
||||||
params['page']
|
params['page']
|
||||||
@projects = Project.find :all, :order => sort_clause,
|
@projects = Project.find :all, :order => sort_clause,
|
||||||
|
:conditions => conditions,
|
||||||
:limit => @project_pages.items_per_page,
|
:limit => @project_pages.items_per_page,
|
||||||
:offset => @project_pages.current.offset
|
:offset => @project_pages.current.offset
|
||||||
|
|
||||||
@@ -51,6 +57,10 @@ class AdminController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def info
|
def info
|
||||||
@adapter_name = ActiveRecord::Base.connection.adapter_name
|
@db_adapter_name = ActiveRecord::Base.connection.adapter_name
|
||||||
|
@flags = Hash.new
|
||||||
|
@flags[:default_admin_changed] = User.find(:first, :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?
|
||||||
|
@flags[:file_repository_writable] = File.writable?(Attachment.storage_path)
|
||||||
|
@flags[:textile_available] = ActionView::Helpers::TextHelper.method_defined? "textilize"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -17,6 +17,11 @@
|
|||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
before_filter :check_if_login_required, :set_localization
|
before_filter :check_if_login_required, :set_localization
|
||||||
|
filter_parameter_logging :password
|
||||||
|
|
||||||
|
REDMINE_SUPPORTED_SCM.each do |scm|
|
||||||
|
require_dependency "repository/#{scm.underscore}"
|
||||||
|
end
|
||||||
|
|
||||||
def logged_in_user=(user)
|
def logged_in_user=(user)
|
||||||
@logged_in_user = user
|
@logged_in_user = user
|
||||||
@@ -31,9 +36,22 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the role that the logged in user has on the current project
|
||||||
|
# or nil if current user is not a member of the project
|
||||||
|
def logged_in_user_membership
|
||||||
|
@user_membership ||= logged_in_user.role_for_project(@project)
|
||||||
|
end
|
||||||
|
|
||||||
# check if login is globally required to access the application
|
# check if login is globally required to access the application
|
||||||
def check_if_login_required
|
def check_if_login_required
|
||||||
require_login if $RDM_LOGIN_REQUIRED
|
# no check needed if user is already logged in
|
||||||
|
return true if logged_in_user
|
||||||
|
# auto-login feature
|
||||||
|
autologin_key = cookies[:autologin]
|
||||||
|
if autologin_key && Setting.autologin?
|
||||||
|
self.logged_in_user = User.find_by_autologin_key(autologin_key)
|
||||||
|
end
|
||||||
|
require_login if Setting.login_required?
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_localization
|
def set_localization
|
||||||
@@ -48,7 +66,7 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end || $RDM_DEFAULT_LANG
|
end || Setting.default_language
|
||||||
set_language_if_valid(lang)
|
set_language_if_valid(lang)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -64,7 +82,7 @@ class ApplicationController < ActionController::Base
|
|||||||
def require_admin
|
def require_admin
|
||||||
return unless require_login
|
return unless require_login
|
||||||
unless self.logged_in_user.admin?
|
unless self.logged_in_user.admin?
|
||||||
render :nothing => true, :status => 403
|
render_403
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
@@ -72,6 +90,11 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
# authorizes the user for the requested action.
|
# authorizes the user for the requested action.
|
||||||
def authorize(ctrl = params[:controller], action = params[:action])
|
def authorize(ctrl = params[:controller], action = params[:action])
|
||||||
|
unless @project.active?
|
||||||
|
@project = nil
|
||||||
|
render_404
|
||||||
|
return false
|
||||||
|
end
|
||||||
# check if action is allowed on public projects
|
# check if action is allowed on public projects
|
||||||
if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ ctrl, action ]
|
if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ ctrl, action ]
|
||||||
return true
|
return true
|
||||||
@@ -81,30 +104,51 @@ class ApplicationController < ActionController::Base
|
|||||||
# admin is always authorized
|
# admin is always authorized
|
||||||
return true if self.logged_in_user.admin?
|
return true if self.logged_in_user.admin?
|
||||||
# if not admin, check membership permission
|
# 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 logged_in_user_membership and Permission.allowed_to_role( "%s/%s" % [ ctrl, action ], logged_in_user_membership )
|
||||||
if @user_membership and Permission.allowed_to_role( "%s/%s" % [ ctrl, action ], @user_membership.role_id )
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
render :nothing => true, :status => 403
|
render_403
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
# make sure that the user is a member of the project (or admin) if project is private
|
||||||
|
# used as a before_filter for actions that do not require any particular permission on the project
|
||||||
|
def check_project_privacy
|
||||||
|
unless @project.active?
|
||||||
|
@project = nil
|
||||||
|
render_404
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true if @project.is_public?
|
||||||
|
return false unless logged_in_user
|
||||||
|
return true if logged_in_user.admin? || logged_in_user_membership
|
||||||
|
render_403
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# store current uri in session.
|
# store current uri in session.
|
||||||
# return to this location by calling redirect_back_or_default
|
# return to this location by calling redirect_back_or_default
|
||||||
def store_location
|
def store_location
|
||||||
session[:return_to] = request.request_uri
|
session[:return_to_params] = params
|
||||||
end
|
end
|
||||||
|
|
||||||
# move to the last store_location call or to the passed default one
|
# move to the last store_location call or to the passed default one
|
||||||
def redirect_back_or_default(default)
|
def redirect_back_or_default(default)
|
||||||
if session[:return_to].nil?
|
if session[:return_to_params].nil?
|
||||||
redirect_to default
|
redirect_to default
|
||||||
else
|
else
|
||||||
redirect_to_url session[:return_to]
|
redirect_to session[:return_to_params]
|
||||||
session[:return_to] = nil
|
session[:return_to_params] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_403
|
||||||
|
@html_title = "403"
|
||||||
|
@project = nil
|
||||||
|
render :template => "common/403", :layout => true, :status => 403
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
def render_404
|
def render_404
|
||||||
@html_title = "404"
|
@html_title = "404"
|
||||||
render :template => "common/404", :layout => true, :status => 404
|
render :template => "common/404", :layout => true, :status => 404
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# 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 AttachmentsController < ApplicationController
|
||||||
|
layout 'base'
|
||||||
|
before_filter :find_project, :check_project_privacy
|
||||||
|
|
||||||
|
# sends an attachment
|
||||||
|
def download
|
||||||
|
send_file @attachment.diskfile, :filename => @attachment.filename
|
||||||
|
rescue
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
# sends an image to be displayed inline
|
||||||
|
def show
|
||||||
|
render(:nothing => true, :status => 404) and return unless @attachment.diskfile =~ /\.(jpeg|jpg|gif|png)$/i
|
||||||
|
send_file @attachment.diskfile, :filename => @attachment.filename, :type => "image/#{$1}", :disposition => 'inline'
|
||||||
|
rescue
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_project
|
||||||
|
@attachment = Attachment.find(params[:id])
|
||||||
|
@project = @attachment.project
|
||||||
|
rescue
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
# 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 BoardsController < ApplicationController
|
||||||
|
layout 'base'
|
||||||
|
before_filter :find_project
|
||||||
|
before_filter :authorize, :except => [:index, :show]
|
||||||
|
before_filter :check_project_privacy, :only => [:index, :show]
|
||||||
|
|
||||||
|
helper :messages
|
||||||
|
include MessagesHelper
|
||||||
|
helper :sort
|
||||||
|
include SortHelper
|
||||||
|
helper :watchers
|
||||||
|
include WatchersHelper
|
||||||
|
|
||||||
|
def index
|
||||||
|
@boards = @project.boards
|
||||||
|
# show the board if there is only one
|
||||||
|
if @boards.size == 1
|
||||||
|
@board = @boards.first
|
||||||
|
show
|
||||||
|
render :action => 'show'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
sort_init "#{Message.table_name}.updated_on", "desc"
|
||||||
|
sort_update
|
||||||
|
|
||||||
|
@topic_count = @board.topics.count
|
||||||
|
@topic_pages = Paginator.new self, @topic_count, 25, params['page']
|
||||||
|
@topics = @board.topics.find :all, :order => sort_clause,
|
||||||
|
:include => [:author, {:last_reply => :author}],
|
||||||
|
:limit => @topic_pages.items_per_page,
|
||||||
|
:offset => @topic_pages.current.offset
|
||||||
|
render :action => 'show', :layout => false if request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
|
verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index }
|
||||||
|
|
||||||
|
def new
|
||||||
|
@board = Board.new(params[:board])
|
||||||
|
@board.project = @project
|
||||||
|
if request.post? && @board.save
|
||||||
|
flash[:notice] = l(:notice_successful_create)
|
||||||
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
if request.post? && @board.update_attributes(params[:board])
|
||||||
|
case params[:position]
|
||||||
|
when 'highest'; @board.move_to_top
|
||||||
|
when 'higher'; @board.move_higher
|
||||||
|
when 'lower'; @board.move_lower
|
||||||
|
when 'lowest'; @board.move_to_bottom
|
||||||
|
end if params[:position]
|
||||||
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@board.destroy
|
||||||
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_project
|
||||||
|
@project = Project.find(params[:project_id])
|
||||||
|
@board = @project.boards.find(params[:id]) if params[:id]
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -25,7 +25,8 @@ class CustomFieldsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def list
|
def list
|
||||||
@custom_field_pages, @custom_fields = paginate :custom_fields, :per_page => 15
|
@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?
|
render :action => "list", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -44,9 +45,9 @@ class CustomFieldsController < ApplicationController
|
|||||||
end
|
end
|
||||||
if request.post? and @custom_field.save
|
if request.post? and @custom_field.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list', :tab => @custom_field.type
|
||||||
end
|
end
|
||||||
@trackers = Tracker.find(:all)
|
@trackers = Tracker.find(:all, :order => 'position')
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@@ -56,14 +57,14 @@ class CustomFieldsController < ApplicationController
|
|||||||
@custom_field.trackers = params[:tracker_ids] ? Tracker.find(params[:tracker_ids]) : []
|
@custom_field.trackers = params[:tracker_ids] ? Tracker.find(params[:tracker_ids]) : []
|
||||||
end
|
end
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list', :tab => @custom_field.type
|
||||||
end
|
end
|
||||||
@trackers = Tracker.find(:all)
|
@trackers = Tracker.find(:all, :order => 'position')
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
CustomField.find(params[:id]).destroy
|
@custom_field = CustomField.find(params[:id]).destroy
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list', :tab => @custom_field.type
|
||||||
rescue
|
rescue
|
||||||
flash[:notice] = "Unable to delete custom field"
|
flash[:notice] = "Unable to delete custom field"
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -46,9 +46,13 @@ class DocumentsController < ApplicationController
|
|||||||
|
|
||||||
def add_attachment
|
def add_attachment
|
||||||
# Save the attachments
|
# Save the attachments
|
||||||
params[:attachments].each { |a|
|
@attachments = []
|
||||||
Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
|
params[:attachments].each { |file|
|
||||||
|
next unless file.size > 0
|
||||||
|
a = Attachment.create(:container => @document, :file => file, :author => logged_in_user)
|
||||||
|
@attachments << a unless a.new_record?
|
||||||
} if params[:attachments] and params[:attachments].is_a? Array
|
} 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
|
redirect_to :action => 'show', :id => @document
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -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,10 +16,83 @@
|
|||||||
# 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 FeedsController < ApplicationController
|
class FeedsController < ApplicationController
|
||||||
|
before_filter :find_scope
|
||||||
session :off
|
session :off
|
||||||
|
|
||||||
|
helper :issues
|
||||||
|
include IssuesHelper
|
||||||
|
helper :custom_fields
|
||||||
|
include CustomFieldsHelper
|
||||||
|
|
||||||
|
# news feeds
|
||||||
def news
|
def news
|
||||||
@news = News.find :all, :order => 'news.created_on DESC', :limit => 10, :include => [ :author, :project ]
|
News.with_scope(:find => @find_options) do
|
||||||
@headers["Content-Type"] = "application/rss+xml"
|
@news = News.find :all, :order => "#{News.table_name}.created_on DESC", :include => [ :author, :project ]
|
||||||
|
end
|
||||||
|
headers["Content-Type"] = "application/rss+xml"
|
||||||
|
render :action => 'news_atom' if 'atom' == params[:format]
|
||||||
|
end
|
||||||
|
|
||||||
|
# issue feeds
|
||||||
|
def issues
|
||||||
|
if @project && params[:query_id]
|
||||||
|
query = Query.find(params[:query_id])
|
||||||
|
query.executed_by = @user
|
||||||
|
# ignore query if it's not valid
|
||||||
|
query = nil unless query.valid?
|
||||||
|
# override with query conditions
|
||||||
|
@find_options[:conditions] = query.statement if query.valid? and @project == query.project
|
||||||
|
end
|
||||||
|
|
||||||
|
Issue.with_scope(:find => @find_options) do
|
||||||
|
@issues = Issue.find :all, :include => [:project, :author, :tracker, :status, :custom_values],
|
||||||
|
:order => "#{Issue.table_name}.created_on DESC"
|
||||||
|
end
|
||||||
|
@title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
|
||||||
|
headers["Content-Type"] = "application/rss+xml"
|
||||||
|
render :action => 'issues_atom' if 'atom' == params[:format]
|
||||||
|
end
|
||||||
|
|
||||||
|
# issue changes feeds
|
||||||
|
def history
|
||||||
|
if @project && params[:query_id]
|
||||||
|
query = Query.find(params[:query_id])
|
||||||
|
query.executed_by = @user
|
||||||
|
# ignore query if it's not valid
|
||||||
|
query = nil unless query.valid?
|
||||||
|
# override with query conditions
|
||||||
|
@find_options[:conditions] = query.statement if query.valid? and @project == query.project
|
||||||
|
end
|
||||||
|
|
||||||
|
Journal.with_scope(:find => @find_options) do
|
||||||
|
@journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status, :custom_values]} ],
|
||||||
|
:order => "#{Journal.table_name}.created_on DESC"
|
||||||
|
end
|
||||||
|
|
||||||
|
@title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
|
||||||
|
headers["Content-Type"] = "application/rss+xml"
|
||||||
|
render :action => 'history_atom' if 'atom' == params[:format]
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
# override for feeds specific authentication
|
||||||
|
def check_if_login_required
|
||||||
|
@user = User.find_by_rss_key(params[:key])
|
||||||
|
render(:nothing => true, :status => 403) and return false if !@user && Setting.login_required?
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_scope
|
||||||
|
if params[:project_id]
|
||||||
|
# project feed
|
||||||
|
# check if project is public or if the user is a member
|
||||||
|
@project = Project.find(params[:project_id])
|
||||||
|
render(:nothing => true, :status => 403) and return false unless @project.is_public? || (@user && @user.role_for_project(@project))
|
||||||
|
scope = ["#{Project.table_name}.id=?", params[:project_id].to_i]
|
||||||
|
else
|
||||||
|
# global feed
|
||||||
|
scope = ["#{Project.table_name}.is_public=?", true]
|
||||||
|
end
|
||||||
|
@find_options = {:conditions => scope, :limit => Setting.feeds_limit.to_i}
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,11 +33,8 @@ class HelpController < ApplicationController
|
|||||||
# choose language according to available help translations
|
# choose language according to available help translations
|
||||||
lang = (@help_config['langs'].include? current_language.to_s) ? current_language.to_s : @help_config['langs'].first
|
lang = (@help_config['langs'].include? current_language.to_s) ? current_language.to_s : @help_config['langs'].first
|
||||||
|
|
||||||
if template
|
url = "/manual/#{lang}/" + (template || "index.html")
|
||||||
redirect_to "/manual/#{lang}/#{template}"
|
redirect_to(request.relative_url_root + url)
|
||||||
else
|
|
||||||
redirect_to "/manual/#{lang}/index.html"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -16,22 +16,22 @@
|
|||||||
# 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] = l(:notice_successful_update)
|
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
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# 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 IssueRelationsController < ApplicationController
|
||||||
|
layout 'base'
|
||||||
|
before_filter :find_project, :authorize
|
||||||
|
|
||||||
|
def new
|
||||||
|
@relation = IssueRelation.new(params[:relation])
|
||||||
|
@relation.issue_from = @issue
|
||||||
|
@relation.save if request.post?
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
||||||
|
format.js do
|
||||||
|
render :update do |page|
|
||||||
|
page.replace_html "relations", :partial => 'issues/relations'
|
||||||
|
if @relation.errors.empty?
|
||||||
|
page << "$('relation_delay').value = ''"
|
||||||
|
page << "$('relation_issue_to_id').value = ''"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
relation = IssueRelation.find(params[:id])
|
||||||
|
if request.post? && @issue.relations.include?(relation)
|
||||||
|
relation.destroy
|
||||||
|
@issue.reload
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
||||||
|
format.js { render(:update) {|page| page.replace_html "relations", :partial => 'issues/relations'} }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_project
|
||||||
|
@issue = Issue.find(params[:issue_id])
|
||||||
|
@project = @issue.project
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -16,8 +16,11 @@
|
|||||||
# 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
|
||||||
@@ -25,7 +28,7 @@ class IssueStatusesController < ApplicationController
|
|||||||
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?
|
render :action => "list", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -57,6 +60,21 @@ class IssueStatusesController < ApplicationController
|
|||||||
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'
|
||||||
@@ -64,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
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -19,27 +19,37 @@ class IssuesController < ApplicationController
|
|||||||
layout 'base', :except => :export_pdf
|
layout 'base', :except => :export_pdf
|
||||||
before_filter :find_project, :authorize
|
before_filter :find_project, :authorize
|
||||||
|
|
||||||
|
cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
|
||||||
|
|
||||||
|
helper :projects
|
||||||
|
include ProjectsHelper
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
include CustomFieldsHelper
|
include CustomFieldsHelper
|
||||||
helper :ifpdf
|
helper :ifpdf
|
||||||
include IfpdfHelper
|
include IfpdfHelper
|
||||||
|
helper :issue_relations
|
||||||
|
include IssueRelationsHelper
|
||||||
|
helper :watchers
|
||||||
|
include WatchersHelper
|
||||||
|
helper :attachments
|
||||||
|
include AttachmentsHelper
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@status_options = @issue.status.workflows.find(:all, :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
|
@status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
|
||||||
@custom_values = @issue.custom_values.find(:all, :include => :custom_field)
|
@custom_values = @issue.custom_values.find(:all, :include => :custom_field)
|
||||||
@journals_count = @issue.journals.count
|
@journals_count = @issue.journals.count
|
||||||
@journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "journals.created_on desc")
|
@journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "#{Journal.table_name}.created_on desc")
|
||||||
end
|
end
|
||||||
|
|
||||||
def history
|
def history
|
||||||
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "journals.created_on desc")
|
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on desc")
|
||||||
@journals_count = @journals.length
|
@journals_count = @journals.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_pdf
|
def export_pdf
|
||||||
@custom_values = @issue.custom_values.find(:all, :include => :custom_field)
|
@custom_values = @issue.custom_values.find(:all, :include => :custom_field)
|
||||||
@options_for_rfpdf ||= {}
|
@options_for_rfpdf ||= {}
|
||||||
@options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.long_id}.pdf"
|
@options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.id}.pdf"
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@@ -67,9 +77,6 @@ class IssuesController < ApplicationController
|
|||||||
def add_note
|
def add_note
|
||||||
unless params[:notes].empty?
|
unless params[:notes].empty?
|
||||||
journal = @issue.init_journal(self.logged_in_user, params[:notes])
|
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
|
if @issue.save
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||||||
@@ -82,20 +89,29 @@ class IssuesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def change_status
|
def change_status
|
||||||
#@history = @issue.histories.build(params[:history])
|
@status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
|
||||||
@status_options = @issue.status.workflows.find(:all, :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])
|
@new_status = IssueStatus.find(params[:new_status_id])
|
||||||
if params[:confirm]
|
if params[:confirm]
|
||||||
begin
|
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])
|
journal = @issue.init_journal(self.logged_in_user, params[:notes])
|
||||||
@issue.status = @new_status
|
@issue.status = @new_status
|
||||||
if @issue.update_attributes(params[:issue])
|
if @issue.update_attributes(params[:issue])
|
||||||
|
# Save attachments
|
||||||
|
params[:attachments].each { |file|
|
||||||
|
next unless file.size > 0
|
||||||
|
a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
|
||||||
|
journal.details << JournalDetail.new(:property => 'attachment',
|
||||||
|
:prop_key => a.id,
|
||||||
|
:value => a.filename) unless a.new_record?
|
||||||
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
|
|
||||||
|
# Log time
|
||||||
|
if logged_in_user.authorized_to(@project, "timelog/edit")
|
||||||
|
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => logged_in_user, :spent_on => Date.today)
|
||||||
|
@time_entry.attributes = params[:time_entry]
|
||||||
|
@time_entry.save
|
||||||
|
end
|
||||||
|
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||||||
redirect_to :action => 'show', :id => @issue
|
redirect_to :action => 'show', :id => @issue
|
||||||
@@ -106,6 +122,7 @@ class IssuesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
@assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
|
@assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
|
||||||
|
@activities = Enumeration::get_values('ACTI')
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@@ -115,26 +132,32 @@ class IssuesController < ApplicationController
|
|||||||
|
|
||||||
def add_attachment
|
def add_attachment
|
||||||
# Save the attachments
|
# Save the attachments
|
||||||
params[:attachments].each { |a|
|
@attachments = []
|
||||||
@attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
|
journal = @issue.init_journal(self.logged_in_user)
|
||||||
@attachment.save
|
params[:attachments].each { |file|
|
||||||
|
next unless file.size > 0
|
||||||
|
a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
|
||||||
|
@attachments << a unless a.new_record?
|
||||||
|
journal.details << JournalDetail.new(:property => 'attachment',
|
||||||
|
:prop_key => a.id,
|
||||||
|
:value => a.filename) unless a.new_record?
|
||||||
} if params[:attachments] and params[:attachments].is_a? Array
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
|
journal.save if journal.details.any?
|
||||||
|
Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
||||||
redirect_to :action => 'show', :id => @issue
|
redirect_to :action => 'show', :id => @issue
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_attachment
|
def destroy_attachment
|
||||||
@issue.attachments.find(params[:attachment_id]).destroy
|
a = @issue.attachments.find(params[:attachment_id])
|
||||||
|
a.destroy
|
||||||
|
journal = @issue.init_journal(self.logged_in_user)
|
||||||
|
journal.details << JournalDetail.new(:property => 'attachment',
|
||||||
|
:prop_key => a.id,
|
||||||
|
:old_value => a.filename)
|
||||||
|
journal.save
|
||||||
redirect_to :action => 'show', :id => @issue
|
redirect_to :action => 'show', :id => @issue
|
||||||
end
|
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
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
|
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
|
||||||
|
|||||||
@@ -16,21 +16,25 @@
|
|||||||
# 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] = l(:notice_successful_update)
|
respond_to do |format|
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
||||||
end
|
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/members'} }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@member.destroy
|
@member.destroy
|
||||||
flash[:notice] = l(:notice_successful_delete)
|
respond_to do |format|
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :id => @project
|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
||||||
end
|
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/members'} }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@@ -39,5 +43,4 @@ private
|
|||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
# 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 MessagesController < ApplicationController
|
||||||
|
layout 'base'
|
||||||
|
before_filter :find_project, :check_project_privacy
|
||||||
|
before_filter :require_login, :only => [:new, :reply]
|
||||||
|
|
||||||
|
verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show }
|
||||||
|
|
||||||
|
helper :attachments
|
||||||
|
include AttachmentsHelper
|
||||||
|
|
||||||
|
def show
|
||||||
|
@reply = Message.new(:subject => "RE: #{@message.subject}")
|
||||||
|
render :action => "show", :layout => false if request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@message = Message.new(params[:message])
|
||||||
|
@message.author = logged_in_user
|
||||||
|
@message.board = @board
|
||||||
|
if request.post? && @message.save
|
||||||
|
params[:attachments].each { |file|
|
||||||
|
next unless file.size > 0
|
||||||
|
Attachment.create(:container => @message, :file => file, :author => logged_in_user)
|
||||||
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
|
redirect_to :action => 'show', :id => @message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def reply
|
||||||
|
@reply = Message.new(params[:reply])
|
||||||
|
@reply.author = logged_in_user
|
||||||
|
@reply.board = @board
|
||||||
|
@message.children << @reply
|
||||||
|
redirect_to :action => 'show', :id => @message
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_project
|
||||||
|
@board = Board.find(params[:board_id], :include => :project)
|
||||||
|
@project = @board.project
|
||||||
|
@message = @board.topics.find(params[:id]) if params[:id]
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -19,13 +19,18 @@ class MyController < ApplicationController
|
|||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :require_login
|
before_filter :require_login
|
||||||
|
|
||||||
BLOCKS = { 'issues_assigned_to_me' => :label_assigned_to_me_issues,
|
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
|
||||||
'issues_reported_by_me' => :label_reported_issues,
|
'issuesreportedbyme' => :label_reported_issues,
|
||||||
'latest_news' => :label_news_latest,
|
'issueswatched' => :label_watched_issues,
|
||||||
|
'news' => :label_news_latest,
|
||||||
'calendar' => :label_calendar,
|
'calendar' => :label_calendar,
|
||||||
'documents' => :label_document_plural
|
'documents' => :label_document_plural
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'],
|
||||||
|
'right' => ['issuesreportedbyme']
|
||||||
|
}.freeze
|
||||||
|
|
||||||
verify :xhr => true,
|
verify :xhr => true,
|
||||||
:session => :page_layout,
|
:session => :page_layout,
|
||||||
:only => [:add_block, :remove_block, :order_blocks]
|
:only => [:add_block, :remove_block, :order_blocks]
|
||||||
@@ -38,7 +43,7 @@ class MyController < ApplicationController
|
|||||||
# Show user's page
|
# Show user's page
|
||||||
def page
|
def page
|
||||||
@user = self.logged_in_user
|
@user = self.logged_in_user
|
||||||
@blocks = @user.pref[:my_page_layout] || { 'left' => ['issues_assigned_to_me'], 'right' => ['issues_reported_by_me'] }
|
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT
|
||||||
end
|
end
|
||||||
|
|
||||||
# Edit user's account
|
# Edit user's account
|
||||||
@@ -47,7 +52,7 @@ class MyController < ApplicationController
|
|||||||
@pref = @user.pref
|
@pref = @user.pref
|
||||||
@user.attributes = params[:user]
|
@user.attributes = params[:user]
|
||||||
@user.pref.attributes = params[:pref]
|
@user.pref.attributes = params[:pref]
|
||||||
if request.post? and @user.save
|
if request.post? and @user.save and @user.pref.save
|
||||||
set_localization
|
set_localization
|
||||||
flash.now[:notice] = l(:notice_account_updated)
|
flash.now[:notice] = l(:notice_account_updated)
|
||||||
self.logged_in_user.reload
|
self.logged_in_user.reload
|
||||||
@@ -75,7 +80,7 @@ class MyController < ApplicationController
|
|||||||
# User's page layout configuration
|
# User's page layout configuration
|
||||||
def page_layout
|
def page_layout
|
||||||
@user = self.logged_in_user
|
@user = self.logged_in_user
|
||||||
@blocks = @user.pref[:my_page_layout] || { 'left' => ['issues_assigned_to_me'], 'right' => ['issues_reported_by_me'] }
|
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup
|
||||||
session[:page_layout] = @blocks
|
session[:page_layout] = @blocks
|
||||||
%w(top left right).each {|f| session[:page_layout][f] ||= [] }
|
%w(top left right).each {|f| session[:page_layout][f] ||= [] }
|
||||||
@block_options = []
|
@block_options = []
|
||||||
@@ -86,8 +91,9 @@ class MyController < ApplicationController
|
|||||||
# The block is added on top of the page
|
# The block is added on top of the page
|
||||||
# params[:block] : id of the block to add
|
# params[:block] : id of the block to add
|
||||||
def add_block
|
def add_block
|
||||||
@user = self.logged_in_user
|
|
||||||
block = params[:block]
|
block = params[:block]
|
||||||
|
render(:nothing => true) and return unless block && (BLOCKS.keys.include? block)
|
||||||
|
@user = self.logged_in_user
|
||||||
# remove if already present in a group
|
# remove if already present in a group
|
||||||
%w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }
|
%w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }
|
||||||
# add it on top
|
# add it on top
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
# 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 NewsController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :find_project, :authorize
|
before_filter :find_project, :authorize
|
||||||
|
|
||||||
def show
|
def show
|
||||||
end
|
end
|
||||||
@@ -45,10 +45,10 @@ class NewsController < ApplicationController
|
|||||||
redirect_to :action => 'show', :id => @news
|
redirect_to :action => 'show', :id => @news
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@news.destroy
|
@news.destroy
|
||||||
redirect_to :controller => 'projects', :action => 'list_news', :id => @project
|
redirect_to :controller => 'projects', :action => 'list_news', :id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
|
|||||||
@@ -15,10 +15,16 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
require 'csv'
|
||||||
|
|
||||||
class ProjectsController < ApplicationController
|
class ProjectsController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
|
before_filter :find_project, :except => [ :index, :list, :add ]
|
||||||
before_filter :require_admin, :only => [ :add, :destroy ]
|
before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ]
|
||||||
|
before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
|
||||||
|
|
||||||
|
cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ]
|
||||||
|
cache_sweeper :issue_sweeper, :only => [ :add_issue ]
|
||||||
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
@@ -29,6 +35,8 @@ class ProjectsController < ApplicationController
|
|||||||
helper IssuesHelper
|
helper IssuesHelper
|
||||||
helper :queries
|
helper :queries
|
||||||
include QueriesHelper
|
include QueriesHelper
|
||||||
|
helper :repositories
|
||||||
|
include RepositoriesHelper
|
||||||
|
|
||||||
def index
|
def index
|
||||||
list
|
list
|
||||||
@@ -37,14 +45,15 @@ class ProjectsController < ApplicationController
|
|||||||
|
|
||||||
# Lists public projects
|
# Lists public projects
|
||||||
def list
|
def list
|
||||||
sort_init 'name', 'asc'
|
sort_init "#{Project.table_name}.name", "asc"
|
||||||
sort_update
|
sort_update
|
||||||
@project_count = Project.count(["is_public=?", true])
|
@project_count = Project.count(:all, :conditions => Project.visible_by(logged_in_user))
|
||||||
@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,
|
||||||
:conditions => ["is_public=?", true],
|
:conditions => Project.visible_by(logged_in_user),
|
||||||
|
:include => :parent,
|
||||||
:limit => @project_pages.items_per_page,
|
:limit => @project_pages.items_per_page,
|
||||||
:offset => @project_pages.current.offset
|
:offset => @project_pages.current.offset
|
||||||
|
|
||||||
@@ -63,9 +72,13 @@ class ProjectsController < ApplicationController
|
|||||||
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
|
@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
|
@project.custom_values = @custom_values
|
||||||
if params[:repository_enabled] && params[:repository_enabled] == "1"
|
if params[:repository_enabled] && params[:repository_enabled] == "1"
|
||||||
@project.repository = Repository.new
|
@project.repository = Repository.factory(params[:repository_scm])
|
||||||
@project.repository.attributes = params[:repository]
|
@project.repository.attributes = params[:repository]
|
||||||
end
|
end
|
||||||
|
if "1" == params[:wiki_enabled]
|
||||||
|
@project.wiki = Wiki.new
|
||||||
|
@project.wiki.attributes = params[:wiki]
|
||||||
|
end
|
||||||
if @project.save
|
if @project.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :controller => 'admin', :action => 'projects'
|
redirect_to :controller => 'admin', :action => 'projects'
|
||||||
@@ -76,10 +89,12 @@ class ProjectsController < ApplicationController
|
|||||||
# Show @project
|
# Show @project
|
||||||
def show
|
def show
|
||||||
@custom_values = @project.custom_values.find(:all, :include => :custom_field)
|
@custom_values = @project.custom_values.find(:all, :include => :custom_field)
|
||||||
@members = @project.members.find(:all, :include => [:user, :role])
|
@members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role}
|
||||||
@subprojects = @project.children if @project.children_count > 0
|
@subprojects = @project.active_children
|
||||||
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
|
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
||||||
@trackers = Tracker.find(:all)
|
@trackers = Tracker.find(:all, :order => 'position')
|
||||||
|
@open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false])
|
||||||
|
@total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def settings
|
def settings
|
||||||
@@ -87,8 +102,6 @@ class ProjectsController < ApplicationController
|
|||||||
@custom_fields = IssueCustomField.find(:all)
|
@custom_fields = IssueCustomField.find(:all)
|
||||||
@issue_category ||= IssueCategory.new
|
@issue_category ||= IssueCategory.new
|
||||||
@member ||= @project.members.new
|
@member ||= @project.members.new
|
||||||
@roles = Role.find(:all)
|
|
||||||
@users = User.find(:all) - @project.members.find(:all, :include => :user).collect{|m| m.user }
|
|
||||||
@custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
|
@custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -105,8 +118,17 @@ class ProjectsController < ApplicationController
|
|||||||
when "0"
|
when "0"
|
||||||
@project.repository = nil
|
@project.repository = nil
|
||||||
when "1"
|
when "1"
|
||||||
@project.repository ||= Repository.new
|
@project.repository ||= Repository.factory(params[:repository_scm])
|
||||||
@project.repository.attributes = params[:repository]
|
@project.repository.update_attributes params[:repository] if @project.repository
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if params[:wiki_enabled]
|
||||||
|
case params[:wiki_enabled]
|
||||||
|
when "0"
|
||||||
|
@project.wiki.destroy if @project.wiki
|
||||||
|
when "1"
|
||||||
|
@project.wiki ||= Wiki.new
|
||||||
|
@project.wiki.update_attributes params[:wiki]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@project.attributes = params[:project]
|
@project.attributes = params[:project]
|
||||||
@@ -120,25 +142,33 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def archive
|
||||||
|
@project.archive if request.post? && @project.active?
|
||||||
|
redirect_to :controller => 'admin', :action => 'projects'
|
||||||
|
end
|
||||||
|
|
||||||
|
def unarchive
|
||||||
|
@project.unarchive if request.post? && !@project.active?
|
||||||
|
redirect_to :controller => 'admin', :action => 'projects'
|
||||||
|
end
|
||||||
|
|
||||||
# Delete @project
|
# Delete @project
|
||||||
def destroy
|
def destroy
|
||||||
|
@project_to_destroy = @project
|
||||||
if request.post? and params[:confirm]
|
if request.post? and params[:confirm]
|
||||||
@project.destroy
|
@project_to_destroy.destroy
|
||||||
redirect_to :controller => 'admin', :action => 'projects'
|
redirect_to :controller => 'admin', :action => 'projects'
|
||||||
end
|
end
|
||||||
|
# hide project in layout
|
||||||
|
@project = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new issue category to @project
|
# Add a new issue category to @project
|
||||||
def add_issue_category
|
def add_issue_category
|
||||||
if request.post?
|
@category = @project.issue_categories.build(params[:category])
|
||||||
@issue_category = @project.issue_categories.build(params[:issue_category])
|
if request.post? and @category.save
|
||||||
if @issue_category.save
|
flash[:notice] = l(:notice_successful_create)
|
||||||
flash[:notice] = l(:notice_successful_create)
|
redirect_to :action => 'settings', :tab => 'categories', :id => @project
|
||||||
redirect_to :action => 'settings', :id => @project
|
|
||||||
else
|
|
||||||
settings
|
|
||||||
render :action => 'settings'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -147,27 +177,27 @@ class ProjectsController < ApplicationController
|
|||||||
@version = @project.versions.build(params[:version])
|
@version = @project.versions.build(params[:version])
|
||||||
if request.post? and @version.save
|
if request.post? and @version.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'settings', :id => @project
|
redirect_to :action => 'settings', :tab => 'versions', :id => @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new member to @project
|
# Add a new member to @project
|
||||||
def add_member
|
def add_member
|
||||||
@member = @project.members.build(params[:member])
|
@member = @project.members.build(params[:member])
|
||||||
if request.post?
|
if request.post? && @member.save
|
||||||
if @member.save
|
respond_to do |format|
|
||||||
flash[:notice] = l(:notice_successful_create)
|
format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project }
|
||||||
redirect_to :action => 'settings', :id => @project
|
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'members'} }
|
||||||
else
|
|
||||||
settings
|
|
||||||
render :action => 'settings'
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
settings
|
||||||
|
render :action => 'settings'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Show members list of @project
|
# Show members list of @project
|
||||||
def list_members
|
def list_members
|
||||||
@members = @project.members
|
@members = @project.members.find(:all)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new document to @project
|
# Add a new document to @project
|
||||||
@@ -180,6 +210,7 @@ class ProjectsController < ApplicationController
|
|||||||
Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
|
Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
|
||||||
} if params[:attachments] and params[:attachments].is_a? Array
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
flash[:notice] = l(:notice_successful_create)
|
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
|
redirect_to :action => 'list_documents', :id => @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -193,12 +224,25 @@ class ProjectsController < ApplicationController
|
|||||||
def add_issue
|
def add_issue
|
||||||
@tracker = Tracker.find(params[:tracker_id])
|
@tracker = Tracker.find(params[:tracker_id])
|
||||||
@priorities = Enumeration::get_values('IPRI')
|
@priorities = Enumeration::get_values('IPRI')
|
||||||
|
|
||||||
|
default_status = IssueStatus.default
|
||||||
|
unless default_status
|
||||||
|
flash.now[:notice] = 'No default issue status defined. Please check your configuration.'
|
||||||
|
render :nothing => true, :layout => true
|
||||||
|
return
|
||||||
|
end
|
||||||
@issue = Issue.new(:project => @project, :tracker => @tracker)
|
@issue = Issue.new(:project => @project, :tracker => @tracker)
|
||||||
|
@issue.status = default_status
|
||||||
|
@allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker))if logged_in_user
|
||||||
if request.get?
|
if request.get?
|
||||||
@issue.start_date = Date.today
|
@issue.start_date = Date.today
|
||||||
@custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
|
@custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
|
||||||
else
|
else
|
||||||
@issue.attributes = params[:issue]
|
@issue.attributes = params[:issue]
|
||||||
|
|
||||||
|
requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
|
||||||
|
@issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
|
||||||
|
|
||||||
@issue.author_id = self.logged_in_user.id if self.logged_in_user
|
@issue.author_id = self.logged_in_user.id if self.logged_in_user
|
||||||
# Multiple file upload
|
# Multiple file upload
|
||||||
@attachments = []
|
@attachments = []
|
||||||
@@ -218,7 +262,7 @@ class ProjectsController < ApplicationController
|
|||||||
|
|
||||||
# Show filtered/sorted issues list of @project
|
# Show filtered/sorted issues list of @project
|
||||||
def list_issues
|
def list_issues
|
||||||
sort_init 'issues.id', 'desc'
|
sort_init "#{Issue.table_name}.id", "desc"
|
||||||
sort_update
|
sort_update
|
||||||
|
|
||||||
retrieve_query
|
retrieve_query
|
||||||
@@ -232,46 +276,70 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
if @query.valid?
|
if @query.valid?
|
||||||
@issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
|
@issue_count = Issue.count(:include => [:status, :project, :custom_values], :conditions => @query.statement)
|
||||||
@issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
|
@issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
|
||||||
@issues = Issue.find :all, :order => sort_clause,
|
@issues = Issue.find :all, :order => sort_clause,
|
||||||
:include => [ :author, :status, :tracker, :project ],
|
:include => [ :assigned_to, :status, :tracker, :project, :priority, :custom_values ],
|
||||||
:conditions => @query.statement,
|
:conditions => @query.statement,
|
||||||
:limit => @issue_pages.items_per_page,
|
:limit => @issue_pages.items_per_page,
|
||||||
:offset => @issue_pages.current.offset
|
:offset => @issue_pages.current.offset
|
||||||
end
|
end
|
||||||
@trackers = Tracker.find :all
|
|
||||||
render :layout => false if request.xhr?
|
render :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Export filtered/sorted issues list to CSV
|
# Export filtered/sorted issues list to CSV
|
||||||
def export_issues_csv
|
def export_issues_csv
|
||||||
sort_init 'issues.id', 'desc'
|
sort_init "#{Issue.table_name}.id", "desc"
|
||||||
sort_update
|
sort_update
|
||||||
|
|
||||||
retrieve_query
|
retrieve_query
|
||||||
render :action => 'list_issues' and return unless @query.valid?
|
render :action => 'list_issues' and return unless @query.valid?
|
||||||
|
|
||||||
@issues = Issue.find :all, :order => sort_clause,
|
@issues = Issue.find :all, :order => sort_clause,
|
||||||
:include => [ :author, :status, :tracker, :project, :custom_values ],
|
:include => [ :assigned_to, :author, :status, :tracker, :priority, :project, {:custom_values => :custom_field} ],
|
||||||
:conditions => @query.statement
|
:conditions => @query.statement,
|
||||||
|
:limit => Setting.issues_export_limit.to_i
|
||||||
|
|
||||||
ic = Iconv.new('ISO-8859-1', 'UTF-8')
|
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||||
export = StringIO.new
|
export = StringIO.new
|
||||||
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
||||||
# csv header fields
|
# csv header fields
|
||||||
headers = [ "#", l(:field_status), l(:field_tracker), l(:field_subject), l(:field_author), l(:field_created_on), l(:field_updated_on) ]
|
headers = [ "#", l(:field_status),
|
||||||
|
l(:field_project),
|
||||||
|
l(:field_tracker),
|
||||||
|
l(:field_priority),
|
||||||
|
l(:field_subject),
|
||||||
|
l(:field_assigned_to),
|
||||||
|
l(:field_author),
|
||||||
|
l(:field_start_date),
|
||||||
|
l(:field_due_date),
|
||||||
|
l(:field_done_ratio),
|
||||||
|
l(:field_created_on),
|
||||||
|
l(:field_updated_on)
|
||||||
|
]
|
||||||
for custom_field in @project.all_custom_fields
|
for custom_field in @project.all_custom_fields
|
||||||
headers << custom_field.name
|
headers << custom_field.name
|
||||||
end
|
end
|
||||||
csv << headers.collect {|c| ic.iconv(c) }
|
csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
||||||
# csv lines
|
# csv lines
|
||||||
@issues.each do |issue|
|
@issues.each do |issue|
|
||||||
fields = [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
|
fields = [issue.id, issue.status.name,
|
||||||
|
issue.project.name,
|
||||||
|
issue.tracker.name,
|
||||||
|
issue.priority.name,
|
||||||
|
issue.subject,
|
||||||
|
(issue.assigned_to ? issue.assigned_to.name : ""),
|
||||||
|
issue.author.name,
|
||||||
|
issue.start_date ? l_date(issue.start_date) : nil,
|
||||||
|
issue.due_date ? l_date(issue.due_date) : nil,
|
||||||
|
issue.done_ratio,
|
||||||
|
l_datetime(issue.created_on),
|
||||||
|
l_datetime(issue.updated_on)
|
||||||
|
]
|
||||||
for custom_field in @project.all_custom_fields
|
for custom_field in @project.all_custom_fields
|
||||||
fields << (show_value issue.custom_value_for(custom_field))
|
fields << (show_value issue.custom_value_for(custom_field))
|
||||||
end
|
end
|
||||||
csv << fields.collect {|c| ic.iconv(c.to_s) }
|
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
export.rewind
|
export.rewind
|
||||||
@@ -280,15 +348,16 @@ class ProjectsController < ApplicationController
|
|||||||
|
|
||||||
# Export filtered/sorted issues to PDF
|
# Export filtered/sorted issues to PDF
|
||||||
def export_issues_pdf
|
def export_issues_pdf
|
||||||
sort_init 'issues.id', 'desc'
|
sort_init "#{Issue.table_name}.id", "desc"
|
||||||
sort_update
|
sort_update
|
||||||
|
|
||||||
retrieve_query
|
retrieve_query
|
||||||
render :action => 'list_issues' and return unless @query.valid?
|
render :action => 'list_issues' and return unless @query.valid?
|
||||||
|
|
||||||
@issues = Issue.find :all, :order => sort_clause,
|
@issues = Issue.find :all, :order => sort_clause,
|
||||||
:include => [ :author, :status, :tracker, :project, :custom_values ],
|
:include => [ :author, :status, :tracker, :priority, :project, :custom_values ],
|
||||||
:conditions => @query.statement
|
:conditions => @query.statement,
|
||||||
|
:limit => Setting.issues_export_limit.to_i
|
||||||
|
|
||||||
@options_for_rfpdf ||= {}
|
@options_for_rfpdf ||= {}
|
||||||
@options_for_rfpdf[:file_name] = "export.pdf"
|
@options_for_rfpdf[:file_name] = "export.pdf"
|
||||||
@@ -300,7 +369,7 @@ class ProjectsController < ApplicationController
|
|||||||
redirect_to :action => 'list_issues', :id => @project and return unless @issues
|
redirect_to :action => 'list_issues', :id => @project and return unless @issues
|
||||||
@projects = []
|
@projects = []
|
||||||
# find projects to which the user is allowed to move the issue
|
# 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)}
|
@logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role)}
|
||||||
# issue can be moved to any tracker
|
# issue can be moved to any tracker
|
||||||
@trackers = Tracker.find(:all)
|
@trackers = Tracker.find(:all)
|
||||||
if request.post? and params[:new_project_id] and params[:new_tracker_id]
|
if request.post? and params[:new_project_id] and params[:new_tracker_id]
|
||||||
@@ -311,6 +380,9 @@ class ProjectsController < ApplicationController
|
|||||||
unless i.project_id == new_project.id
|
unless i.project_id == new_project.id
|
||||||
i.category = nil
|
i.category = nil
|
||||||
i.fixed_version = nil
|
i.fixed_version = nil
|
||||||
|
# delete issue relations
|
||||||
|
i.relations_from.clear
|
||||||
|
i.relations_to.clear
|
||||||
end
|
end
|
||||||
# move the issue
|
# move the issue
|
||||||
i.project = new_project
|
i.project = new_project
|
||||||
@@ -322,22 +394,6 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
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
|
# Add a news to @project
|
||||||
def add_news
|
def add_news
|
||||||
@news = News.new(:project => @project)
|
@news = News.new(:project => @project)
|
||||||
@@ -353,7 +409,7 @@ class ProjectsController < ApplicationController
|
|||||||
|
|
||||||
# Show news list of @project
|
# Show news list of @project
|
||||||
def list_news
|
def list_news
|
||||||
@news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
|
@news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "#{News.table_name}.created_on DESC"
|
||||||
render :action => "list_news", :layout => false if request.xhr?
|
render :action => "list_news", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -361,33 +417,34 @@ class ProjectsController < ApplicationController
|
|||||||
if request.post?
|
if request.post?
|
||||||
@version = @project.versions.find_by_id(params[:version_id])
|
@version = @project.versions.find_by_id(params[:version_id])
|
||||||
# Save the attachments
|
# Save the attachments
|
||||||
params[:attachments].each { |a|
|
@attachments = []
|
||||||
Attachment.create(:container => @version, :file => a, :author => logged_in_user) unless a.size == 0
|
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
|
} 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
|
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
||||||
end
|
end
|
||||||
@versions = @project.versions
|
@versions = @project.versions.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_files
|
def list_files
|
||||||
@versions = @project.versions
|
@versions = @project.versions.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
# Show changelog for @project
|
# Show changelog for @project
|
||||||
def changelog
|
def changelog
|
||||||
@trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true])
|
@trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
|
||||||
if request.get?
|
retrieve_selected_tracker_ids(@trackers)
|
||||||
@selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
|
@versions = @project.versions.sort
|
||||||
else
|
end
|
||||||
@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
|
def roadmap
|
||||||
@selected_tracker_ids ||= []
|
@trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position')
|
||||||
@fixed_issues = @project.issues.find(:all,
|
retrieve_selected_tracker_ids(@trackers)
|
||||||
:include => [ :fixed_version, :status, :tracker ],
|
conditions = ("1" == params[:completed] ? nil : [ "#{Version.table_name}.effective_date > ? OR #{Version.table_name}.effective_date IS NULL", Date.today])
|
||||||
:conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
|
@versions = @project.versions.find(:all, :conditions => conditions).sort
|
||||||
:order => "versions.effective_date DESC, issues.id DESC"
|
|
||||||
) unless @selected_tracker_ids.empty?
|
|
||||||
@fixed_issues ||= []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def activity
|
def activity
|
||||||
@@ -401,12 +458,12 @@ class ProjectsController < ApplicationController
|
|||||||
@month ||= Date.today.month
|
@month ||= Date.today.month
|
||||||
|
|
||||||
@date_from = Date.civil(@year, @month, 1)
|
@date_from = Date.civil(@year, @month, 1)
|
||||||
@date_to = (@date_from >> 1)-1
|
@date_to = @date_from >> 1
|
||||||
|
|
||||||
@events_by_day = {}
|
@events_by_day = {}
|
||||||
|
|
||||||
unless params[:show_issues] == "0"
|
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|
|
@project.issues.find(:all, :include => [:author], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] ).each { |i|
|
||||||
@events_by_day[i.created_on.to_date] ||= []
|
@events_by_day[i.created_on.to_date] ||= []
|
||||||
@events_by_day[i.created_on.to_date] << i
|
@events_by_day[i.created_on.to_date] << i
|
||||||
}
|
}
|
||||||
@@ -414,7 +471,7 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless params[:show_news] == "0"
|
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|
|
@project.news.find(:all, :conditions => ["#{News.table_name}.created_on>=? and #{News.table_name}.created_on<=?", @date_from, @date_to], :include => :author ).each { |i|
|
||||||
@events_by_day[i.created_on.to_date] ||= []
|
@events_by_day[i.created_on.to_date] ||= []
|
||||||
@events_by_day[i.created_on.to_date] << i
|
@events_by_day[i.created_on.to_date] << i
|
||||||
}
|
}
|
||||||
@@ -422,7 +479,7 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless params[:show_files] == "0"
|
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|
|
Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
|
||||||
@events_by_day[i.created_on.to_date] ||= []
|
@events_by_day[i.created_on.to_date] ||= []
|
||||||
@events_by_day[i.created_on.to_date] << i
|
@events_by_day[i.created_on.to_date] << i
|
||||||
}
|
}
|
||||||
@@ -430,21 +487,55 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless params[:show_documents] == "0"
|
unless params[:show_documents] == "0"
|
||||||
@project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.created_on<=?", @date_from, @date_to] ).each { |i|
|
@project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on>=? and #{Document.table_name}.created_on<=?", @date_from, @date_to] ).each { |i|
|
||||||
@events_by_day[i.created_on.to_date] ||= []
|
@events_by_day[i.created_on.to_date] ||= []
|
||||||
@events_by_day[i.created_on.to_date] << i
|
@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|
|
Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on>=? and #{Attachment.table_name}.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|
|
||||||
@events_by_day[i.created_on.to_date] ||= []
|
@events_by_day[i.created_on.to_date] ||= []
|
||||||
@events_by_day[i.created_on.to_date] << i
|
@events_by_day[i.created_on.to_date] << i
|
||||||
}
|
}
|
||||||
@show_documents = 1
|
@show_documents = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless @project.wiki.nil? || params[:show_wiki_edits] == "0"
|
||||||
|
select = "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " +
|
||||||
|
"#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title"
|
||||||
|
joins = "LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{WikiContent.versioned_table_name}.page_id " +
|
||||||
|
"LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id "
|
||||||
|
conditions = ["#{Wiki.table_name}.project_id = ? AND #{WikiContent.versioned_table_name}.updated_on BETWEEN ? AND ?",
|
||||||
|
@project.id, @date_from, @date_to]
|
||||||
|
|
||||||
|
WikiContent.versioned_class.find(:all, :select => select, :joins => joins, :conditions => conditions).each { |i|
|
||||||
|
# We provide this alias so all events can be treated in the same manner
|
||||||
|
def i.created_on
|
||||||
|
self.updated_on
|
||||||
|
end
|
||||||
|
|
||||||
|
@events_by_day[i.created_on.to_date] ||= []
|
||||||
|
@events_by_day[i.created_on.to_date] << i
|
||||||
|
}
|
||||||
|
@show_wiki_edits = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
unless @project.repository.nil? || params[:show_changesets] == "0"
|
||||||
|
@project.repository.changesets.find(:all, :conditions => ["#{Changeset.table_name}.committed_on BETWEEN ? AND ?", @date_from, @date_to]).each { |i|
|
||||||
|
def i.created_on
|
||||||
|
self.committed_on
|
||||||
|
end
|
||||||
|
@events_by_day[i.created_on.to_date] ||= []
|
||||||
|
@events_by_day[i.created_on.to_date] << i
|
||||||
|
}
|
||||||
|
@show_changesets = 1
|
||||||
|
end
|
||||||
|
|
||||||
render :layout => false if request.xhr?
|
render :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def calendar
|
def calendar
|
||||||
|
@trackers = Tracker.find(:all, :order => 'position')
|
||||||
|
retrieve_selected_tracker_ids(@trackers)
|
||||||
|
|
||||||
if params[:year] and params[:year].to_i > 1900
|
if params[:year] and params[:year].to_i > 1900
|
||||||
@year = params[:year].to_i
|
@year = params[:year].to_i
|
||||||
if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
|
if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
|
||||||
@@ -461,11 +552,25 @@ class ProjectsController < ApplicationController
|
|||||||
# finish on sunday
|
# finish on sunday
|
||||||
@date_to = @date_to + (7-@date_to.cwday)
|
@date_to = @date_to + (7-@date_to.cwday)
|
||||||
|
|
||||||
@issues = @project.issues.find(:all, :include => :tracker, :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to])
|
@events = []
|
||||||
|
@project.issues_with_subprojects(params[:with_subprojects]) do
|
||||||
|
@events += Issue.find(:all,
|
||||||
|
:include => [:tracker, :status, :assigned_to, :priority, :project],
|
||||||
|
:conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", @date_from, @date_to, @date_from, @date_to]
|
||||||
|
) unless @selected_tracker_ids.empty?
|
||||||
|
end
|
||||||
|
@events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
|
||||||
|
|
||||||
|
@ending_events_by_days = @events.group_by {|event| event.due_date}
|
||||||
|
@starting_events_by_days = @events.group_by {|event| event.start_date}
|
||||||
|
|
||||||
render :layout => false if request.xhr?
|
render :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def gantt
|
def gantt
|
||||||
|
@trackers = Tracker.find(:all, :order => 'position')
|
||||||
|
retrieve_selected_tracker_ids(@trackers)
|
||||||
|
|
||||||
if params[:year] and params[:year].to_i >0
|
if params[:year] and params[:year].to_i >0
|
||||||
@year_from = params[:year].to_i
|
@year_from = params[:year].to_i
|
||||||
if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
|
if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
|
||||||
@@ -483,7 +588,17 @@ class ProjectsController < ApplicationController
|
|||||||
|
|
||||||
@date_from = Date.civil(@year_from, @month_from, 1)
|
@date_from = Date.civil(@year_from, @month_from, 1)
|
||||||
@date_to = (@date_from >> @months) - 1
|
@date_to = (@date_from >> @months) - 1
|
||||||
@issues = @project.issues.find(:all, :order => "start_date, due_date", :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])
|
|
||||||
|
@events = []
|
||||||
|
@project.issues_with_subprojects(params[:with_subprojects]) do
|
||||||
|
@events += Issue.find(:all,
|
||||||
|
:order => "start_date, due_date",
|
||||||
|
:include => [:tracker, :status, :assigned_to, :priority, :project],
|
||||||
|
:conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]
|
||||||
|
) unless @selected_tracker_ids.empty?
|
||||||
|
end
|
||||||
|
@events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
|
||||||
|
@events.sort! {|x,y| x.start_date <=> y.start_date }
|
||||||
|
|
||||||
if params[:output]=='pdf'
|
if params[:output]=='pdf'
|
||||||
@options_for_rfpdf ||= {}
|
@options_for_rfpdf ||= {}
|
||||||
@@ -494,6 +609,11 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def feeds
|
||||||
|
@queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)]
|
||||||
|
@key = logged_in_user.get_or_create_rss_key.value if logged_in_user
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# Find project of id params[:id]
|
# Find project of id params[:id]
|
||||||
# if not found, redirect to project list
|
# if not found, redirect to project list
|
||||||
@@ -505,14 +625,24 @@ private
|
|||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def retrieve_selected_tracker_ids(selectable_trackers)
|
||||||
|
if ids = params[:tracker_ids]
|
||||||
|
@selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
|
||||||
|
else
|
||||||
|
@selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Retrieve query from session or build a new query
|
# Retrieve query from session or build a new query
|
||||||
def retrieve_query
|
def retrieve_query
|
||||||
if params[:query_id]
|
if params[:query_id]
|
||||||
@query = @project.queries.find(params[:query_id])
|
@query = @project.queries.find(params[:query_id])
|
||||||
|
@query.executed_by = logged_in_user
|
||||||
|
session[:query] = @query
|
||||||
else
|
else
|
||||||
if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
|
if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
|
||||||
# Give it a name, required to be valid
|
# Give it a name, required to be valid
|
||||||
@query = Query.new(:name => "_")
|
@query = Query.new(:name => "_", :executed_by => logged_in_user)
|
||||||
@query.project = @project
|
@query.project = @project
|
||||||
if params[:fields] and params[:fields].is_a? Array
|
if params[:fields] and params[:fields].is_a? Array
|
||||||
params[:fields].each do |field|
|
params[:fields].each do |field|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -17,7 +17,33 @@
|
|||||||
|
|
||||||
class QueriesController < ApplicationController
|
class QueriesController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :require_login, :find_query
|
before_filter :require_login, :except => :index
|
||||||
|
before_filter :find_project, :check_project_privacy
|
||||||
|
|
||||||
|
def index
|
||||||
|
@queries = @project.queries.find(:all,
|
||||||
|
:order => "name ASC",
|
||||||
|
:conditions => ["is_public = ? or user_id = ?", true, (logged_in_user ? logged_in_user.id : 0)])
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@query = Query.new(params[:query])
|
||||||
|
@query.project = @project
|
||||||
|
@query.user = logged_in_user
|
||||||
|
@query.executed_by = logged_in_user
|
||||||
|
@query.is_public = false unless logged_in_user.authorized_to(@project, 'projects/add_query')
|
||||||
|
|
||||||
|
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 => 'projects', :action => 'list_issues', :id => @project, :query_id => @query
|
||||||
|
return
|
||||||
|
end
|
||||||
|
render :layout => false if request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
if request.post?
|
if request.post?
|
||||||
@@ -26,6 +52,7 @@ class QueriesController < ApplicationController
|
|||||||
@query.add_filter(field, params[:operators][field], params[:values][field])
|
@query.add_filter(field, params[:operators][field], params[:values][field])
|
||||||
end if params[:fields]
|
end if params[:fields]
|
||||||
@query.attributes = params[:query]
|
@query.attributes = params[:query]
|
||||||
|
@query.is_public = false unless logged_in_user.authorized_to(@project, 'projects/add_query')
|
||||||
|
|
||||||
if @query.save
|
if @query.save
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
@@ -36,15 +63,19 @@ class QueriesController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@query.destroy if request.post?
|
@query.destroy if request.post?
|
||||||
redirect_to :controller => 'reports', :action => 'issue_report', :id => @project
|
redirect_to :controller => 'queries', :project_id => @project
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_query
|
def find_project
|
||||||
@query = Query.find(params[:id])
|
if params[:id]
|
||||||
@project = @query.project
|
@query = Query.find(params[:id])
|
||||||
# check if user is allowed to manage queries (same permission as add_query)
|
@query.executed_by = logged_in_user
|
||||||
authorize('projects', 'add_query')
|
@project = @query.project
|
||||||
|
render_403 unless @query.editable_by?(logged_in_user)
|
||||||
|
else
|
||||||
|
@project = Project.find(params[:project_id])
|
||||||
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,19 +16,25 @@
|
|||||||
# 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 ReportsController < ApplicationController
|
class ReportsController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :find_project, :authorize
|
before_filter :find_project, :authorize
|
||||||
|
|
||||||
def issue_report
|
def issue_report
|
||||||
@statuses = IssueStatus.find :all
|
@statuses = IssueStatus.find(:all, :order => 'position')
|
||||||
|
|
||||||
case params[:detail]
|
case params[:detail]
|
||||||
when "tracker"
|
when "tracker"
|
||||||
@field = "tracker_id"
|
@field = "tracker_id"
|
||||||
@rows = Tracker.find :all
|
@rows = Tracker.find :all, :order => 'position'
|
||||||
@data = issues_by_tracker
|
@data = issues_by_tracker
|
||||||
@report_title = l(:field_tracker)
|
@report_title = l(:field_tracker)
|
||||||
render :template => "reports/issue_report_details"
|
render :template => "reports/issue_report_details"
|
||||||
|
when "version"
|
||||||
|
@field = "fixed_version_id"
|
||||||
|
@rows = @project.versions.sort
|
||||||
|
@data = issues_by_version
|
||||||
|
@report_title = l(:field_version)
|
||||||
|
render :template => "reports/issue_report_details"
|
||||||
when "priority"
|
when "priority"
|
||||||
@field = "priority_id"
|
@field = "priority_id"
|
||||||
@rows = Enumeration::get_values('IPRI')
|
@rows = Enumeration::get_values('IPRI')
|
||||||
@@ -47,16 +53,26 @@ class ReportsController < ApplicationController
|
|||||||
@data = issues_by_author
|
@data = issues_by_author
|
||||||
@report_title = l(:field_author)
|
@report_title = l(:field_author)
|
||||||
render :template => "reports/issue_report_details"
|
render :template => "reports/issue_report_details"
|
||||||
|
when "subproject"
|
||||||
|
@field = "project_id"
|
||||||
|
@rows = @project.active_children
|
||||||
|
@data = issues_by_subproject
|
||||||
|
@report_title = l(:field_subproject)
|
||||||
|
render :template => "reports/issue_report_details"
|
||||||
else
|
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')
|
||||||
@trackers = Tracker.find(:all)
|
@versions = @project.versions.sort
|
||||||
@priorities = Enumeration::get_values('IPRI')
|
@priorities = Enumeration::get_values('IPRI')
|
||||||
@categories = @project.issue_categories
|
@categories = @project.issue_categories
|
||||||
@authors = @project.members.collect { |m| m.user }
|
@authors = @project.members.collect { |m| m.user }
|
||||||
|
@subprojects = @project.active_children
|
||||||
issues_by_tracker
|
issues_by_tracker
|
||||||
|
issues_by_version
|
||||||
issues_by_priority
|
issues_by_priority
|
||||||
issues_by_category
|
issues_by_category
|
||||||
issues_by_author
|
issues_by_author
|
||||||
|
issues_by_subproject
|
||||||
|
@total_hours = @project.time_entries.sum(:hours)
|
||||||
render :template => "reports/issue_report"
|
render :template => "reports/issue_report"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -105,63 +121,93 @@ private
|
|||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
def issues_by_tracker
|
def issues_by_tracker
|
||||||
@issues_by_tracker ||=
|
@issues_by_tracker ||=
|
||||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||||
s.is_closed as closed,
|
s.is_closed as closed,
|
||||||
t.id as tracker_id,
|
t.id as tracker_id,
|
||||||
count(i.id) as total
|
count(i.id) as total
|
||||||
from
|
from
|
||||||
issues i, issue_statuses s, trackers t
|
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t
|
||||||
where
|
where
|
||||||
i.status_id=s.id
|
i.status_id=s.id
|
||||||
and i.tracker_id=t.id
|
and i.tracker_id=t.id
|
||||||
and i.project_id=#{@project.id}
|
and i.project_id=#{@project.id}
|
||||||
group by s.id, s.is_closed, t.id")
|
group by s.id, s.is_closed, t.id")
|
||||||
end
|
end
|
||||||
|
|
||||||
def issues_by_priority
|
def issues_by_version
|
||||||
|
@issues_by_version ||=
|
||||||
|
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||||
|
s.is_closed as closed,
|
||||||
|
v.id as fixed_version_id,
|
||||||
|
count(i.id) as total
|
||||||
|
from
|
||||||
|
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Version.table_name} v
|
||||||
|
where
|
||||||
|
i.status_id=s.id
|
||||||
|
and i.fixed_version_id=v.id
|
||||||
|
and i.project_id=#{@project.id}
|
||||||
|
group by s.id, s.is_closed, v.id")
|
||||||
|
end
|
||||||
|
|
||||||
|
def issues_by_priority
|
||||||
@issues_by_priority ||=
|
@issues_by_priority ||=
|
||||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||||
s.is_closed as closed,
|
s.is_closed as closed,
|
||||||
p.id as priority_id,
|
p.id as priority_id,
|
||||||
count(i.id) as total
|
count(i.id) as total
|
||||||
from
|
from
|
||||||
issues i, issue_statuses s, enumerations p
|
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Enumeration.table_name} p
|
||||||
where
|
where
|
||||||
i.status_id=s.id
|
i.status_id=s.id
|
||||||
and i.priority_id=p.id
|
and i.priority_id=p.id
|
||||||
and i.project_id=#{@project.id}
|
and i.project_id=#{@project.id}
|
||||||
group by s.id, s.is_closed, p.id")
|
group by s.id, s.is_closed, p.id")
|
||||||
end
|
end
|
||||||
|
|
||||||
def issues_by_category
|
def issues_by_category
|
||||||
@issues_by_category ||=
|
@issues_by_category ||=
|
||||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||||
s.is_closed as closed,
|
s.is_closed as closed,
|
||||||
c.id as category_id,
|
c.id as category_id,
|
||||||
count(i.id) as total
|
count(i.id) as total
|
||||||
from
|
from
|
||||||
issues i, issue_statuses s, issue_categories c
|
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssueCategory.table_name} c
|
||||||
where
|
where
|
||||||
i.status_id=s.id
|
i.status_id=s.id
|
||||||
and i.category_id=c.id
|
and i.category_id=c.id
|
||||||
and i.project_id=#{@project.id}
|
and i.project_id=#{@project.id}
|
||||||
group by s.id, s.is_closed, c.id")
|
group by s.id, s.is_closed, c.id")
|
||||||
end
|
end
|
||||||
|
|
||||||
def issues_by_author
|
def issues_by_author
|
||||||
@issues_by_author ||=
|
@issues_by_author ||=
|
||||||
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||||
s.is_closed as closed,
|
s.is_closed as closed,
|
||||||
a.id as author_id,
|
a.id as author_id,
|
||||||
count(i.id) as total
|
count(i.id) as total
|
||||||
from
|
from
|
||||||
issues i, issue_statuses s, users a
|
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
|
||||||
where
|
where
|
||||||
i.status_id=s.id
|
i.status_id=s.id
|
||||||
and i.author_id=a.id
|
and i.author_id=a.id
|
||||||
and i.project_id=#{@project.id}
|
and i.project_id=#{@project.id}
|
||||||
group by s.id, s.is_closed, a.id")
|
group by s.id, s.is_closed, a.id")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def issues_by_subproject
|
||||||
|
@issues_by_subproject ||=
|
||||||
|
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
||||||
|
s.is_closed as closed,
|
||||||
|
i.project_id as project_id,
|
||||||
|
count(i.id) as total
|
||||||
|
from
|
||||||
|
#{Issue.table_name} i, #{IssueStatus.table_name} s
|
||||||
|
where
|
||||||
|
i.status_id=s.id
|
||||||
|
and i.project_id IN (#{@project.active_children.collect{|p| p.id}.join(',')})
|
||||||
|
group by s.id, s.is_closed, i.project_id") if @project.active_children.any?
|
||||||
|
@issues_by_subproject ||= []
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -15,54 +15,114 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
require 'SVG/Graph/Bar'
|
||||||
|
require 'SVG/Graph/BarHorizontal'
|
||||||
|
require 'digest/sha1'
|
||||||
|
|
||||||
class RepositoriesController < ApplicationController
|
class RepositoriesController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
before_filter :find_project, :authorize
|
before_filter :find_project, :except => [:update_form]
|
||||||
|
before_filter :authorize, :except => [:update_form, :stats, :graph]
|
||||||
|
before_filter :check_project_privacy, :only => [:stats, :graph]
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@entries = @repository.scm.entries('')
|
# check if new revisions have been committed in the repository
|
||||||
show_error and return unless @entries
|
@repository.fetch_changesets if Setting.autofetch_changesets?
|
||||||
@latest_revision = @entries.revisions.latest
|
# get entries for the browse frame
|
||||||
|
@entries = @repository.entries('')
|
||||||
|
# latest changesets
|
||||||
|
@changesets = @repository.changesets.find(:all, :limit => 10, :order => "committed_on DESC")
|
||||||
|
show_error and return unless @entries || @changesets.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
def browse
|
def browse
|
||||||
@entries = @repository.scm.entries(@path, @rev)
|
@entries = @repository.entries(@path, @rev)
|
||||||
show_error and return unless @entries
|
show_error and return unless @entries
|
||||||
end
|
end
|
||||||
|
|
||||||
def revisions
|
def changes
|
||||||
@entry = @repository.scm.entry(@path, @rev)
|
@entry = @repository.scm.entry(@path, @rev)
|
||||||
@revisions = @repository.scm.revisions(@path, @rev)
|
show_error and return unless @entry
|
||||||
show_error and return unless @entry && @revisions
|
@changes = Change.find(:all, :include => :changeset,
|
||||||
|
:conditions => ["repository_id = ? AND path = ?", @repository.id, @path.with_leading_slash],
|
||||||
|
:order => "committed_on DESC")
|
||||||
|
end
|
||||||
|
|
||||||
|
def revisions
|
||||||
|
@changeset_count = @repository.changesets.count
|
||||||
|
@changeset_pages = Paginator.new self, @changeset_count,
|
||||||
|
25,
|
||||||
|
params['page']
|
||||||
|
@changesets = @repository.changesets.find(:all,
|
||||||
|
:limit => @changeset_pages.items_per_page,
|
||||||
|
:offset => @changeset_pages.current.offset)
|
||||||
|
|
||||||
|
render :action => "revisions", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def entry
|
def entry
|
||||||
|
@content = @repository.scm.cat(@path, @rev)
|
||||||
|
show_error and return unless @content
|
||||||
if 'raw' == params[:format]
|
if 'raw' == params[:format]
|
||||||
content = @repository.scm.cat(@path, @rev)
|
send_data @content, :filename => @path.split('/').last
|
||||||
show_error and return unless content
|
|
||||||
send_data content, :filename => @path.split('/').last
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision
|
def revision
|
||||||
@revisions = @repository.scm.revisions '', @rev, @rev, :with_paths => true
|
@changeset = @repository.changesets.find_by_revision(@rev)
|
||||||
show_error and return unless @revisions
|
show_error and return unless @changeset
|
||||||
@revision = @revisions.first
|
@changes_count = @changeset.changes.size
|
||||||
|
@changes_pages = Paginator.new self, @changes_count, 150, params['page']
|
||||||
|
@changes = @changeset.changes.find(:all,
|
||||||
|
:limit => @changes_pages.items_per_page,
|
||||||
|
:offset => @changes_pages.current.offset)
|
||||||
|
|
||||||
|
render :action => "revision", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff
|
def diff
|
||||||
@rev_to = params[:rev_to] || (@rev-1)
|
@rev_to = params[:rev_to] ? params[:rev_to].to_i : (@rev - 1)
|
||||||
@diff = @repository.scm.diff(params[:path], @rev, @rev_to)
|
@diff_type = ('sbs' == params[:type]) ? 'sbs' : 'inline'
|
||||||
show_error and return unless @diff
|
|
||||||
|
@cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")
|
||||||
|
unless read_fragment(@cache_key)
|
||||||
|
@diff = @repository.diff(@path, @rev, @rev_to, type)
|
||||||
|
show_error and return unless @diff
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def stats
|
||||||
|
end
|
||||||
|
|
||||||
|
def graph
|
||||||
|
data = nil
|
||||||
|
case params[:graph]
|
||||||
|
when "commits_per_month"
|
||||||
|
data = graph_commits_per_month(@repository)
|
||||||
|
when "commits_per_author"
|
||||||
|
data = graph_commits_per_author(@repository)
|
||||||
|
end
|
||||||
|
if data
|
||||||
|
headers["Content-Type"] = "image/svg+xml"
|
||||||
|
send_data(data, :type => "image/svg+xml", :disposition => "inline")
|
||||||
|
else
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_form
|
||||||
|
@repository = Repository.factory(params[:repository_scm])
|
||||||
|
render :partial => 'projects/repository', :locals => {:repository => @repository}
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@project = Project.find(params[:id])
|
@project = Project.find(params[:id])
|
||||||
@repository = @project.repository
|
@repository = @project.repository
|
||||||
@path = params[:path].squeeze('/').gsub(/^\//, '') if params[:path]
|
render_404 and return false unless @repository
|
||||||
|
@path = params[:path].squeeze('/') if params[:path]
|
||||||
@path ||= ''
|
@path ||= ''
|
||||||
@rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0
|
@rev = params[:rev].to_i if params[:rev]
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
@@ -71,4 +131,101 @@ private
|
|||||||
flash.now[:notice] = l(:notice_scm_error)
|
flash.now[:notice] = l(:notice_scm_error)
|
||||||
render :nothing => true, :layout => true
|
render :nothing => true, :layout => true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def graph_commits_per_month(repository)
|
||||||
|
@date_to = Date.today
|
||||||
|
@date_from = @date_to << 12
|
||||||
|
commits_by_day = repository.changesets.count(:all, :group => :commit_date, :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
|
||||||
|
commits_by_month = [0] * 12
|
||||||
|
commits_by_day.each {|c| commits_by_month[c.first.to_date.months_ago] += c.last }
|
||||||
|
|
||||||
|
changes_by_day = repository.changes.count(:all, :group => :commit_date)
|
||||||
|
changes_by_month = [0] * 12
|
||||||
|
changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last }
|
||||||
|
|
||||||
|
fields = []
|
||||||
|
month_names = l(:actionview_datehelper_select_month_names_abbr).split(',')
|
||||||
|
12.times {|m| fields << month_names[((Date.today.month - 1 - m) % 12)]}
|
||||||
|
|
||||||
|
graph = SVG::Graph::Bar.new(
|
||||||
|
:height => 300,
|
||||||
|
:width => 500,
|
||||||
|
:fields => fields.reverse,
|
||||||
|
:stack => :side,
|
||||||
|
:scale_integers => true,
|
||||||
|
:step_x_labels => 2,
|
||||||
|
:show_data_values => false,
|
||||||
|
:graph_title => l(:label_commits_per_month),
|
||||||
|
:show_graph_title => true
|
||||||
|
)
|
||||||
|
|
||||||
|
graph.add_data(
|
||||||
|
:data => commits_by_month[0..11].reverse,
|
||||||
|
:title => l(:label_revision_plural)
|
||||||
|
)
|
||||||
|
|
||||||
|
graph.add_data(
|
||||||
|
:data => changes_by_month[0..11].reverse,
|
||||||
|
:title => l(:label_change_plural)
|
||||||
|
)
|
||||||
|
|
||||||
|
graph.burn
|
||||||
|
end
|
||||||
|
|
||||||
|
def graph_commits_per_author(repository)
|
||||||
|
commits_by_author = repository.changesets.count(:all, :group => :committer)
|
||||||
|
commits_by_author.sort! {|x, y| x.last <=> y.last}
|
||||||
|
|
||||||
|
changes_by_author = repository.changes.count(:all, :group => :committer)
|
||||||
|
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
||||||
|
|
||||||
|
fields = commits_by_author.collect {|r| r.first}
|
||||||
|
commits_data = commits_by_author.collect {|r| r.last}
|
||||||
|
changes_data = commits_by_author.collect {|r| h[r.first] || 0}
|
||||||
|
|
||||||
|
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
||||||
|
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
||||||
|
changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10
|
||||||
|
|
||||||
|
graph = SVG::Graph::BarHorizontal.new(
|
||||||
|
:height => 300,
|
||||||
|
:width => 500,
|
||||||
|
:fields => fields,
|
||||||
|
:stack => :side,
|
||||||
|
:scale_integers => true,
|
||||||
|
:show_data_values => false,
|
||||||
|
:rotate_y_labels => false,
|
||||||
|
:graph_title => l(:label_commits_per_author),
|
||||||
|
:show_graph_title => true
|
||||||
|
)
|
||||||
|
|
||||||
|
graph.add_data(
|
||||||
|
:data => commits_data,
|
||||||
|
:title => l(:label_revision_plural)
|
||||||
|
)
|
||||||
|
|
||||||
|
graph.add_data(
|
||||||
|
:data => changes_data,
|
||||||
|
:title => l(:label_change_plural)
|
||||||
|
)
|
||||||
|
|
||||||
|
graph.burn
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
class Date
|
||||||
|
def months_ago(date = Date.today)
|
||||||
|
(date.year - self.year)*12 + (date.month - self.month)
|
||||||
|
end
|
||||||
|
|
||||||
|
def weeks_ago(date = Date.today)
|
||||||
|
(date.year - self.year)*52 + (date.cweek - self.cweek)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class String
|
||||||
|
def with_leading_slash
|
||||||
|
starts_with?('/') ? self : "/#{self}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,8 +16,11 @@
|
|||||||
# 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
|
||||||
@@ -25,7 +28,7 @@ class RolesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def list
|
def list
|
||||||
@role_pages, @roles = paginate :roles, :per_page => 10
|
@role_pages, @roles = paginate :roles, :per_page => 25, :order => "position"
|
||||||
render :action => "list", :layout => false if request.xhr?
|
render :action => "list", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -62,6 +65,21 @@ class RolesController < ApplicationController
|
|||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
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])
|
||||||
@@ -77,8 +95,21 @@ class RolesController < ApplicationController
|
|||||||
flash[:notice] = l(:notice_successful_update)
|
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
|
||||||
|
|
||||||
|
def report
|
||||||
|
@roles = Role.find(:all, :order => 'position')
|
||||||
|
@permissions = Permission.find :all, :conditions => ["is_public=?", false], :order => 'sort'
|
||||||
|
if request.post?
|
||||||
|
@roles.each do |role|
|
||||||
|
role.permissions = Permission.find(params[:permission_ids] ? (params[:permission_ids][role.id.to_s] || []) : [] )
|
||||||
|
end
|
||||||
|
Permission.allowed_to_role_expired
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
redirect_to :action => 'list'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
# 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 SearchController < ApplicationController
|
||||||
|
layout 'base'
|
||||||
|
|
||||||
|
helper :messages
|
||||||
|
include MessagesHelper
|
||||||
|
|
||||||
|
def index
|
||||||
|
@question = params[:q] || ""
|
||||||
|
@question.strip!
|
||||||
|
@all_words = params[:all_words] || (params[:submit] ? false : true)
|
||||||
|
@scope = params[:scope] || (params[:submit] ? [] : %w(projects issues changesets news documents wiki messages) )
|
||||||
|
|
||||||
|
# quick jump to an issue
|
||||||
|
if @scope.include?('issues') && @question.match(/^#?(\d+)$/) && Issue.find_by_id($1, :include => :project, :conditions => Project.visible_by(logged_in_user))
|
||||||
|
redirect_to :controller => "issues", :action => "show", :id => $1
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:id]
|
||||||
|
find_project
|
||||||
|
return unless check_project_privacy
|
||||||
|
end
|
||||||
|
|
||||||
|
# tokens must be at least 3 character long
|
||||||
|
@tokens = @question.split.uniq.select {|w| w.length > 2 }
|
||||||
|
|
||||||
|
if !@tokens.empty?
|
||||||
|
# no more than 5 tokens to search for
|
||||||
|
@tokens.slice! 5..-1 if @tokens.size > 5
|
||||||
|
# strings used in sql like statement
|
||||||
|
like_tokens = @tokens.collect {|w| "%#{w.downcase}%"}
|
||||||
|
operator = @all_words ? " AND " : " OR "
|
||||||
|
limit = 10
|
||||||
|
@results = []
|
||||||
|
if @project
|
||||||
|
@results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(subject) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues'
|
||||||
|
@results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort], :include => :author ) if @scope.include? 'news'
|
||||||
|
@results += @project.documents.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'documents'
|
||||||
|
@results += @project.wiki.pages.find(:all, :limit => limit, :include => :content, :conditions => [ (["(LOWER(title) like ? OR LOWER(text) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @project.wiki && @scope.include?('wiki')
|
||||||
|
@results += @project.repository.changesets.find(:all, :limit => limit, :conditions => [ (["(LOWER(comments) like ?)"] * like_tokens.size).join(operator), * (like_tokens).sort] ) if @project.repository && @scope.include?('changesets')
|
||||||
|
Message.with_scope :find => {:conditions => ["#{Board.table_name}.project_id = ?", @project.id]} do
|
||||||
|
@results += Message.find(:all, :include => :board, :limit => limit, :conditions => [ (["(LOWER(subject) like ? OR LOWER(content) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'messages'
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Project.with_scope(:find => {:conditions => Project.visible_by(logged_in_user)}) do
|
||||||
|
@results += Project.find(:all, :limit => limit, :conditions => [ (["(LOWER(name) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'projects'
|
||||||
|
end
|
||||||
|
# if only one project is found, user is redirected to its overview
|
||||||
|
redirect_to :controller => 'projects', :action => 'show', :id => @results.first and return if @results.size == 1
|
||||||
|
end
|
||||||
|
@question = @tokens.join(" ")
|
||||||
|
else
|
||||||
|
@question = ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_project
|
||||||
|
@project = Project.find(params[:id])
|
||||||
|
@html_title = @project.name
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# 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
|
||||||
|
@textile_available = ActionView::Helpers::TextHelper.method_defined?("textilize")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# redMine - project management software
|
||||||
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class SysController < ActionController::Base
|
||||||
|
wsdl_service_name 'Sys'
|
||||||
|
web_service_api SysApi
|
||||||
|
web_service_scaffold :invoke
|
||||||
|
|
||||||
|
before_invocation :check_enabled
|
||||||
|
|
||||||
|
def projects
|
||||||
|
Project.find(:all, :include => :repository)
|
||||||
|
end
|
||||||
|
|
||||||
|
def repository_created(project_id, url)
|
||||||
|
project = Project.find_by_id(project_id)
|
||||||
|
return 0 unless project && project.repository.nil?
|
||||||
|
logger.debug "Repository for #{project.name} created"
|
||||||
|
repository = Repository.new(:project => project, :url => url)
|
||||||
|
repository.root_url = url
|
||||||
|
repository.save
|
||||||
|
repository.id
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def check_enabled(name, args)
|
||||||
|
Setting.sys_api_enabled?
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
# 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 TimelogController < ApplicationController
|
||||||
|
layout 'base'
|
||||||
|
|
||||||
|
before_filter :find_project
|
||||||
|
before_filter :authorize, :only => :edit
|
||||||
|
before_filter :check_project_privacy, :except => :edit
|
||||||
|
|
||||||
|
helper :sort
|
||||||
|
include SortHelper
|
||||||
|
|
||||||
|
def report
|
||||||
|
@available_criterias = { 'version' => {:sql => "#{Issue.table_name}.fixed_version_id",
|
||||||
|
:values => @project.versions,
|
||||||
|
:label => :label_version},
|
||||||
|
'category' => {:sql => "#{Issue.table_name}.category_id",
|
||||||
|
:values => @project.issue_categories,
|
||||||
|
:label => :field_category},
|
||||||
|
'member' => {:sql => "#{TimeEntry.table_name}.user_id",
|
||||||
|
:values => @project.users,
|
||||||
|
:label => :label_member},
|
||||||
|
'tracker' => {:sql => "#{Issue.table_name}.tracker_id",
|
||||||
|
:values => Tracker.find(:all),
|
||||||
|
:label => :label_tracker},
|
||||||
|
'activity' => {:sql => "#{TimeEntry.table_name}.activity_id",
|
||||||
|
:values => Enumeration::get_values('ACTI'),
|
||||||
|
:label => :label_activity}
|
||||||
|
}
|
||||||
|
|
||||||
|
@criterias = params[:criterias] || []
|
||||||
|
@criterias = @criterias.select{|criteria| @available_criterias.has_key? criteria}
|
||||||
|
@criterias.uniq!
|
||||||
|
|
||||||
|
@columns = (params[:period] && %w(year month week).include?(params[:period])) ? params[:period] : 'month'
|
||||||
|
|
||||||
|
if params[:date_from]
|
||||||
|
begin; @date_from = params[:date_from].to_date; rescue; end
|
||||||
|
end
|
||||||
|
if params[:date_to]
|
||||||
|
begin; @date_to = params[:date_to].to_date; rescue; end
|
||||||
|
end
|
||||||
|
@date_from ||= Date.civil(Date.today.year, 1, 1)
|
||||||
|
@date_to ||= Date.civil(Date.today.year, Date.today.month+1, 1) - 1
|
||||||
|
|
||||||
|
unless @criterias.empty?
|
||||||
|
sql_select = @criterias.collect{|criteria| @available_criterias[criteria][:sql] + " AS " + criteria}.join(', ')
|
||||||
|
sql_group_by = @criterias.collect{|criteria| @available_criterias[criteria][:sql]}.join(', ')
|
||||||
|
|
||||||
|
sql = "SELECT #{sql_select}, tyear, tmonth, tweek, SUM(hours) AS hours"
|
||||||
|
sql << " FROM #{TimeEntry.table_name} LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id"
|
||||||
|
sql << " WHERE #{TimeEntry.table_name}.project_id = %s" % @project.id
|
||||||
|
sql << " AND spent_on BETWEEN '%s' AND '%s'" % [ActiveRecord::Base.connection.quoted_date(@date_from.to_time), ActiveRecord::Base.connection.quoted_date(@date_to.to_time)]
|
||||||
|
sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek"
|
||||||
|
|
||||||
|
@hours = ActiveRecord::Base.connection.select_all(sql)
|
||||||
|
|
||||||
|
@hours.each do |row|
|
||||||
|
case @columns
|
||||||
|
when 'year'
|
||||||
|
row['year'] = row['tyear']
|
||||||
|
when 'month'
|
||||||
|
row['month'] = "#{row['tyear']}-#{row['tmonth']}"
|
||||||
|
when 'week'
|
||||||
|
row['week'] = "#{row['tyear']}-#{row['tweek']}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@periods = []
|
||||||
|
date_from = @date_from
|
||||||
|
# 100 columns max
|
||||||
|
while date_from < @date_to && @periods.length < 100
|
||||||
|
case @columns
|
||||||
|
when 'year'
|
||||||
|
@periods << "#{date_from.year}"
|
||||||
|
date_from = date_from >> 12
|
||||||
|
when 'month'
|
||||||
|
@periods << "#{date_from.year}-#{date_from.month}"
|
||||||
|
date_from = date_from >> 1
|
||||||
|
when 'week'
|
||||||
|
@periods << "#{date_from.year}-#{date_from.cweek}"
|
||||||
|
date_from = date_from + 7
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
render :layout => false if request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
|
def details
|
||||||
|
sort_init 'spent_on', 'desc'
|
||||||
|
sort_update
|
||||||
|
|
||||||
|
@entries = (@issue ? @issue : @project).time_entries.find(:all, :include => [:activity, :user, {:issue => [:tracker, :assigned_to, :priority]}], :order => sort_clause)
|
||||||
|
|
||||||
|
@total_hours = @entries.inject(0) { |sum,entry| sum + entry.hours }
|
||||||
|
@owner_id = logged_in_user ? logged_in_user.id : 0
|
||||||
|
|
||||||
|
send_csv and return if 'csv' == params[:export]
|
||||||
|
render :action => 'details', :layout => false if request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
render_404 and return if @time_entry && @time_entry.user != logged_in_user
|
||||||
|
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => logged_in_user, :spent_on => Date.today)
|
||||||
|
@time_entry.attributes = params[:time_entry]
|
||||||
|
if request.post? and @time_entry.save
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
redirect_to :action => 'details', :project_id => @time_entry.project, :issue_id => @time_entry.issue
|
||||||
|
return
|
||||||
|
end
|
||||||
|
@activities = Enumeration::get_values('ACTI')
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_project
|
||||||
|
if params[:id]
|
||||||
|
@time_entry = TimeEntry.find(params[:id])
|
||||||
|
@project = @time_entry.project
|
||||||
|
elsif params[:issue_id]
|
||||||
|
@issue = Issue.find(params[:issue_id])
|
||||||
|
@project = @issue.project
|
||||||
|
elsif params[:project_id]
|
||||||
|
@project = Project.find(params[:project_id])
|
||||||
|
else
|
||||||
|
render_404
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_csv
|
||||||
|
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||||
|
export = StringIO.new
|
||||||
|
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
||||||
|
# csv header fields
|
||||||
|
headers = [l(:field_spent_on),
|
||||||
|
l(:field_user),
|
||||||
|
l(:field_activity),
|
||||||
|
l(:field_issue),
|
||||||
|
l(:field_hours),
|
||||||
|
l(:field_comments)
|
||||||
|
]
|
||||||
|
csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
||||||
|
# csv lines
|
||||||
|
@entries.each do |entry|
|
||||||
|
fields = [l_date(entry.spent_on),
|
||||||
|
entry.user.name,
|
||||||
|
entry.activity.name,
|
||||||
|
(entry.issue ? entry.issue.id : nil),
|
||||||
|
entry.hours,
|
||||||
|
entry.comments
|
||||||
|
]
|
||||||
|
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
export.rewind
|
||||||
|
send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -25,19 +25,26 @@ class TrackersController < ApplicationController
|
|||||||
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?
|
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
|
||||||
|
# workflow copy
|
||||||
|
if params[:copy_workflow_from] && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
|
||||||
|
copy_from.workflows.each do |w|
|
||||||
|
@tracker.workflows << w.clone
|
||||||
|
end
|
||||||
|
end
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
|
@trackers = Tracker.find :all
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@@ -48,6 +55,21 @@ class TrackersController < ApplicationController
|
|||||||
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?
|
||||||
@@ -57,5 +79,4 @@ class TrackersController < ApplicationController
|
|||||||
end
|
end
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -32,11 +32,17 @@ class UsersController < ApplicationController
|
|||||||
def list
|
def list
|
||||||
sort_init 'login', 'asc'
|
sort_init 'login', 'asc'
|
||||||
sort_update
|
sort_update
|
||||||
@user_count = User.count
|
|
||||||
|
@status = params[:status] ? params[:status].to_i : 1
|
||||||
|
conditions = nil
|
||||||
|
conditions = ["status=?", @status] unless @status == 0
|
||||||
|
|
||||||
|
@user_count = User.count(:conditions => conditions)
|
||||||
@user_pages = Paginator.new self, @user_count,
|
@user_pages = Paginator.new self, @user_count,
|
||||||
15,
|
15,
|
||||||
params['page']
|
params['page']
|
||||||
@users = User.find :all,:order => sort_clause,
|
@users = User.find :all,:order => sort_clause,
|
||||||
|
:conditions => conditions,
|
||||||
:limit => @user_pages.items_per_page,
|
:limit => @user_pages.items_per_page,
|
||||||
:offset => @user_pages.current.offset
|
:offset => @user_pages.current.offset
|
||||||
|
|
||||||
@@ -45,7 +51,7 @@ class UsersController < ApplicationController
|
|||||||
|
|
||||||
def add
|
def add
|
||||||
if request.get?
|
if request.get?
|
||||||
@user = User.new(:language => $RDM_DEFAULT_LANG)
|
@user = User.new(:language => Setting.default_language)
|
||||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
|
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
|
||||||
else
|
else
|
||||||
@user = User.new(params[:user])
|
@user = User.new(params[:user])
|
||||||
@@ -55,6 +61,7 @@ class UsersController < ApplicationController
|
|||||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
|
@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
|
@user.custom_values = @custom_values
|
||||||
if @user.save
|
if @user.save
|
||||||
|
Mailer.deliver_account_information(@user, params[:password]) if params[:send_information]
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
redirect_to :action => 'list'
|
redirect_to :action => 'list'
|
||||||
end
|
end
|
||||||
@@ -80,8 +87,8 @@ class UsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
@auth_sources = AuthSource.find(:all)
|
@auth_sources = AuthSource.find(:all)
|
||||||
@roles = Role.find :all
|
@roles = Role.find(:all, :order => 'position')
|
||||||
@projects = Project.find(:all) - @user.projects
|
@projects = Project.find(:all, :order => 'name', :conditions => "status=#{Project::STATUS_ACTIVE}") - @user.projects
|
||||||
@membership ||= Member.new
|
@membership ||= Member.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -22,16 +22,16 @@ class VersionsController < ApplicationController
|
|||||||
def edit
|
def edit
|
||||||
if request.post? and @version.update_attributes(params[:version])
|
if request.post? and @version.update_attributes(params[:version])
|
||||||
flash[:notice] = l(:notice_successful_update)
|
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
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# 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 WatchersController < ApplicationController
|
||||||
|
layout 'base'
|
||||||
|
before_filter :require_login, :find_project, :check_project_privacy
|
||||||
|
|
||||||
|
def add
|
||||||
|
user = logged_in_user
|
||||||
|
@watched.add_watcher(user)
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :text => 'Watcher added.', :layout => true }
|
||||||
|
format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove
|
||||||
|
user = logged_in_user
|
||||||
|
@watched.remove_watcher(user)
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :text => 'Watcher removed.', :layout => true }
|
||||||
|
format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_project
|
||||||
|
klass = Object.const_get(params[:object_type].camelcase)
|
||||||
|
return false unless klass.respond_to?('watched_by')
|
||||||
|
@watched = klass.find(params[:object_id])
|
||||||
|
@project = @watched.project
|
||||||
|
rescue
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
# 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 'diff'
|
||||||
|
|
||||||
|
class WikiController < ApplicationController
|
||||||
|
layout 'base'
|
||||||
|
before_filter :find_wiki, :check_project_privacy
|
||||||
|
before_filter :authorize, :only => [:destroy, :add_attachment, :destroy_attachment]
|
||||||
|
|
||||||
|
verify :method => :post, :only => [:destroy, :destroy_attachment], :redirect_to => { :action => :index }
|
||||||
|
|
||||||
|
helper :attachments
|
||||||
|
include AttachmentsHelper
|
||||||
|
|
||||||
|
# display a page (in editing mode if it doesn't exist)
|
||||||
|
def index
|
||||||
|
page_title = params[:page]
|
||||||
|
@page = @wiki.find_or_new_page(page_title)
|
||||||
|
if @page.new_record?
|
||||||
|
edit
|
||||||
|
render :action => 'edit' and return
|
||||||
|
end
|
||||||
|
@content = @page.content_for_version(params[:version])
|
||||||
|
if params[:export] == 'html'
|
||||||
|
export = render_to_string :action => 'export', :layout => false
|
||||||
|
send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
|
||||||
|
return
|
||||||
|
elsif params[:export] == 'txt'
|
||||||
|
send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
render :action => 'show'
|
||||||
|
end
|
||||||
|
|
||||||
|
# edit an existing page or a new one
|
||||||
|
def edit
|
||||||
|
@page = @wiki.find_or_new_page(params[:page])
|
||||||
|
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||||
|
|
||||||
|
@content = @page.content_for_version(params[:version])
|
||||||
|
@content.text = "h1. #{@page.pretty_title}" if @content.text.blank?
|
||||||
|
# don't keep previous comment
|
||||||
|
@content.comments = nil
|
||||||
|
if request.post?
|
||||||
|
if @content.text == params[:content][:text]
|
||||||
|
# don't save if text wasn't changed
|
||||||
|
redirect_to :action => 'index', :id => @project, :page => @page.title
|
||||||
|
return
|
||||||
|
end
|
||||||
|
#@content.text = params[:content][:text]
|
||||||
|
#@content.comments = params[:content][:comments]
|
||||||
|
@content.attributes = params[:content]
|
||||||
|
@content.author = logged_in_user
|
||||||
|
# if page is new @page.save will also save content, but not if page isn't a new record
|
||||||
|
if (@page.new_record? ? @page.save : @content.save)
|
||||||
|
redirect_to :action => 'index', :id => @project, :page => @page.title
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue ActiveRecord::StaleObjectError
|
||||||
|
# Optimistic locking exception
|
||||||
|
flash[:notice] = l(:notice_locking_conflict)
|
||||||
|
end
|
||||||
|
|
||||||
|
# show page history
|
||||||
|
def history
|
||||||
|
@page = @wiki.find_page(params[:page])
|
||||||
|
|
||||||
|
@version_count = @page.content.versions.count
|
||||||
|
@version_pages = Paginator.new self, @version_count, 25, params['p']
|
||||||
|
# don't load text
|
||||||
|
@versions = @page.content.versions.find :all,
|
||||||
|
:select => "id, author_id, comments, updated_on, version",
|
||||||
|
:order => 'version DESC',
|
||||||
|
:limit => @version_pages.items_per_page + 1,
|
||||||
|
:offset => @version_pages.current.offset
|
||||||
|
|
||||||
|
render :layout => false if request.xhr?
|
||||||
|
end
|
||||||
|
|
||||||
|
def diff
|
||||||
|
@page = @wiki.find_page(params[:page])
|
||||||
|
@diff = @page.diff(params[:version], params[:version_from])
|
||||||
|
render_404 unless @diff
|
||||||
|
end
|
||||||
|
|
||||||
|
# remove a wiki page and its history
|
||||||
|
def destroy
|
||||||
|
@page = @wiki.find_page(params[:page])
|
||||||
|
@page.destroy if @page
|
||||||
|
redirect_to :action => 'special', :id => @project, :page => 'Page_index'
|
||||||
|
end
|
||||||
|
|
||||||
|
# display special pages
|
||||||
|
def special
|
||||||
|
page_title = params[:page].downcase
|
||||||
|
case page_title
|
||||||
|
# show pages index, sorted by title
|
||||||
|
when 'page_index'
|
||||||
|
# eager load information about last updates, without loading text
|
||||||
|
@pages = @wiki.pages.find :all, :select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on",
|
||||||
|
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id",
|
||||||
|
:order => 'title'
|
||||||
|
# export wiki to a single html file
|
||||||
|
when 'export'
|
||||||
|
@pages = @wiki.pages.find :all, :order => 'title'
|
||||||
|
export = render_to_string :action => 'export_multiple', :layout => false
|
||||||
|
send_data(export, :type => 'text/html', :filename => "wiki.html")
|
||||||
|
return
|
||||||
|
else
|
||||||
|
# requested special page doesn't exist, redirect to default page
|
||||||
|
redirect_to :action => 'index', :id => @project, :page => nil and return
|
||||||
|
end
|
||||||
|
render :action => "special_#{page_title}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def preview
|
||||||
|
page = @wiki.find_page(params[:page])
|
||||||
|
@attachements = page.attachments if page
|
||||||
|
@text = params[:content][:text]
|
||||||
|
render :partial => 'preview'
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_attachment
|
||||||
|
@page = @wiki.find_page(params[:page])
|
||||||
|
# Save the attachments
|
||||||
|
params[:attachments].each { |file|
|
||||||
|
next unless file.size > 0
|
||||||
|
a = Attachment.create(:container => @page, :file => file, :author => logged_in_user)
|
||||||
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
|
redirect_to :action => 'index', :page => @page.title
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy_attachment
|
||||||
|
@page = @wiki.find_page(params[:page])
|
||||||
|
@page.attachments.find(params[:attachment_id]).destroy
|
||||||
|
redirect_to :action => 'index', :page => @page.title
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_wiki
|
||||||
|
@project = Project.find(params[:id])
|
||||||
|
@wiki = @project.wiki
|
||||||
|
render_404 unless @wiki
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -16,4 +16,8 @@
|
|||||||
# 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 AdminHelper
|
module AdminHelper
|
||||||
|
def project_status_options_for_select(selected)
|
||||||
|
options_for_select([[l(:label_all), "*"],
|
||||||
|
[l(:status_active), 1]], selected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -15,6 +15,14 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class RedCloth
|
||||||
|
# Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet.
|
||||||
|
# <a href="http://code.whytheluckystiff.net/redcloth/changeset/128">http://code.whytheluckystiff.net/redcloth/changeset/128</a>
|
||||||
|
def hard_break( text )
|
||||||
|
text.gsub!( /(.)\n(?!\n|\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
|
|
||||||
# Return current logged in user or nil
|
# Return current logged in user or nil
|
||||||
@@ -34,7 +42,7 @@ module ApplicationHelper
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
# check if user is authorized
|
# 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) ) )
|
if @logged_in_user and (@logged_in_user.admin? or Permission.allowed_to_role( "%s/%s" % [ controller, action ], @logged_in_user.role_for_project(@project) ) )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -47,15 +55,39 @@ module ApplicationHelper
|
|||||||
|
|
||||||
# Display a link to user's account page
|
# Display a link to user's account page
|
||||||
def link_to_user(user)
|
def link_to_user(user)
|
||||||
link_to user.display_name, :controller => 'account', :action => 'show', :id => user
|
link_to user.name, :controller => 'account', :action => 'show', :id => user
|
||||||
|
end
|
||||||
|
|
||||||
|
def link_to_issue(issue)
|
||||||
|
link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue
|
||||||
|
end
|
||||||
|
|
||||||
|
def toggle_link(name, id, options={})
|
||||||
|
onclick = "Element.toggle('#{id}'); "
|
||||||
|
onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
|
||||||
|
onclick << "return false;"
|
||||||
|
link_to(name, "#", :onclick => onclick)
|
||||||
|
end
|
||||||
|
|
||||||
|
def image_to_function(name, function, html_options = {})
|
||||||
|
html_options.symbolize_keys!
|
||||||
|
tag(:input, html_options.merge({
|
||||||
|
:type => "image", :src => image_path(name),
|
||||||
|
:onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
|
||||||
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_date(date)
|
def format_date(date)
|
||||||
l_date(date) if date
|
return nil unless date
|
||||||
|
@date_format_setting ||= Setting.date_format.to_i
|
||||||
|
@date_format_setting == 0 ? l_date(date) : date.strftime("%Y-%m-%d")
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_time(time)
|
def format_time(time)
|
||||||
l_datetime(time) if time
|
return nil unless time
|
||||||
|
@date_format_setting ||= Setting.date_format.to_i
|
||||||
|
time = time.to_time if time.is_a?(String)
|
||||||
|
@date_format_setting == 0 ? l_datetime(time) : (time.strftime("%Y-%m-%d") + ' ' + l_time(time))
|
||||||
end
|
end
|
||||||
|
|
||||||
def day_name(day)
|
def day_name(day)
|
||||||
@@ -67,25 +99,89 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pagination_links_full(paginator, options={}, html_options={})
|
def pagination_links_full(paginator, options={}, html_options={})
|
||||||
|
page_param = options.delete(:page_param) || :page
|
||||||
|
|
||||||
html = ''
|
html = ''
|
||||||
html << link_to_remote(('« ' + l(:label_previous)),
|
html << link_to_remote(('« ' + l(:label_previous)),
|
||||||
{:update => "content", :url => { :page => paginator.current.previous }},
|
{:update => "content", :url => options.merge(page_param => paginator.current.previous)},
|
||||||
{:href => url_for(:action => 'list', :params => params.merge({:page => paginator.current.previous}))}) + ' ' if paginator.current.previous
|
{:href => url_for(:params => options.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
|
||||||
|
|
||||||
html << (pagination_links_each(paginator, options) do |n|
|
html << (pagination_links_each(paginator, options) do |n|
|
||||||
link_to_remote(n.to_s,
|
link_to_remote(n.to_s,
|
||||||
{:url => {:action => 'list', :params => params.merge({:page => n})}, :update => 'content'},
|
{:url => {:params => options.merge(page_param => n)}, :update => 'content'},
|
||||||
{:href => url_for(:action => 'list', :params => params.merge({:page => n}))})
|
{:href => url_for(:params => options.merge(page_param => n))})
|
||||||
end || '')
|
end || '')
|
||||||
|
|
||||||
html << ' ' + link_to_remote((l(:label_next) + ' »'),
|
html << ' ' + link_to_remote((l(:label_next) + ' »'),
|
||||||
{:update => "content", :url => { :page => paginator.current.next }},
|
{:update => "content", :url => options.merge(page_param => paginator.current.next)},
|
||||||
{:href => url_for(:action => 'list', :params => params.merge({:page => paginator.current.next}))}) if paginator.current.next
|
{:href => url_for(:params => options.merge(page_param => paginator.current.next))}) if paginator.current.next
|
||||||
html
|
html
|
||||||
end
|
end
|
||||||
|
|
||||||
def textilizable(text)
|
# textilize text according to system settings and RedCloth availability
|
||||||
$RDM_TEXTILE_DISABLED ? simple_format(auto_link(h(text))) : RedCloth.new(h(text)).to_html
|
def textilizable(text, options = {})
|
||||||
|
return "" if text.blank?
|
||||||
|
|
||||||
|
# different methods for formatting wiki links
|
||||||
|
case options[:wiki_links]
|
||||||
|
when :local
|
||||||
|
# used for local links to html files
|
||||||
|
format_wiki_link = Proc.new {|title| "#{title}.html" }
|
||||||
|
when :anchor
|
||||||
|
# used for single-file wiki export
|
||||||
|
format_wiki_link = Proc.new {|title| "##{title}" }
|
||||||
|
else
|
||||||
|
if @project
|
||||||
|
format_wiki_link = Proc.new {|title| url_for :controller => 'wiki', :action => 'index', :id => @project, :page => title }
|
||||||
|
else
|
||||||
|
format_wiki_link = Proc.new {|title| title }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# turn wiki links into textile links:
|
||||||
|
# example:
|
||||||
|
# [[link]] -> "link":link
|
||||||
|
# [[link|title]] -> "title":link
|
||||||
|
text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + format_wiki_link.call(Wiki.titleize($1)) }
|
||||||
|
|
||||||
|
# turn issue ids into links
|
||||||
|
# example:
|
||||||
|
# #52 -> <a href="/issues/show/52">#52</a>
|
||||||
|
text = text.gsub(/#(\d+)(?=\b)/) {|m| link_to "##{$1}", :controller => 'issues', :action => 'show', :id => $1}
|
||||||
|
|
||||||
|
# turn revision ids into links (@project needed)
|
||||||
|
# example:
|
||||||
|
# r52 -> <a href="/repositories/revision/6?rev=52">r52</a> (@project.id is 6)
|
||||||
|
text = text.gsub(/(?=\b)r(\d+)(?=\b)/) {|m| link_to "r#{$1}", :controller => 'repositories', :action => 'revision', :id => @project.id, :rev => $1} if @project
|
||||||
|
|
||||||
|
# when using an image link, try to use an attachment, if possible
|
||||||
|
attachments = options[:attachments]
|
||||||
|
if attachments
|
||||||
|
text = text.gsub(/!([<>=]*)(\S+\.(gif|jpg|jpeg|png))!/) do |m|
|
||||||
|
align = $1
|
||||||
|
filename = $2
|
||||||
|
rf = Regexp.new(filename, Regexp::IGNORECASE)
|
||||||
|
# search for the picture in attachments
|
||||||
|
if found = attachments.detect { |att| att.filename =~ rf }
|
||||||
|
image_url = url_for :controller => 'attachments', :action => 'show', :id => found.id
|
||||||
|
"!#{align}#{image_url}!"
|
||||||
|
else
|
||||||
|
"!#{align}#{filename}!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# finally textilize text
|
||||||
|
@do_textilize ||= (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize")
|
||||||
|
text = @do_textilize ? auto_link(RedCloth.new(text, [:hard_breaks]).to_html) : simple_format(auto_link(h(text)))
|
||||||
|
end
|
||||||
|
|
||||||
|
# Same as Rails' simple_format helper without using paragraphs
|
||||||
|
def simple_format_without_paragraph(text)
|
||||||
|
text.to_s.
|
||||||
|
gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
|
||||||
|
gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
|
||||||
|
gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_messages_for(object_name, options = {})
|
def error_messages_for(object_name, options = {})
|
||||||
@@ -96,6 +192,7 @@ module ApplicationHelper
|
|||||||
full_messages = []
|
full_messages = []
|
||||||
object.errors.each do |attr, msg|
|
object.errors.each do |attr, msg|
|
||||||
next if msg.nil?
|
next if msg.nil?
|
||||||
|
msg = msg.first if msg.is_a? Array
|
||||||
if attr == "base"
|
if attr == "base"
|
||||||
full_messages << l(msg)
|
full_messages << l(msg)
|
||||||
else
|
else
|
||||||
@@ -107,6 +204,7 @@ module ApplicationHelper
|
|||||||
object.custom_values.each do |v|
|
object.custom_values.each do |v|
|
||||||
v.errors.each do |attr, msg|
|
v.errors.each do |attr, msg|
|
||||||
next if msg.nil?
|
next if msg.nil?
|
||||||
|
msg = msg.first if msg.is_a? Array
|
||||||
full_messages << "« " + v.custom_field.name + " » " + l(msg)
|
full_messages << "« " + v.custom_field.name + " » " + l(msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -123,8 +221,9 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def lang_options_for_select
|
def lang_options_for_select(blank=true)
|
||||||
(GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]}
|
(blank ? [["(auto)", ""]] : []) +
|
||||||
|
GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.first <=> y.first }
|
||||||
end
|
end
|
||||||
|
|
||||||
def label_tag_for(name, option_tags = nil, options = {})
|
def label_tag_for(name, option_tags = nil, options = {})
|
||||||
@@ -145,9 +244,14 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def calendar_for(field_id)
|
def calendar_for(field_id)
|
||||||
image_tag("calendar", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
|
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' });")
|
javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def wikitoolbar_for(field_id)
|
||||||
|
return '' unless Setting.text_formatting == 'textile'
|
||||||
|
javascript_include_tag('jstoolbar') + javascript_tag("var toolbar = new jsToolBar($('#{field_id}')); toolbar.draw();")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TabularFormBuilder < ActionView::Helpers::FormBuilder
|
class TabularFormBuilder < ActionView::Helpers::FormBuilder
|
||||||
@@ -162,7 +266,9 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
|
|||||||
src = <<-END_SRC
|
src = <<-END_SRC
|
||||||
def #{selector}(field, options = {})
|
def #{selector}(field, options = {})
|
||||||
return super if options.delete :no_label
|
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_text = l(options[:label]) if options[:label]
|
||||||
|
label_text ||= l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym)
|
||||||
|
label_text << @template.content_tag("span", " *", :class => "required") if options.delete(:required)
|
||||||
label = @template.content_tag("label", label_text,
|
label = @template.content_tag("label", label_text,
|
||||||
:class => (@object && @object.errors[field] ? "error" : nil),
|
:class => (@object && @object.errors[field] ? "error" : nil),
|
||||||
:for => (@object_name.to_s + "_" + field.to_s))
|
:for => (@object_name.to_s + "_" + field.to_s))
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# 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 AttachmentsHelper
|
||||||
|
# displays the links to a collection of attachments
|
||||||
|
def link_to_attachments(attachments, options = {})
|
||||||
|
if attachments.any?
|
||||||
|
render :partial => 'attachments/links', :locals => {:attachments => attachments, :options => options}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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 BoardsHelper
|
||||||
|
end
|
||||||
@@ -34,7 +34,7 @@ module CustomFieldsHelper
|
|||||||
when "bool"
|
when "bool"
|
||||||
check_box 'custom_value', 'value', :name => field_name, :id => field_id
|
check_box 'custom_value', 'value', :name => field_name, :id => field_id
|
||||||
when "list"
|
when "list"
|
||||||
select 'custom_value', 'value', custom_field.possible_values.split('|'), { :include_blank => true }, :name => field_name, :id => field_id
|
select 'custom_value', 'value', custom_field.possible_values, { :include_blank => true }, :name => field_name, :id => field_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -59,10 +59,10 @@ module CustomFieldsHelper
|
|||||||
|
|
||||||
# Return a string used to display a custom value
|
# Return a string used to display a custom value
|
||||||
def format_value(value, field_format)
|
def format_value(value, field_format)
|
||||||
return "" unless value
|
return "" unless value && !value.empty?
|
||||||
case field_format
|
case field_format
|
||||||
when "date"
|
when "date"
|
||||||
value.empty? ? "" : l_date(value.to_date)
|
begin; l_date(value.to_date); rescue; value end
|
||||||
when "bool"
|
when "bool"
|
||||||
l_YesNo(value == "1")
|
l_YesNo(value == "1")
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -16,15 +16,42 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require 'iconv'
|
require 'iconv'
|
||||||
|
require 'rfpdf/chinese'
|
||||||
|
|
||||||
module IfpdfHelper
|
module IfpdfHelper
|
||||||
|
|
||||||
class IFPDF < FPDF
|
class IFPDF < FPDF
|
||||||
|
include GLoc
|
||||||
attr_accessor :footer_date
|
attr_accessor :footer_date
|
||||||
|
|
||||||
|
def initialize(lang)
|
||||||
|
super()
|
||||||
|
set_language_if_valid lang
|
||||||
|
case current_language
|
||||||
|
when :ja
|
||||||
|
extend(PDF_Japanese)
|
||||||
|
AddSJISFont()
|
||||||
|
@font_for_content = 'SJIS'
|
||||||
|
@font_for_footer = 'SJIS'
|
||||||
|
when :zh
|
||||||
|
extend(PDF_Chinese)
|
||||||
|
AddBig5Font()
|
||||||
|
@font_for_content = 'Big5'
|
||||||
|
@font_for_footer = 'Big5'
|
||||||
|
else
|
||||||
|
@font_for_content = 'Arial'
|
||||||
|
@font_for_footer = 'Helvetica'
|
||||||
|
end
|
||||||
|
SetCreator("redMine #{Redmine::VERSION}")
|
||||||
|
SetFont(@font_for_content)
|
||||||
|
end
|
||||||
|
|
||||||
|
def SetFontStyle(style, size)
|
||||||
|
SetFont(@font_for_content, style, size)
|
||||||
|
end
|
||||||
|
|
||||||
def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
|
def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
|
||||||
@ic ||= Iconv.new('ISO-8859-1', 'UTF-8')
|
@ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
|
||||||
txt = begin
|
txt = begin
|
||||||
@ic.iconv(txt)
|
@ic.iconv(txt)
|
||||||
rescue
|
rescue
|
||||||
@@ -34,7 +61,7 @@ module IfpdfHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def Footer
|
def Footer
|
||||||
SetFont('Helvetica', 'I', 8)
|
SetFont(@font_for_footer, 'I', 8)
|
||||||
SetY(-15)
|
SetY(-15)
|
||||||
SetX(15)
|
SetX(15)
|
||||||
Cell(0, 5, @footer_date, 0, 0, 'L')
|
Cell(0, 5, @footer_date, 0, 0, 'L')
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# 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 IssueRelationsHelper
|
||||||
|
def collection_for_relation_type_select
|
||||||
|
values = IssueRelation::TYPES
|
||||||
|
values.keys.sort{|x,y| values[x][:order] <=> values[y][:order]}.collect{|k| [l(values[k][:name]), k]}
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -48,6 +48,8 @@ module IssuesHelper
|
|||||||
value = format_value(detail.value, custom_field.field_format) if detail.value
|
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
|
old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value
|
||||||
end
|
end
|
||||||
|
when 'attachment'
|
||||||
|
label = l(:label_attachment)
|
||||||
end
|
end
|
||||||
|
|
||||||
label ||= detail.prop_key
|
label ||= detail.prop_key
|
||||||
@@ -56,19 +58,29 @@ module IssuesHelper
|
|||||||
|
|
||||||
unless no_html
|
unless no_html
|
||||||
label = content_tag('strong', label)
|
label = content_tag('strong', label)
|
||||||
old_value = content_tag("i", h(old_value)) if old_value
|
old_value = content_tag("i", h(old_value)) if detail.old_value
|
||||||
old_value = content_tag("strike", h(old_value)) if old_value and !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
|
value = content_tag("i", h(value)) if value
|
||||||
end
|
end
|
||||||
|
|
||||||
if value
|
if detail.value and !detail.value.to_s.empty?
|
||||||
if old_value
|
case detail.property
|
||||||
label + " " + l(:text_journal_changed, old_value, value)
|
when 'attr', 'cf'
|
||||||
else
|
if old_value
|
||||||
label + " " + l(:text_journal_set_to, value)
|
label + " " + l(:text_journal_changed, old_value, value)
|
||||||
|
else
|
||||||
|
label + " " + l(:text_journal_set_to, value)
|
||||||
|
end
|
||||||
|
when 'attachment'
|
||||||
|
"#{label} #{value} #{l(:label_added)}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
label + " " + l(:text_journal_deleted) + " (#{old_value})"
|
case detail.property
|
||||||
|
when 'attr', 'cf'
|
||||||
|
label + " " + l(:text_journal_deleted) + " (#{old_value})"
|
||||||
|
when 'attachment'
|
||||||
|
"#{label} #{old_value} #{l(:label_deleted)}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# 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 MessagesHelper
|
||||||
|
|
||||||
|
def link_to_message(message)
|
||||||
|
return '' unless message
|
||||||
|
link_to h(truncate(message.subject, 60)), :controller => 'messages',
|
||||||
|
:action => 'show',
|
||||||
|
:board_id => message.board_id,
|
||||||
|
:id => message.root,
|
||||||
|
:anchor => (message.parent_id ? "message-#{message.id}" : nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -16,4 +16,13 @@
|
|||||||
# 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 ProjectsHelper
|
module ProjectsHelper
|
||||||
|
def link_to_version(version, options = {})
|
||||||
|
return '' unless version && version.is_a?(Version)
|
||||||
|
link_to version.name, {:controller => 'projects',
|
||||||
|
:action => 'roadmap',
|
||||||
|
:id => version.project_id,
|
||||||
|
:completed => (version.completed? ? 1 : nil),
|
||||||
|
:anchor => version.name
|
||||||
|
}, options
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ module ReportsHelper
|
|||||||
data.each { |row|
|
data.each { |row|
|
||||||
match = 1
|
match = 1
|
||||||
criteria.each { |k, v|
|
criteria.each { |k, v|
|
||||||
match = 0 unless row[k].to_s == v.to_s
|
match = 0 unless (row[k].to_s == v.to_s) || (k == 'closed' && row[k] == (v == 0 ? "f" : "t"))
|
||||||
} unless criteria.nil?
|
} unless criteria.nil?
|
||||||
a = a + row["total"].to_i if match == 1
|
a = a + row["total"].to_i if match == 1
|
||||||
} unless data.nil?
|
} unless data.nil?
|
||||||
|
|||||||
@@ -16,4 +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.
|
||||||
|
|
||||||
module RepositoriesHelper
|
module RepositoriesHelper
|
||||||
|
def repository_field_tags(form, repository)
|
||||||
|
method = repository.class.name.demodulize.underscore + "_field_tags"
|
||||||
|
send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method)
|
||||||
|
end
|
||||||
|
|
||||||
|
def scm_select_tag
|
||||||
|
container = [[]]
|
||||||
|
REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]}
|
||||||
|
select_tag('repository_scm',
|
||||||
|
options_for_select(container, @project.repository.class.name.demodulize),
|
||||||
|
:disabled => (@project.repository && !@project.repository.new_record?),
|
||||||
|
:onchange => remote_function(:update => "repository_fields", :url => { :controller => 'repositories', :action => 'update_form', :id => @project }, :with => "Form.serialize(this.form)")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def with_leading_slash(path)
|
||||||
|
path ||= ''
|
||||||
|
path.starts_with?("/") ? "/#{path}" : path
|
||||||
|
end
|
||||||
|
|
||||||
|
def subversion_field_tags(form, repository)
|
||||||
|
content_tag('p', form.text_field(:url, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)) +
|
||||||
|
'<br />(http://, https://, svn://, file:///)') +
|
||||||
|
content_tag('p', form.text_field(:login, :size => 30)) +
|
||||||
|
content_tag('p', form.password_field(:password, :size => 30))
|
||||||
|
end
|
||||||
|
|
||||||
|
def darcs_field_tags(form, repository)
|
||||||
|
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?)))
|
||||||
|
end
|
||||||
|
|
||||||
|
def mercurial_field_tags(form, repository)
|
||||||
|
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
|
||||||
|
end
|
||||||
|
|
||||||
|
def cvs_field_tags(form, repository)
|
||||||
|
content_tag('p', form.text_field(:root_url, :label => 'CVSROOT', :size => 60, :required => true, :disabled => !repository.new_record?)) +
|
||||||
|
content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# 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 SearchHelper
|
||||||
|
def highlight_tokens(text, tokens)
|
||||||
|
return text unless tokens && !tokens.empty?
|
||||||
|
regexp = Regexp.new "(#{tokens.join('|')})", Regexp::IGNORECASE
|
||||||
|
result = ''
|
||||||
|
text.split(regexp).each_with_index do |words, i|
|
||||||
|
result << (i.even? ? (words.length > 100 ? "#{words[0..44]} ... #{words[-45..-1]}" : words) : content_tag('span', words, :class => 'highlight'))
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
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
|
||||||
@@ -96,10 +96,10 @@ module SortHelper
|
|||||||
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
|
||||||
@@ -107,10 +107,12 @@ module SortHelper
|
|||||||
order = 'desc' # changed for desc order by default
|
order = 'desc' # changed for desc order by default
|
||||||
end
|
end
|
||||||
caption = titleize(Inflector::humanize(column)) unless caption
|
caption = titleize(Inflector::humanize(column)) unless caption
|
||||||
params = {:params => {:sort_key => column, :sort_order => order}}
|
|
||||||
|
url = {:sort_key => column, :sort_order => order, :issue_id => params[:issue_id], :project_id => params[:project_id]}
|
||||||
|
|
||||||
link_to_remote(caption,
|
link_to_remote(caption,
|
||||||
{:update => "content", :url => { :sort_key => column, :sort_order => order}},
|
{:update => "content", :url => url},
|
||||||
{:href => url_for(:params => { :sort_key => column, :sort_order => order})}) +
|
{:href => url_for(url)}) +
|
||||||
(icon ? nbsp(2) + image_tag(icon) : '')
|
(icon ? nbsp(2) + image_tag(icon) : '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,16 @@
|
|||||||
# 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 IssueHistory < ActiveRecord::Base
|
module TimelogHelper
|
||||||
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
|
def select_hours(data, criteria, value)
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
data.select {|row| row[criteria] == value.to_s}
|
||||||
belongs_to :issue
|
end
|
||||||
|
|
||||||
validates_presence_of :status
|
def sum_hours(data)
|
||||||
|
sum = 0
|
||||||
|
data.each do |row|
|
||||||
|
sum += row['hours'].to_f
|
||||||
|
end
|
||||||
|
sum
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -16,4 +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.
|
||||||
|
|
||||||
module UsersHelper
|
module UsersHelper
|
||||||
|
def status_options_for_select(selected)
|
||||||
|
options_for_select([[l(:label_all), "*"],
|
||||||
|
[l(:status_active), 1],
|
||||||
|
[l(:status_registered), 2],
|
||||||
|
[l(:status_locked), 3]], selected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# 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 WatchersHelper
|
||||||
|
def watcher_tag(object, user)
|
||||||
|
content_tag("span", watcher_link(object, user), :id => 'watcher')
|
||||||
|
end
|
||||||
|
|
||||||
|
def watcher_link(object, user)
|
||||||
|
return '' unless user && object.respond_to?('watched_by?')
|
||||||
|
watched = object.watched_by?(user)
|
||||||
|
url = {:controller => 'watchers',
|
||||||
|
:action => (watched ? 'remove' : 'add'),
|
||||||
|
:object_type => object.class.to_s.underscore,
|
||||||
|
:object_id => object.id}
|
||||||
|
link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)),
|
||||||
|
{:url => url},
|
||||||
|
:href => url_for(url),
|
||||||
|
:class => (watched ? 'icon icon-fav' : 'icon icon-fav-off'))
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# redMine - project management software
|
||||||
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
module WikiHelper
|
||||||
|
|
||||||
|
def html_diff(wdiff)
|
||||||
|
words = wdiff.words.collect{|word| h(word)}
|
||||||
|
words_add = 0
|
||||||
|
words_del = 0
|
||||||
|
dels = 0
|
||||||
|
del_off = 0
|
||||||
|
wdiff.diff.diffs.each do |diff|
|
||||||
|
add_at = nil
|
||||||
|
add_to = nil
|
||||||
|
del_at = nil
|
||||||
|
deleted = ""
|
||||||
|
diff.each do |change|
|
||||||
|
pos = change[1]
|
||||||
|
if change[0] == "+"
|
||||||
|
add_at = pos + dels unless add_at
|
||||||
|
add_to = pos + dels
|
||||||
|
words_add += 1
|
||||||
|
else
|
||||||
|
del_at = pos unless del_at
|
||||||
|
deleted << ' ' + change[2]
|
||||||
|
words_del += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if add_at
|
||||||
|
words[add_at] = '<span class="diff_in">' + words[add_at]
|
||||||
|
words[add_to] = words[add_to] + '</span>'
|
||||||
|
end
|
||||||
|
if del_at
|
||||||
|
words.insert del_at - del_off + dels + words_add, '<span class="diff_out">' + deleted + '</span>'
|
||||||
|
dels += 1
|
||||||
|
del_off += words_del
|
||||||
|
words_del = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
simple_format_without_paragraph(words.join(' '))
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -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,11 +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"
|
||||||
|
|
||||||
@@max_size = $RDM_ATTACHMENT_MAX_SIZE || 5*1024*1024
|
|
||||||
cattr_reader :max_size
|
|
||||||
|
|
||||||
validates_presence_of :container, :filename
|
validates_presence_of :container, :filename
|
||||||
validates_inclusion_of :filesize, :in => 1..@@max_size
|
|
||||||
|
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?
|
||||||
@@ -63,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
|
||||||
@@ -75,6 +78,10 @@ class Attachment < ActiveRecord::Base
|
|||||||
find(:all, :limit => 5, :order => "downloads DESC")
|
find(:all, :limit => 5, :order => "downloads DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def project
|
||||||
|
container.is_a?(Project) ? container : container.project
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def sanitize_filename(value)
|
def sanitize_filename(value)
|
||||||
# get only the filename, not the whole path
|
# get only the filename, not the whole path
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# 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 Board < ActiveRecord::Base
|
||||||
|
belongs_to :project
|
||||||
|
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
|
||||||
|
has_many :messages, :dependent => :delete_all, :order => "#{Message.table_name}.created_on DESC"
|
||||||
|
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
|
||||||
|
acts_as_list :scope => :project_id
|
||||||
|
acts_as_watchable
|
||||||
|
|
||||||
|
validates_presence_of :name, :description
|
||||||
|
validates_length_of :name, :maximum => 30
|
||||||
|
validates_length_of :description, :maximum => 255
|
||||||
|
end
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# redMine - project management software
|
||||||
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class Change < ActiveRecord::Base
|
||||||
|
belongs_to :changeset
|
||||||
|
|
||||||
|
validates_presence_of :changeset_id, :action, :path
|
||||||
|
end
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# redMine - project management software
|
||||||
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class Changeset < ActiveRecord::Base
|
||||||
|
belongs_to :repository
|
||||||
|
has_many :changes, :dependent => :delete_all
|
||||||
|
has_and_belongs_to_many :issues
|
||||||
|
|
||||||
|
validates_presence_of :repository_id, :revision, :committed_on, :commit_date
|
||||||
|
validates_numericality_of :revision, :only_integer => true
|
||||||
|
validates_uniqueness_of :revision, :scope => :repository_id
|
||||||
|
validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true
|
||||||
|
|
||||||
|
def committed_on=(date)
|
||||||
|
self.commit_date = date
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def after_create
|
||||||
|
scan_comment_for_issue_ids
|
||||||
|
end
|
||||||
|
|
||||||
|
def scan_comment_for_issue_ids
|
||||||
|
return if comments.blank?
|
||||||
|
# keywords used to reference issues
|
||||||
|
ref_keywords = Setting.commit_ref_keywords.downcase.split(",")
|
||||||
|
# keywords used to fix issues
|
||||||
|
fix_keywords = Setting.commit_fix_keywords.downcase.split(",")
|
||||||
|
# status applied
|
||||||
|
fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id)
|
||||||
|
|
||||||
|
kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw.strip)}.join("|")
|
||||||
|
return if kw_regexp.blank?
|
||||||
|
|
||||||
|
# remove any associated issues
|
||||||
|
self.issues.clear
|
||||||
|
|
||||||
|
comments.scan(Regexp.new("(#{kw_regexp})[\s:]+(([\s,;&]*#?\\d+)+)", Regexp::IGNORECASE)).each do |match|
|
||||||
|
action = match[0]
|
||||||
|
target_issue_ids = match[1].scan(/\d+/)
|
||||||
|
target_issues = repository.project.issues.find_all_by_id(target_issue_ids)
|
||||||
|
if fix_status && fix_keywords.include?(action.downcase)
|
||||||
|
# update status of issues
|
||||||
|
logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug?
|
||||||
|
target_issues.each do |issue|
|
||||||
|
# don't change the status is the issue is already closed
|
||||||
|
next if issue.status.is_closed?
|
||||||
|
issue.status = fix_status
|
||||||
|
issue.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.issues << target_issues
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -19,5 +19,5 @@ class Comment < ActiveRecord::Base
|
|||||||
belongs_to :commented, :polymorphic => true, :counter_cache => true
|
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 :commented, :author, :comment
|
validates_presence_of :commented, :author, :comments
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class CustomField < ActiveRecord::Base
|
class CustomField < ActiveRecord::Base
|
||||||
has_many :custom_values, :dependent => :delete_all
|
has_many :custom_values, :dependent => :delete_all
|
||||||
|
serialize :possible_values
|
||||||
|
|
||||||
FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 },
|
FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 },
|
||||||
"text" => { :name => :label_text, :order => 2 },
|
"text" => { :name => :label_text, :order => 2 },
|
||||||
@@ -30,7 +31,23 @@ class CustomField < ActiveRecord::Base
|
|||||||
validates_uniqueness_of :name
|
validates_uniqueness_of :name
|
||||||
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||||
validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys
|
validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys
|
||||||
validates_presence_of :possible_values, :if => Proc.new { |field| field.field_format == "list" }
|
|
||||||
|
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
|
# to move in project_custom_field
|
||||||
def self.for_all
|
def self.for_all
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class CustomValue < ActiveRecord::Base
|
|||||||
protected
|
protected
|
||||||
def validate
|
def validate
|
||||||
errors.add(:value, :activerecord_error_blank) and return if custom_field.is_required? and value.empty?
|
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_invalid) unless custom_field.regexp.blank? 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_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
|
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
|
case custom_field.field_format
|
||||||
@@ -31,7 +31,7 @@ protected
|
|||||||
when "date"
|
when "date"
|
||||||
errors.add(:value, :activerecord_error_not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/ or value.empty?
|
errors.add(:value, :activerecord_error_not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/ or value.empty?
|
||||||
when "list"
|
when "list"
|
||||||
errors.add(:value, :activerecord_error_inclusion) unless custom_field.possible_values.split('|').include? value or value.empty?
|
errors.add(:value, :activerecord_error_inclusion) unless custom_field.possible_values.include? value or value.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ class Enumeration < ActiveRecord::Base
|
|||||||
|
|
||||||
OPTIONS = {
|
OPTIONS = {
|
||||||
"IPRI" => :enumeration_issue_priorities,
|
"IPRI" => :enumeration_issue_priorities,
|
||||||
"DCAT" => :enumeration_doc_categories
|
"DCAT" => :enumeration_doc_categories,
|
||||||
|
"ACTI" => :enumeration_activities
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
def self.get_values(option)
|
def self.get_values(option)
|
||||||
@@ -42,6 +43,8 @@ private
|
|||||||
raise "Can't delete enumeration" if Issue.find(:first, :conditions => ["priority_id=?", self.id])
|
raise "Can't delete enumeration" if Issue.find(:first, :conditions => ["priority_id=?", self.id])
|
||||||
when "DCAT"
|
when "DCAT"
|
||||||
raise "Can't delete enumeration" if Document.find(:first, :conditions => ["category_id=?", self.id])
|
raise "Can't delete enumeration" if Document.find(:first, :conditions => ["category_id=?", self.id])
|
||||||
|
when "ACTI"
|
||||||
|
raise "Can't delete enumeration" if TimeEntry.find(:first, :conditions => ["activity_id=?", self.id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+45
-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,7 +16,6 @@
|
|||||||
# 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 Issue < ActiveRecord::Base
|
class Issue < ActiveRecord::Base
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :tracker
|
belongs_to :tracker
|
||||||
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
|
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
|
||||||
@@ -28,9 +27,15 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
has_many :journals, :as => :journalized, :dependent => :destroy
|
has_many :journals, :as => :journalized, :dependent => :destroy
|
||||||
has_many :attachments, :as => :container, :dependent => :destroy
|
has_many :attachments, :as => :container, :dependent => :destroy
|
||||||
|
has_many :time_entries, :dependent => :nullify
|
||||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||||
has_many :custom_fields, :through => :custom_values
|
has_many :custom_fields, :through => :custom_values
|
||||||
|
has_and_belongs_to_many :changesets, :order => "revision ASC"
|
||||||
|
|
||||||
|
has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
|
||||||
|
has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
|
||||||
|
|
||||||
|
acts_as_watchable
|
||||||
|
|
||||||
validates_presence_of :subject, :description, :priority, :tracker, :author, :status
|
validates_presence_of :subject, :description, :priority, :tracker, :author, :status
|
||||||
validates_inclusion_of :done_ratio, :in => 0..100
|
validates_inclusion_of :done_ratio, :in => 0..100
|
||||||
@@ -38,7 +43,7 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
# set default status for new issues
|
# set default status for new issues
|
||||||
def before_validation
|
def before_validation
|
||||||
self.status = IssueStatus.default if new_record?
|
self.status = IssueStatus.default if status.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
@@ -49,11 +54,18 @@ class Issue < ActiveRecord::Base
|
|||||||
if self.due_date and self.start_date and self.due_date < self.start_date
|
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
|
errors.add :due_date, :activerecord_error_greater_than_start_date
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if start_date && soonest_start && start_date < soonest_start
|
||||||
|
errors.add :start_date, :activerecord_error_invalid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#def before_create
|
def before_create
|
||||||
# build_history
|
# default assignment based on category
|
||||||
#end
|
if assigned_to.nil? && category && category.assigned_to
|
||||||
|
self.assigned_to = category.assigned_to
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def before_save
|
def before_save
|
||||||
if @current_journal
|
if @current_journal
|
||||||
@@ -75,8 +87,8 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def long_id
|
def after_save
|
||||||
"%05d" % self.id
|
relations_from.each(&:set_issue_to_dates)
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_value_for(custom_field)
|
def custom_value_for(custom_field)
|
||||||
@@ -92,11 +104,28 @@ class Issue < ActiveRecord::Base
|
|||||||
@current_journal
|
@current_journal
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
def spent_hours
|
||||||
# Creates an history for the issue
|
@spent_hours ||= time_entries.sum(:hours) || 0
|
||||||
#def build_history
|
end
|
||||||
# @history = self.histories.build
|
|
||||||
# @history.status = self.status
|
def relations
|
||||||
# @history.author = self.author
|
(relations_from + relations_to).sort
|
||||||
#end
|
end
|
||||||
|
|
||||||
|
def all_dependent_issues
|
||||||
|
dependencies = []
|
||||||
|
relations_from.each do |relation|
|
||||||
|
dependencies << relation.issue_to
|
||||||
|
dependencies += relation.issue_to.all_dependent_issues
|
||||||
|
end
|
||||||
|
dependencies
|
||||||
|
end
|
||||||
|
|
||||||
|
def duration
|
||||||
|
(start_date && due_date) ? due_date - start_date : 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def soonest_start
|
||||||
|
@soonest_start ||= relations_to.collect{|relation| relation.successor_soonest_start}.compact.min
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
class IssueCategory < ActiveRecord::Base
|
class IssueCategory < ActiveRecord::Base
|
||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id'
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name, :scope => [:project_id]
|
validates_uniqueness_of :name, :scope => [:project_id]
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
# 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 IssueCustomField < CustomField
|
class IssueCustomField < CustomField
|
||||||
has_and_belongs_to_many :projects, :join_table => "custom_fields_projects", :foreign_key => "custom_field_id"
|
has_and_belongs_to_many :projects, :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :foreign_key => "custom_field_id"
|
||||||
has_and_belongs_to_many :trackers, :join_table => "custom_fields_trackers", :foreign_key => "custom_field_id"
|
has_and_belongs_to_many :trackers, :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :foreign_key => "custom_field_id"
|
||||||
has_many :issues, :through => :issue_custom_values
|
has_many :issues, :through => :issue_custom_values
|
||||||
|
|
||||||
def type_name
|
def type_name
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
# 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 IssueRelation < ActiveRecord::Base
|
||||||
|
belongs_to :issue_from, :class_name => 'Issue', :foreign_key => 'issue_from_id'
|
||||||
|
belongs_to :issue_to, :class_name => 'Issue', :foreign_key => 'issue_to_id'
|
||||||
|
|
||||||
|
TYPE_RELATES = "relates"
|
||||||
|
TYPE_DUPLICATES = "duplicates"
|
||||||
|
TYPE_BLOCKS = "blocks"
|
||||||
|
TYPE_PRECEDES = "precedes"
|
||||||
|
|
||||||
|
TYPES = { TYPE_RELATES => { :name => :label_relates_to, :sym_name => :label_relates_to, :order => 1 },
|
||||||
|
TYPE_DUPLICATES => { :name => :label_duplicates, :sym_name => :label_duplicates, :order => 2 },
|
||||||
|
TYPE_BLOCKS => { :name => :label_blocks, :sym_name => :label_blocked_by, :order => 3 },
|
||||||
|
TYPE_PRECEDES => { :name => :label_precedes, :sym_name => :label_follows, :order => 4 },
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
validates_presence_of :issue_from, :issue_to, :relation_type
|
||||||
|
validates_inclusion_of :relation_type, :in => TYPES.keys
|
||||||
|
validates_numericality_of :delay, :allow_nil => true
|
||||||
|
validates_uniqueness_of :issue_to_id, :scope => :issue_from_id
|
||||||
|
|
||||||
|
def validate
|
||||||
|
if issue_from && issue_to
|
||||||
|
errors.add :issue_to_id, :activerecord_error_invalid if issue_from_id == issue_to_id
|
||||||
|
errors.add :issue_to_id, :activerecord_error_not_same_project unless issue_from.project_id == issue_to.project_id
|
||||||
|
errors.add_to_base :activerecord_error_circular_dependency if issue_to.all_dependent_issues.include? issue_from
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def other_issue(issue)
|
||||||
|
(self.issue_from_id == issue.id) ? issue_to : issue_from
|
||||||
|
end
|
||||||
|
|
||||||
|
def label_for(issue)
|
||||||
|
TYPES[relation_type] ? TYPES[relation_type][(self.issue_from_id == issue.id) ? :name : :sym_name] : :unknow
|
||||||
|
end
|
||||||
|
|
||||||
|
def before_save
|
||||||
|
if TYPE_PRECEDES == relation_type
|
||||||
|
self.delay ||= 0
|
||||||
|
else
|
||||||
|
self.delay = nil
|
||||||
|
end
|
||||||
|
set_issue_to_dates
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_issue_to_dates
|
||||||
|
soonest_start = self.successor_soonest_start
|
||||||
|
if soonest_start && (!issue_to.start_date || issue_to.start_date < soonest_start)
|
||||||
|
issue_to.start_date, issue_to.due_date = successor_soonest_start, successor_soonest_start + issue_to.duration
|
||||||
|
issue_to.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def successor_soonest_start
|
||||||
|
return nil unless (TYPE_PRECEDES == self.relation_type) && (issue_from.start_date || issue_from.due_date)
|
||||||
|
(issue_from.due_date || issue_from.start_date) + 1 + delay
|
||||||
|
end
|
||||||
|
|
||||||
|
def <=>(relation)
|
||||||
|
TYPES[self.relation_type][:order] <=> TYPES[relation.relation_type][:order]
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
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", :dependent => :delete_all
|
||||||
|
acts_as_list
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name
|
validates_uniqueness_of :name
|
||||||
@@ -26,7 +27,7 @@ class IssueStatus < ActiveRecord::Base
|
|||||||
validates_format_of :html_color, :with => /^[a-f0-9]*$/i
|
validates_format_of :html_color, :with => /^[a-f0-9]*$/i
|
||||||
|
|
||||||
def before_save
|
def before_save
|
||||||
IssueStatus.update_all "is_default=false" if self.is_default?
|
IssueStatus.update_all "is_default=#{connection.quoted_false}" if self.is_default?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the default status for new issues
|
# Returns the default status for new issues
|
||||||
@@ -35,16 +36,23 @@ class IssueStatus < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of all statuses the given role can switch to
|
# Returns an array of all statuses the given role can switch to
|
||||||
|
# Uses association cache when called more than one time
|
||||||
def new_statuses_allowed_to(role, tracker)
|
def new_statuses_allowed_to(role, tracker)
|
||||||
statuses = []
|
new_statuses = workflows.select {|w| w.role_id == role.id && w.tracker_id == tracker.id}.collect{|w| w.new_status} if role && tracker
|
||||||
for workflow in self.workflows
|
new_statuses ? new_statuses.compact.sort{|x, y| x.position <=> y.position } : []
|
||||||
statuses << workflow.new_status if workflow.role_id == role.id and workflow.tracker_id == tracker.id
|
end
|
||||||
end unless role.nil? or tracker.nil?
|
|
||||||
statuses
|
# Same thing as above but uses a database query
|
||||||
|
# More efficient than the previous method if called just once
|
||||||
|
def find_new_statuses_allowed_to(role, tracker)
|
||||||
|
new_statuses = workflows.find(:all,
|
||||||
|
:include => :new_status,
|
||||||
|
:conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status }.compact if role && tracker
|
||||||
|
new_statuses ? new_statuses.sort{|x, y| x.position <=> y.position } : []
|
||||||
end
|
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
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
class Journal < ActiveRecord::Base
|
class Journal < ActiveRecord::Base
|
||||||
belongs_to :journalized, :polymorphic => true
|
belongs_to :journalized, :polymorphic => true
|
||||||
|
# added as a quick fix to allow eager loading of the polymorphic association
|
||||||
|
# since always associated to an issue, for now
|
||||||
|
belongs_to :issue, :foreign_key => :journalized_id
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
|
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,4 +17,9 @@
|
|||||||
|
|
||||||
class JournalDetail < ActiveRecord::Base
|
class JournalDetail < ActiveRecord::Base
|
||||||
belongs_to :journal
|
belongs_to :journal
|
||||||
|
|
||||||
|
def before_save
|
||||||
|
self.value = value[0..254] if value && value.is_a?(String)
|
||||||
|
self.old_value = old_value[0..254] if old_value && old_value.is_a?(String)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# 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 MailHandler < ActionMailer::Base
|
||||||
|
|
||||||
|
# Processes incoming emails
|
||||||
|
# Currently, it only supports adding a note to an existing issue
|
||||||
|
# by replying to the initial notification message
|
||||||
|
def receive(email)
|
||||||
|
# find related issue by parsing the subject
|
||||||
|
m = email.subject.match %r{\[.*#(\d+)\]}
|
||||||
|
return unless m
|
||||||
|
issue = Issue.find_by_id(m[1])
|
||||||
|
return unless issue
|
||||||
|
|
||||||
|
# find user
|
||||||
|
user = User.find_active(:first, :conditions => {:mail => email.from.first})
|
||||||
|
return unless user
|
||||||
|
# check permission
|
||||||
|
return unless Permission.allowed_to_role("issues/add_note", user.role_for_project(issue.project))
|
||||||
|
|
||||||
|
# add the note
|
||||||
|
issue.init_journal(user, email.body.chomp)
|
||||||
|
issue.save
|
||||||
|
end
|
||||||
|
end
|
||||||
+70
-7
@@ -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,38 +16,101 @@
|
|||||||
# 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 Mailer < ActionMailer::Base
|
||||||
|
|
||||||
helper IssuesHelper
|
helper IssuesHelper
|
||||||
|
|
||||||
|
def account_information(user, password)
|
||||||
|
set_language_if_valid user.language
|
||||||
|
recipients user.mail
|
||||||
|
from Setting.mail_from
|
||||||
|
subject l(:mail_subject_register)
|
||||||
|
body :user => user, :password => password
|
||||||
|
end
|
||||||
|
|
||||||
def issue_add(issue)
|
def issue_add(issue)
|
||||||
|
set_language_if_valid(Setting.default_language)
|
||||||
# Sends to all project members
|
# Sends to all project members
|
||||||
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
|
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
|
||||||
@from = $RDM_MAIL_FROM
|
# Sends to author and assignee (even if they turned off mail notification)
|
||||||
|
@recipients << issue.author.mail if issue.author
|
||||||
|
@recipients << issue.assigned_to.mail if issue.assigned_to
|
||||||
|
@recipients.compact!
|
||||||
|
@recipients.uniq!
|
||||||
|
@from = Setting.mail_from
|
||||||
@subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
|
@subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
|
||||||
@body['issue'] = issue
|
@body['issue'] = issue
|
||||||
end
|
end
|
||||||
|
|
||||||
def issue_edit(journal)
|
def issue_edit(journal)
|
||||||
|
set_language_if_valid(Setting.default_language)
|
||||||
# Sends to all project members
|
# Sends to all project members
|
||||||
issue = journal.journalized
|
issue = journal.journalized
|
||||||
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
|
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
|
||||||
@from = $RDM_MAIL_FROM
|
# Sends to author and assignee (even if they turned off mail notification)
|
||||||
|
@recipients << issue.author.mail if issue.author
|
||||||
|
@recipients << issue.assigned_to.mail if issue.assigned_to
|
||||||
|
@recipients.compact!
|
||||||
|
@recipients.uniq!
|
||||||
|
# Watchers in cc
|
||||||
|
@cc = issue.watcher_recipients - @recipients
|
||||||
|
@from = Setting.mail_from
|
||||||
@subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
|
@subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
|
||||||
@body['issue'] = issue
|
@body['issue'] = issue
|
||||||
@body['journal']= journal
|
@body['journal']= journal
|
||||||
end
|
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)
|
def lost_password(token)
|
||||||
|
set_language_if_valid(token.user.language)
|
||||||
@recipients = token.user.mail
|
@recipients = token.user.mail
|
||||||
@from = $RDM_MAIL_FROM
|
@from = Setting.mail_from
|
||||||
@subject = l(:mail_subject_lost_password)
|
@subject = l(:mail_subject_lost_password)
|
||||||
@body['token'] = token
|
@body['token'] = token
|
||||||
end
|
end
|
||||||
|
|
||||||
def register(token)
|
def register(token)
|
||||||
|
set_language_if_valid(token.user.language)
|
||||||
@recipients = token.user.mail
|
@recipients = token.user.mail
|
||||||
@from = $RDM_MAIL_FROM
|
@from = Setting.mail_from
|
||||||
@subject = l(:mail_subject_register)
|
@subject = l(:mail_subject_register)
|
||||||
@body['token'] = token
|
@body['token'] = token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def message_posted(message, recipients)
|
||||||
|
set_language_if_valid(Setting.default_language)
|
||||||
|
@recipients = recipients
|
||||||
|
@from = Setting.mail_from
|
||||||
|
@subject = "[#{message.board.project.name} - #{message.board.name}] #{message.subject}"
|
||||||
|
@body['message'] = message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ class Member < ActiveRecord::Base
|
|||||||
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.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def before_destroy
|
||||||
|
# remove category based auto assignments for this member
|
||||||
|
project.issue_categories.update_all "assigned_to_id = NULL", ["assigned_to_id = ?", self.user.id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# 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 Message < ActiveRecord::Base
|
||||||
|
belongs_to :board
|
||||||
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
|
acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC"
|
||||||
|
has_many :attachments, :as => :container, :dependent => :destroy
|
||||||
|
belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id'
|
||||||
|
|
||||||
|
validates_presence_of :subject, :content
|
||||||
|
validates_length_of :subject, :maximum => 255
|
||||||
|
|
||||||
|
def after_create
|
||||||
|
board.update_attribute(:last_message_id, self.id)
|
||||||
|
board.increment! :messages_count
|
||||||
|
if parent
|
||||||
|
parent.reload.update_attribute(:last_reply_id, self.id)
|
||||||
|
else
|
||||||
|
board.increment! :topics_count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def project
|
||||||
|
board.project
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# 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 MessageObserver < ActiveRecord::Observer
|
||||||
|
def after_create(message)
|
||||||
|
# send notification to board watchers
|
||||||
|
recipients = message.board.watcher_recipients
|
||||||
|
Mailer.deliver_message_posted(message, recipients) unless recipients.empty?
|
||||||
|
end
|
||||||
|
end
|
||||||
+1
-1
@@ -24,6 +24,6 @@ class News < ActiveRecord::Base
|
|||||||
|
|
||||||
# returns latest news for projects visible by user
|
# returns latest news for projects visible by user
|
||||||
def self.latest(user=nil, count=5)
|
def self.latest(user=nil, count=5)
|
||||||
find(:all, :limit => count, :conditions => Project.visible_by(user), :include => [ :author, :project ], :order => "news.created_on DESC")
|
find(:all, :limit => count, :conditions => Project.visible_by(user), :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,7 +30,10 @@ class Permission < ActiveRecord::Base
|
|||||||
1100 => :label_news_plural,
|
1100 => :label_news_plural,
|
||||||
1200 => :label_document_plural,
|
1200 => :label_document_plural,
|
||||||
1300 => :label_attachment_plural,
|
1300 => :label_attachment_plural,
|
||||||
1400 => :label_repository
|
1400 => :label_repository,
|
||||||
|
1500 => :label_time_tracking,
|
||||||
|
1700 => :label_wiki_page_plural,
|
||||||
|
2000 => :label_board_plural
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
@@cached_perms_for_public = nil
|
@@cached_perms_for_public = nil
|
||||||
@@ -56,7 +59,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
|
||||||
allowed_to_public(action) or (@@cached_perms_for_roles[action] and @@cached_perms_for_roles[action].include? role)
|
allowed_to_public(action) or (role && @@cached_perms_for_roles[action] && @@cached_perms_for_roles[action].include?(role.id))
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.allowed_to_role_expired
|
def self.allowed_to_role_expired
|
||||||
|
|||||||
+71
-18
@@ -16,55 +16,108 @@
|
|||||||
# 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 Project < ActiveRecord::Base
|
class Project < ActiveRecord::Base
|
||||||
has_many :versions, :dependent => :destroy, :order => "versions.effective_date DESC, versions.name DESC"
|
# Project statuses
|
||||||
has_many :members, :dependent => :delete_all, :include => :user, :conditions => "users.status=#{User::STATUS_ACTIVE}"
|
STATUS_ACTIVE = 1
|
||||||
|
STATUS_ARCHIVED = 9
|
||||||
|
|
||||||
|
has_many :members, :dependent => :delete_all, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}"
|
||||||
has_many :users, :through => :members
|
has_many :users, :through => :members
|
||||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||||
has_many :issues, :dependent => :destroy, :order => "issues.created_on DESC", :include => [:status, :tracker]
|
has_many :issues, :dependent => :destroy, :order => "#{Issue.table_name}.created_on DESC", :include => [:status, :tracker]
|
||||||
|
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
|
||||||
|
has_many :time_entries, :dependent => :delete_all
|
||||||
has_many :queries, :dependent => :delete_all
|
has_many :queries, :dependent => :delete_all
|
||||||
has_many :documents, :dependent => :destroy
|
has_many :documents, :dependent => :destroy
|
||||||
has_many :news, :dependent => :delete_all, :include => :author
|
has_many :news, :dependent => :delete_all, :include => :author
|
||||||
has_many :issue_categories, :dependent => :delete_all, :order => "issue_categories.name"
|
has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name"
|
||||||
|
has_many :boards, :order => "position ASC"
|
||||||
has_one :repository, :dependent => :destroy
|
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'
|
has_one :wiki, :dependent => :destroy
|
||||||
|
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
|
||||||
acts_as_tree :order => "name", :counter_cache => true
|
acts_as_tree :order => "name", :counter_cache => true
|
||||||
|
|
||||||
validates_presence_of :name, :description
|
attr_protected :status
|
||||||
validates_uniqueness_of :name
|
|
||||||
|
validates_presence_of :name, :description, :identifier
|
||||||
|
validates_uniqueness_of :name, :identifier
|
||||||
validates_associated :custom_values, :on => :update
|
validates_associated :custom_values, :on => :update
|
||||||
validates_associated :repository
|
validates_associated :repository, :wiki
|
||||||
|
validates_length_of :name, :maximum => 30
|
||||||
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||||
|
validates_length_of :description, :maximum => 255
|
||||||
|
validates_length_of :identifier, :in => 3..12
|
||||||
|
validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
|
||||||
|
|
||||||
|
def identifier=(identifier)
|
||||||
|
super unless identifier_frozen?
|
||||||
|
end
|
||||||
|
|
||||||
|
def identifier_frozen?
|
||||||
|
errors[:identifier].nil? && !(new_record? || identifier.blank?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def issues_with_subprojects(include_subprojects=false)
|
||||||
|
conditions = nil
|
||||||
|
if include_subprojects && !active_children.empty?
|
||||||
|
ids = [id] + active_children.collect {|c| c.id}
|
||||||
|
conditions = ["#{Issue.table_name}.project_id IN (#{ids.join(',')})"]
|
||||||
|
end
|
||||||
|
conditions ||= ["#{Issue.table_name}.project_id = ?", id]
|
||||||
|
Issue.with_scope :find => { :conditions => conditions } do
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# returns latest created projects
|
# returns latest created projects
|
||||||
# non public projects will be returned only if user is a member of those
|
# non public projects will be returned only if user is a member of those
|
||||||
def self.latest(user=nil, count=5)
|
def self.latest(user=nil, count=5)
|
||||||
find(:all, :limit => count, :conditions => visible_by(user), :order => "projects.created_on DESC")
|
find(:all, :limit => count, :conditions => visible_by(user), :order => "created_on DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.visible_by(user=nil)
|
def self.visible_by(user=nil)
|
||||||
if user && !user.memberships.empty?
|
if user && user.admin?
|
||||||
return ["projects.is_public = ? or projects.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')})", true]
|
return ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
|
||||||
|
elsif user && user.memberships.any?
|
||||||
|
return ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND (#{Project.table_name}.is_public = ? or #{Project.table_name}.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')}))", true]
|
||||||
else
|
else
|
||||||
return ["projects.is_public = ?", true]
|
return ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND #{Project.table_name}.is_public = ?", true]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def active?
|
||||||
|
self.status == STATUS_ACTIVE
|
||||||
|
end
|
||||||
|
|
||||||
|
def archive
|
||||||
|
# Archive subprojects if any
|
||||||
|
children.each do |subproject|
|
||||||
|
subproject.archive
|
||||||
|
end
|
||||||
|
update_attribute :status, STATUS_ARCHIVED
|
||||||
|
end
|
||||||
|
|
||||||
|
def unarchive
|
||||||
|
return false if parent && !parent.active?
|
||||||
|
update_attribute :status, STATUS_ACTIVE
|
||||||
|
end
|
||||||
|
|
||||||
|
def active_children
|
||||||
|
children.select {|child| child.active?}
|
||||||
|
end
|
||||||
|
|
||||||
# Returns an array of all custom fields enabled for project issues
|
# Returns an array of all custom fields enabled for project issues
|
||||||
# (explictly associated custom fields and custom fields enabled for all projects)
|
# (explictly associated custom fields and custom fields enabled for all projects)
|
||||||
def custom_fields_for_issues(tracker)
|
def custom_fields_for_issues(tracker)
|
||||||
tracker.custom_fields.find(:all, :include => :projects,
|
all_custom_fields.select {|c| tracker.custom_fields.include? c }
|
||||||
:conditions => ["is_for_all=? or project_id=?", true, self.id])
|
|
||||||
#(CustomField.for_all + custom_fields).uniq
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_custom_fields
|
def all_custom_fields
|
||||||
@all_custom_fields ||= IssueCustomField.find(:all, :include => :projects,
|
@all_custom_fields ||= (IssueCustomField.for_all + custom_fields).uniq
|
||||||
:conditions => ["is_for_all=? or project_id=?", true, self.id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def validate
|
def validate
|
||||||
errors.add(parent_id, " must be a root project") if parent and parent.parent
|
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 projects_count > 0
|
errors.add_to_base("A project with subprojects can't be a subproject") if parent and children.size > 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+102
-29
@@ -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,6 +21,7 @@ class Query < ActiveRecord::Base
|
|||||||
serialize :filters
|
serialize :filters
|
||||||
|
|
||||||
attr_protected :project, :user
|
attr_protected :project, :user
|
||||||
|
attr_accessor :executed_by
|
||||||
|
|
||||||
validates_presence_of :name, :on => :save
|
validates_presence_of :name, :on => :save
|
||||||
|
|
||||||
@@ -45,8 +46,10 @@ class Query < ActiveRecord::Base
|
|||||||
@@operators_by_filter_type = { :list => [ "=", "!" ],
|
@@operators_by_filter_type = { :list => [ "=", "!" ],
|
||||||
:list_status => [ "o", "=", "!", "c", "*" ],
|
:list_status => [ "o", "=", "!", "c", "*" ],
|
||||||
:list_optional => [ "=", "!", "!*", "*" ],
|
:list_optional => [ "=", "!", "!*", "*" ],
|
||||||
|
:list_one_or_more => [ "*", "=" ],
|
||||||
:date => [ "<t+", ">t+", "t+", "t", ">t-", "<t-", "t-" ],
|
:date => [ "<t+", ">t+", "t+", "t", ">t-", "<t-", "t-" ],
|
||||||
:date_past => [ ">t-", "<t-", "t-", "t" ],
|
:date_past => [ ">t-", "<t-", "t-", "t" ],
|
||||||
|
:string => [ "=", "~", "!", "!~" ],
|
||||||
:text => [ "~", "!~" ] }
|
:text => [ "~", "!~" ] }
|
||||||
|
|
||||||
cattr_reader :operators_by_filter_type
|
cattr_reader :operators_by_filter_type
|
||||||
@@ -54,12 +57,16 @@ class Query < ActiveRecord::Base
|
|||||||
def initialize(attributes = nil)
|
def initialize(attributes = nil)
|
||||||
super attributes
|
super attributes
|
||||||
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
|
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
|
||||||
self.is_public = true
|
end
|
||||||
|
|
||||||
|
def executed_by=(user)
|
||||||
|
@executed_by = user
|
||||||
|
set_language_if_valid(user.language) if user
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
filters.each_key do |field|
|
filters.each_key do |field|
|
||||||
errors.add field.gsub(/\_id$/, ""), :activerecord_error_blank unless
|
errors.add label_for(field), :activerecord_error_blank unless
|
||||||
# filter requires one or more values
|
# filter requires one or more values
|
||||||
(values_for(field) and !values_for(field).first.empty?) or
|
(values_for(field) and !values_for(field).first.empty?) or
|
||||||
# filter doesn't require any value
|
# filter doesn't require any value
|
||||||
@@ -67,21 +74,50 @@ class Query < ActiveRecord::Base
|
|||||||
end if filters
|
end if filters
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def editable_by?(user)
|
||||||
|
return false unless user
|
||||||
|
return true if !is_public && self.user_id == user.id
|
||||||
|
is_public && user.authorized_to(project, "projects/add_query")
|
||||||
|
end
|
||||||
|
|
||||||
def available_filters
|
def available_filters
|
||||||
return @available_filters if @available_filters
|
return @available_filters if @available_filters
|
||||||
@available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all).collect{|s| [s.name, s.id.to_s] } },
|
@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).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] } },
|
"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 => 7 },
|
"subject" => { :type => :text, :order => 8 },
|
||||||
"created_on" => { :type => :date_past, :order => 8 },
|
"created_on" => { :type => :date_past, :order => 9 },
|
||||||
"updated_on" => { :type => :date_past, :order => 9 },
|
"updated_on" => { :type => :date_past, :order => 10 },
|
||||||
"start_date" => { :type => :date, :order => 10 },
|
"start_date" => { :type => :date, :order => 11 },
|
||||||
"due_date" => { :type => :date, :order => 11 } }
|
"due_date" => { :type => :date, :order => 12 } }
|
||||||
unless project.nil?
|
unless project.nil?
|
||||||
# project specific filters
|
# project specific filters
|
||||||
@available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => @project.users.collect{|s| [s.name, s.id.to_s] } }
|
user_values = []
|
||||||
@available_filters["author_id"] = { :type => :list, :order => 5, :values => @project.users.collect{|s| [s.name, s.id.to_s] } }
|
user_values << ["<< #{l(:label_me)} >>", "me"] if executed_by
|
||||||
|
user_values += @project.users.collect{|s| [s.name, s.id.to_s] }
|
||||||
|
|
||||||
|
@available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values }
|
||||||
|
@available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values }
|
||||||
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.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.sort.collect{|s| [s.name, s.id.to_s] } }
|
||||||
|
unless @project.active_children.empty?
|
||||||
|
@available_filters["subproject_id"] = { :type => :list_one_or_more, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
|
||||||
|
end
|
||||||
|
@project.all_custom_fields.select(&:is_filter?).each do |field|
|
||||||
|
case field.field_format
|
||||||
|
when "string", "int"
|
||||||
|
options = { :type => :string, :order => 20 }
|
||||||
|
when "text"
|
||||||
|
options = { :type => :text, :order => 20 }
|
||||||
|
when "list"
|
||||||
|
options = { :type => :list_optional, :values => field.possible_values, :order => 20}
|
||||||
|
when "date"
|
||||||
|
options = { :type => :date, :order => 20 }
|
||||||
|
when "bool"
|
||||||
|
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
|
||||||
|
end
|
||||||
|
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
|
||||||
|
end
|
||||||
# remove category filter if no category defined
|
# remove category filter if no category defined
|
||||||
@available_filters.delete "category_id" if @available_filters["category_id"][:values].empty?
|
@available_filters.delete "category_id" if @available_filters["category_id"][:values].empty?
|
||||||
end
|
end
|
||||||
@@ -121,45 +157,82 @@ class Query < ActiveRecord::Base
|
|||||||
has_filter?(field) ? filters[field][:values] : nil
|
has_filter?(field) ? filters[field][:values] : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def label_for(field)
|
||||||
|
label = @available_filters[field][:name] if @available_filters.has_key?(field)
|
||||||
|
label ||= field.gsub(/\_id$/, "")
|
||||||
|
end
|
||||||
|
|
||||||
def statement
|
def statement
|
||||||
sql = "1=1"
|
sql = "1=1"
|
||||||
sql << " AND issues.project_id=%d" % project.id if project
|
if has_filter?("subproject_id")
|
||||||
|
subproject_ids = []
|
||||||
|
if operator_for("subproject_id") == "="
|
||||||
|
subproject_ids = values_for("subproject_id").each(&:to_i)
|
||||||
|
else
|
||||||
|
subproject_ids = project.active_children.collect{|p| p.id}
|
||||||
|
end
|
||||||
|
sql << " AND #{Issue.table_name}.project_id IN (%d,%s)" % [project.id, subproject_ids.join(",")] if project
|
||||||
|
else
|
||||||
|
sql << " AND #{Issue.table_name}.project_id=%d" % project.id if project
|
||||||
|
end
|
||||||
filters.each_key do |field|
|
filters.each_key do |field|
|
||||||
v = values_for field
|
next if field == "subproject_id"
|
||||||
|
v = values_for(field).clone
|
||||||
next unless v and !v.empty?
|
next unless v and !v.empty?
|
||||||
|
|
||||||
sql = sql + " AND " unless sql.empty?
|
sql = sql + " AND " unless sql.empty?
|
||||||
|
sql << "("
|
||||||
|
|
||||||
|
if field =~ /^cf_(\d+)$/
|
||||||
|
# custom field
|
||||||
|
db_table = CustomValue.table_name
|
||||||
|
db_field = "value"
|
||||||
|
sql << "#{db_table}.custom_field_id = #{$1} AND "
|
||||||
|
else
|
||||||
|
# regular field
|
||||||
|
db_table = Issue.table_name
|
||||||
|
db_field = field
|
||||||
|
end
|
||||||
|
|
||||||
|
# "me" value subsitution
|
||||||
|
if %w(assigned_to_id author_id).include?(field)
|
||||||
|
v.push(executed_by ? executed_by.id.to_s : "0") if v.delete("me")
|
||||||
|
end
|
||||||
|
|
||||||
case operator_for field
|
case operator_for field
|
||||||
when "="
|
when "="
|
||||||
sql = sql + "issues.#{field} IN (" + v.each(&:to_i).join(",") + ")"
|
sql = sql + "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
|
||||||
when "!"
|
when "!"
|
||||||
sql = sql + "issues.#{field} NOT IN (" + v.each(&:to_i).join(",") + ")"
|
sql = sql + "#{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
|
||||||
when "!*"
|
when "!*"
|
||||||
sql = sql + "issues.#{field} IS NULL"
|
sql = sql + "#{db_table}.#{db_field} IS NULL"
|
||||||
when "*"
|
when "*"
|
||||||
sql = sql + "issues.#{field} IS NOT NULL"
|
sql = sql + "#{db_table}.#{db_field} IS NOT NULL"
|
||||||
when "o"
|
when "o"
|
||||||
sql = sql + "issue_statuses.is_closed=#{connection.quoted_false}" if field == "status_id"
|
sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id"
|
||||||
when "c"
|
when "c"
|
||||||
sql = sql + "issue_statuses.is_closed=#{connection.quoted_true}" if field == "status_id"
|
sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id"
|
||||||
when ">t-"
|
when ">t-"
|
||||||
sql = sql + "issues.#{field} >= '%s'" % connection.quoted_date(Date.today - v.first.to_i)
|
sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today + 1).to_time)]
|
||||||
when "<t-"
|
when "<t-"
|
||||||
sql = sql + "issues.#{field} <= '" + (Date.today - v.first.to_i).strftime("%Y-%m-%d") + "'"
|
sql = sql + "#{db_table}.#{db_field} <= '%s'" % connection.quoted_date((Date.today - v.first.to_i).to_time)
|
||||||
when "t-"
|
when "t-"
|
||||||
sql = sql + "issues.#{field} = '" + (Date.today - v.first.to_i).strftime("%Y-%m-%d") + "'"
|
sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today - v.first.to_i + 1).to_time)]
|
||||||
when ">t+"
|
when ">t+"
|
||||||
sql = sql + "issues.#{field} >= '" + (Date.today + v.first.to_i).strftime("%Y-%m-%d") + "'"
|
sql = sql + "#{db_table}.#{db_field} >= '%s'" % connection.quoted_date((Date.today + v.first.to_i).to_time)
|
||||||
when "<t+"
|
when "<t+"
|
||||||
sql = sql + "issues.#{field} <= '" + (Date.today + v.first.to_i).strftime("%Y-%m-%d") + "'"
|
sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)]
|
||||||
when "t+"
|
when "t+"
|
||||||
sql = sql + "issues.#{field} = '" + (Date.today + v.first.to_i).strftime("%Y-%m-%d") + "'"
|
sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today + v.first.to_i).to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)]
|
||||||
when "t"
|
when "t"
|
||||||
sql = sql + "issues.#{field} = '%s'" % connection.quoted_date(Date.today)
|
sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today+1).to_time)]
|
||||||
when "~"
|
when "~"
|
||||||
sql = sql + "issues.#{field} LIKE '%#{connection.quote_string(v.first)}%'"
|
sql = sql + "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'"
|
||||||
when "!~"
|
when "!~"
|
||||||
sql = sql + "issues.#{field} NOT LIKE '%#{connection.quote_string(v.first)}%'"
|
sql = sql + "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(v.first)}%'"
|
||||||
end
|
end
|
||||||
|
sql << ")"
|
||||||
|
|
||||||
end if filters and valid?
|
end if filters and valid?
|
||||||
sql
|
sql
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -17,12 +17,63 @@
|
|||||||
|
|
||||||
class Repository < ActiveRecord::Base
|
class Repository < ActiveRecord::Base
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
validates_presence_of :url
|
has_many :changesets, :dependent => :destroy, :order => "#{Changeset.table_name}.revision DESC"
|
||||||
validates_format_of :url, :with => /^(http|https|svn|file):\/\/.+/i
|
has_many :changes, :through => :changesets
|
||||||
|
|
||||||
@scm = nil
|
|
||||||
|
|
||||||
def scm
|
def scm
|
||||||
@scm ||= SvnRepos::Base.new url
|
@scm ||= self.scm_adapter.new url, root_url, login, password
|
||||||
|
update_attribute(:root_url, @scm.root_url) if root_url.blank?
|
||||||
|
@scm
|
||||||
|
end
|
||||||
|
|
||||||
|
def scm_name
|
||||||
|
self.class.scm_name
|
||||||
|
end
|
||||||
|
|
||||||
|
def supports_cat?
|
||||||
|
scm.supports_cat?
|
||||||
|
end
|
||||||
|
|
||||||
|
def entries(path=nil, identifier=nil)
|
||||||
|
scm.entries(path, identifier)
|
||||||
|
end
|
||||||
|
|
||||||
|
def diff(path, rev, rev_to, type)
|
||||||
|
scm.diff(path, rev, rev_to, type)
|
||||||
|
end
|
||||||
|
|
||||||
|
def latest_changeset
|
||||||
|
@latest_changeset ||= changesets.find(:first)
|
||||||
|
end
|
||||||
|
|
||||||
|
def scan_changesets_for_issue_ids
|
||||||
|
self.changesets.each(&:scan_comment_for_issue_ids)
|
||||||
|
end
|
||||||
|
|
||||||
|
# fetch new changesets for all repositories
|
||||||
|
# can be called periodically by an external script
|
||||||
|
# eg. ruby script/runner "Repository.fetch_changesets"
|
||||||
|
def self.fetch_changesets
|
||||||
|
find(:all).each(&:fetch_changesets)
|
||||||
|
end
|
||||||
|
|
||||||
|
# scan changeset comments to find related and fixed issues for all repositories
|
||||||
|
def self.scan_changesets_for_issue_ids
|
||||||
|
find(:all).each(&:scan_changesets_for_issue_ids)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_name
|
||||||
|
'Abstract'
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.available_scm
|
||||||
|
subclasses.collect {|klass| [klass.scm_name, klass.name]}
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.factory(klass_name, *args)
|
||||||
|
klass = "Repository::#{klass_name}".constantize
|
||||||
|
klass.new(*args)
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
# 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 'redmine/scm/adapters/cvs_adapter'
|
||||||
|
require 'digest/sha1'
|
||||||
|
|
||||||
|
class Repository::Cvs < Repository
|
||||||
|
validates_presence_of :url, :root_url
|
||||||
|
|
||||||
|
def scm_adapter
|
||||||
|
Redmine::Scm::Adapters::CvsAdapter
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_name
|
||||||
|
'CVS'
|
||||||
|
end
|
||||||
|
|
||||||
|
def entry(path, identifier)
|
||||||
|
e = entries(path, identifier)
|
||||||
|
e ? e.first : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def entries(path=nil, identifier=nil)
|
||||||
|
entries=scm.entries(path, identifier)
|
||||||
|
if entries
|
||||||
|
entries.each() do |entry|
|
||||||
|
unless entry.lastrev.nil? || entry.lastrev.identifier
|
||||||
|
change=changes.find_by_revision_and_path( entry.lastrev.revision, scm.with_leading_slash(entry.path) )
|
||||||
|
if change
|
||||||
|
entry.lastrev.identifier=change.changeset.revision
|
||||||
|
entry.lastrev.author=change.changeset.committer
|
||||||
|
entry.lastrev.revision=change.revision
|
||||||
|
entry.lastrev.branch=change.branch
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
entries
|
||||||
|
end
|
||||||
|
|
||||||
|
def diff(path, rev, rev_to, type)
|
||||||
|
#convert rev to revision. CVS can't handle changesets here
|
||||||
|
diff=[]
|
||||||
|
changeset_from=changesets.find_by_revision(rev)
|
||||||
|
if rev_to.to_i > 0
|
||||||
|
changeset_to=changesets.find_by_revision(rev_to)
|
||||||
|
end
|
||||||
|
changeset_from.changes.each() do |change_from|
|
||||||
|
|
||||||
|
revision_from=nil
|
||||||
|
revision_to=nil
|
||||||
|
|
||||||
|
revision_from=change_from.revision if path.nil? || (change_from.path.starts_with? scm.with_leading_slash(path))
|
||||||
|
|
||||||
|
if revision_from
|
||||||
|
if changeset_to
|
||||||
|
changeset_to.changes.each() do |change_to|
|
||||||
|
revision_to=change_to.revision if change_to.path==change_from.path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
unless revision_to
|
||||||
|
revision_to=scm.get_previous_revision(revision_from)
|
||||||
|
end
|
||||||
|
diff=diff+scm.diff(change_from.path, revision_from, revision_to, type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return diff
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_changesets
|
||||||
|
#not the preferred way with CVS. maybe we should introduce always a cron-job for this
|
||||||
|
last_commit = changesets.maximum(:committed_on)
|
||||||
|
|
||||||
|
# some nifty bits to introduce a commit-id with cvs
|
||||||
|
# natively cvs doesn't provide any kind of changesets, there is only a revision per file.
|
||||||
|
# we now take a guess using the author, the commitlog and the commit-date.
|
||||||
|
|
||||||
|
# last one is the next step to take. the commit-date is not equal for all
|
||||||
|
# commits in one changeset. cvs update the commit-date when the *,v file was touched. so
|
||||||
|
# we use a small delta here, to merge all changes belonging to _one_ changeset
|
||||||
|
time_delta=10.seconds
|
||||||
|
|
||||||
|
transaction do
|
||||||
|
scm.revisions('', last_commit, nil, :with_paths => true) do |revision|
|
||||||
|
# only add the change to the database, if it doen't exists. the cvs log
|
||||||
|
# is not exclusive at all.
|
||||||
|
unless changes.find_by_path_and_revision(scm.with_leading_slash(revision.paths[0][:path]), revision.paths[0][:revision])
|
||||||
|
revision
|
||||||
|
cs=Changeset.find(:first, :conditions=>{
|
||||||
|
:committed_on=>revision.time-time_delta..revision.time+time_delta,
|
||||||
|
:committer=>revision.author,
|
||||||
|
:comments=>revision.message
|
||||||
|
})
|
||||||
|
|
||||||
|
# create a new changeset....
|
||||||
|
unless cs
|
||||||
|
# we use a negative changeset-number here (just for inserting)
|
||||||
|
# later on, we calculate a continous positive number
|
||||||
|
next_rev = changesets.minimum(:revision)
|
||||||
|
next_rev = 0 if next_rev.nil? or next_rev > 0
|
||||||
|
next_rev = next_rev - 1
|
||||||
|
|
||||||
|
cs=Changeset.create(:repository => self,
|
||||||
|
:revision => next_rev,
|
||||||
|
:committer => revision.author,
|
||||||
|
:committed_on => revision.time,
|
||||||
|
:comments => revision.message)
|
||||||
|
end
|
||||||
|
|
||||||
|
#convert CVS-File-States to internal Action-abbrevations
|
||||||
|
#default action is (M)odified
|
||||||
|
action="M"
|
||||||
|
if revision.paths[0][:action]=="Exp" && revision.paths[0][:revision]=="1.1"
|
||||||
|
action="A" #add-action always at first revision (= 1.1)
|
||||||
|
elsif revision.paths[0][:action]=="dead"
|
||||||
|
action="D" #dead-state is similar to Delete
|
||||||
|
end
|
||||||
|
|
||||||
|
Change.create(:changeset => cs,
|
||||||
|
:action => action,
|
||||||
|
:path => scm.with_leading_slash(revision.paths[0][:path]),
|
||||||
|
:revision => revision.paths[0][:revision],
|
||||||
|
:branch => revision.paths[0][:branch]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
next_rev = [changesets.maximum(:revision) || 0, 0].max
|
||||||
|
changesets.find(:all, :conditions=>["revision < 0"], :order=>"committed_on ASC").each() do |changeset|
|
||||||
|
next_rev = next_rev + 1
|
||||||
|
changeset.revision = next_rev
|
||||||
|
changeset.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
# 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 'redmine/scm/adapters/darcs_adapter'
|
||||||
|
|
||||||
|
class Repository::Darcs < Repository
|
||||||
|
validates_presence_of :url
|
||||||
|
|
||||||
|
def scm_adapter
|
||||||
|
Redmine::Scm::Adapters::DarcsAdapter
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_name
|
||||||
|
'Darcs'
|
||||||
|
end
|
||||||
|
|
||||||
|
def entries(path=nil, identifier=nil)
|
||||||
|
entries=scm.entries(path, identifier)
|
||||||
|
if entries
|
||||||
|
entries.each do |entry|
|
||||||
|
# Search the DB for the entry's last change
|
||||||
|
changeset = changesets.find_by_scmid(entry.lastrev.scmid) if entry.lastrev && !entry.lastrev.scmid.blank?
|
||||||
|
if changeset
|
||||||
|
entry.lastrev.identifier = changeset.revision
|
||||||
|
entry.lastrev.name = changeset.revision
|
||||||
|
entry.lastrev.time = changeset.committed_on
|
||||||
|
entry.lastrev.author = changeset.committer
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
entries
|
||||||
|
end
|
||||||
|
|
||||||
|
def diff(path, rev, rev_to, type)
|
||||||
|
patch_from = changesets.find_by_revision(rev)
|
||||||
|
patch_to = changesets.find_by_revision(rev_to) if rev_to
|
||||||
|
if path.blank?
|
||||||
|
path = patch_from.changes.collect{|change| change.path}.join(' ')
|
||||||
|
end
|
||||||
|
scm.diff(path, patch_from.scmid, patch_to.scmid, type)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_changesets
|
||||||
|
scm_info = scm.info
|
||||||
|
if scm_info
|
||||||
|
db_last_id = latest_changeset ? latest_changeset.scmid : nil
|
||||||
|
next_rev = latest_changeset ? latest_changeset.revision + 1 : 1
|
||||||
|
# latest revision in the repository
|
||||||
|
scm_revision = scm_info.lastrev.scmid
|
||||||
|
unless changesets.find_by_scmid(scm_revision)
|
||||||
|
revisions = scm.revisions('', db_last_id, nil, :with_path => true)
|
||||||
|
transaction do
|
||||||
|
revisions.reverse_each do |revision|
|
||||||
|
changeset = Changeset.create(:repository => self,
|
||||||
|
:revision => next_rev,
|
||||||
|
:scmid => revision.scmid,
|
||||||
|
:committer => revision.author,
|
||||||
|
:committed_on => revision.time,
|
||||||
|
:comments => revision.message)
|
||||||
|
|
||||||
|
next if changeset.new_record?
|
||||||
|
|
||||||
|
revision.paths.each do |change|
|
||||||
|
Change.create(:changeset => changeset,
|
||||||
|
:action => change[:action],
|
||||||
|
:path => change[:path],
|
||||||
|
:from_path => change[:from_path],
|
||||||
|
:from_revision => change[:from_revision])
|
||||||
|
end
|
||||||
|
next_rev += 1
|
||||||
|
end if revisions
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
# 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 'redmine/scm/adapters/mercurial_adapter'
|
||||||
|
|
||||||
|
class Repository::Mercurial < Repository
|
||||||
|
attr_protected :root_url
|
||||||
|
validates_presence_of :url
|
||||||
|
|
||||||
|
def scm_adapter
|
||||||
|
Redmine::Scm::Adapters::MercurialAdapter
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_name
|
||||||
|
'Mercurial'
|
||||||
|
end
|
||||||
|
|
||||||
|
def entries(path=nil, identifier=nil)
|
||||||
|
entries=scm.entries(path, identifier)
|
||||||
|
if entries
|
||||||
|
entries.each do |entry|
|
||||||
|
next unless entry.is_file?
|
||||||
|
# Search the DB for the entry's last change
|
||||||
|
change = changes.find(:first, :conditions => ["path = ?", scm.with_leading_slash(entry.path)], :order => "#{Changeset.table_name}.committed_on DESC")
|
||||||
|
if change
|
||||||
|
entry.lastrev.identifier = change.changeset.revision
|
||||||
|
entry.lastrev.name = change.changeset.revision
|
||||||
|
entry.lastrev.author = change.changeset.committer
|
||||||
|
entry.lastrev.revision = change.revision
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
entries
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_changesets
|
||||||
|
scm_info = scm.info
|
||||||
|
if scm_info
|
||||||
|
# latest revision found in database
|
||||||
|
db_revision = latest_changeset ? latest_changeset.revision : nil
|
||||||
|
# latest revision in the repository
|
||||||
|
scm_revision = scm_info.lastrev.identifier.to_i
|
||||||
|
|
||||||
|
unless changesets.find_by_revision(scm_revision)
|
||||||
|
revisions = scm.revisions('', db_revision, nil)
|
||||||
|
transaction do
|
||||||
|
revisions.reverse_each do |revision|
|
||||||
|
changeset = Changeset.create(:repository => self,
|
||||||
|
:revision => revision.identifier,
|
||||||
|
:scmid => revision.scmid,
|
||||||
|
:committer => revision.author,
|
||||||
|
:committed_on => revision.time,
|
||||||
|
:comments => revision.message)
|
||||||
|
|
||||||
|
revision.paths.each do |change|
|
||||||
|
Change.create(:changeset => changeset,
|
||||||
|
:action => change[:action],
|
||||||
|
:path => change[:path],
|
||||||
|
:from_path => change[:from_path],
|
||||||
|
:from_revision => change[:from_revision])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# 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 'redmine/scm/adapters/subversion_adapter'
|
||||||
|
|
||||||
|
class Repository::Subversion < Repository
|
||||||
|
attr_protected :root_url
|
||||||
|
validates_presence_of :url
|
||||||
|
validates_format_of :url, :with => /^(http|https|svn|file):\/\/.+/i
|
||||||
|
|
||||||
|
def scm_adapter
|
||||||
|
Redmine::Scm::Adapters::SubversionAdapter
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.scm_name
|
||||||
|
'Subversion'
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_changesets
|
||||||
|
scm_info = scm.info
|
||||||
|
if scm_info
|
||||||
|
# latest revision found in database
|
||||||
|
db_revision = latest_changeset ? latest_changeset.revision : 0
|
||||||
|
# latest revision in the repository
|
||||||
|
scm_revision = scm_info.lastrev.identifier.to_i
|
||||||
|
if db_revision < scm_revision
|
||||||
|
logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug?
|
||||||
|
identifier_from = db_revision + 1
|
||||||
|
while (identifier_from <= scm_revision)
|
||||||
|
# loads changesets by batches of 200
|
||||||
|
identifier_to = [identifier_from + 199, scm_revision].min
|
||||||
|
revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true)
|
||||||
|
transaction do
|
||||||
|
revisions.reverse_each do |revision|
|
||||||
|
changeset = Changeset.create(:repository => self,
|
||||||
|
:revision => revision.identifier,
|
||||||
|
:committer => revision.author,
|
||||||
|
:committed_on => revision.time,
|
||||||
|
:comments => revision.message)
|
||||||
|
|
||||||
|
revision.paths.each do |change|
|
||||||
|
Change.create(:changeset => changeset,
|
||||||
|
:action => change[:action],
|
||||||
|
:path => change[:path],
|
||||||
|
:from_path => change[:from_path],
|
||||||
|
:from_revision => change[:from_revision])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end unless revisions.nil?
|
||||||
|
identifier_from = identifier_to + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -20,11 +20,16 @@ class Role < ActiveRecord::Base
|
|||||||
has_and_belongs_to_many :permissions
|
has_and_belongs_to_many :permissions
|
||||||
has_many :workflows, :dependent => :delete_all
|
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
|
validates_format_of :name, :with => /^[\w\s\'\-]*$/i
|
||||||
|
|
||||||
|
def <=>(role)
|
||||||
|
position <=> role.position
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_integrity
|
def check_integrity
|
||||||
raise "Can't delete role" if Member.find(:first, :conditions =>["role_id=?", self.id])
|
raise "Can't delete role" if Member.find(:first, :conditions =>["role_id=?", self.id])
|
||||||
|
|||||||
@@ -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_i > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.#{name}=(value)
|
||||||
|
self[:#{name}] = value
|
||||||
|
end
|
||||||
|
END_SRC
|
||||||
|
class_eval src, __FILE__, __LINE__
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
# redMine - project management software
|
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License
|
|
||||||
# as published by the Free Software Foundation; either version 2
|
|
||||||
# of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
require '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
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# 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 TimeEntry < ActiveRecord::Base
|
||||||
|
# could have used polymorphic association
|
||||||
|
# project association here allows easy loading of time entries at project level with one database trip
|
||||||
|
belongs_to :project
|
||||||
|
belongs_to :issue
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :activity, :class_name => 'Enumeration', :foreign_key => :activity_id
|
||||||
|
|
||||||
|
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
|
||||||
|
|
||||||
|
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
|
||||||
|
validates_numericality_of :hours, :allow_nil => true
|
||||||
|
validates_length_of :comments, :maximum => 255
|
||||||
|
|
||||||
|
def before_validation
|
||||||
|
self.project = issue.project if issue && project.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate
|
||||||
|
errors.add :hours, :activerecord_error_invalid if hours && (hours < 0 || hours >= 1000)
|
||||||
|
errors.add :project_id, :activerecord_error_invalid if project.nil?
|
||||||
|
errors.add :issue_id, :activerecord_error_invalid if (issue_id && !issue) || (issue && project!=issue.project)
|
||||||
|
end
|
||||||
|
|
||||||
|
# tyear, tmonth, tweek assigned where setting spent_on attributes
|
||||||
|
# these attributes make time aggregations easier
|
||||||
|
def spent_on=(date)
|
||||||
|
super
|
||||||
|
self.tyear = spent_on ? spent_on.year : nil
|
||||||
|
self.tmonth = spent_on ? spent_on.month : nil
|
||||||
|
self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil
|
||||||
|
end
|
||||||
|
end
|
||||||
+1
-1
@@ -31,7 +31,7 @@ class Token < ActiveRecord::Base
|
|||||||
|
|
||||||
# Delete all expired tokens
|
# Delete all expired tokens
|
||||||
def self.destroy_expired
|
def self.destroy_expired
|
||||||
Token.delete_all ["created_on < ?", Time.now - @@validity_time]
|
Token.delete_all ["action <> 'feeds' AND created_on < ?", Time.now - @@validity_time]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ class Tracker < ActiveRecord::Base
|
|||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
has_many :issues
|
has_many :issues
|
||||||
has_many :workflows, :dependent => :delete_all
|
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'
|
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
|
||||||
|
acts_as_list
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name
|
validates_uniqueness_of :name
|
||||||
|
|||||||
+55
-22
@@ -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,10 +18,17 @@
|
|||||||
require "digest/sha1"
|
require "digest/sha1"
|
||||||
|
|
||||||
class User < ActiveRecord::Base
|
class User < ActiveRecord::Base
|
||||||
has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :dependent => :delete_all
|
# Account statuses
|
||||||
|
STATUS_ACTIVE = 1
|
||||||
|
STATUS_REGISTERED = 2
|
||||||
|
STATUS_LOCKED = 3
|
||||||
|
|
||||||
|
has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :conditions => "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}", :order => "#{Project.table_name}.name", :dependent => :delete_all
|
||||||
has_many :projects, :through => :memberships
|
has_many :projects, :through => :memberships
|
||||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||||
|
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||||
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
|
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
|
||||||
|
has_one :rss_key, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'"
|
||||||
belongs_to :auth_source
|
belongs_to :auth_source
|
||||||
|
|
||||||
attr_accessor :password, :password_confirmation
|
attr_accessor :password, :password_confirmation
|
||||||
@@ -32,24 +39,34 @@ 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 :firstname, :lastname, :with => /^[\w\s\'\-]*$/i
|
|
||||||
validates_format_of :login, :with => /^[a-z0-9_\-@\.]+$/i
|
validates_format_of :login, :with => /^[a-z0-9_\-@\.]+$/i
|
||||||
|
validates_length_of :login, :maximum => 30
|
||||||
|
validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-]*$/i
|
||||||
|
validates_length_of :firstname, :lastname, :maximum => 30
|
||||||
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
||||||
|
validates_length_of :mail, :maximum => 60
|
||||||
# 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
|
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=?", login])
|
user = find(:first, :conditions => ["login=?", login])
|
||||||
@@ -69,7 +86,7 @@ class User < ActiveRecord::Base
|
|||||||
if attrs
|
if attrs
|
||||||
onthefly = new(*attrs)
|
onthefly = new(*attrs)
|
||||||
onthefly.login = login
|
onthefly.login = login
|
||||||
onthefly.language = $RDM_DEFAULT_LANG
|
onthefly.language = Setting.default_language
|
||||||
if onthefly.save
|
if onthefly.save
|
||||||
user = find(:first, :conditions => ["login=?", login])
|
user = find(:first, :conditions => ["login=?", login])
|
||||||
logger.info("User '#{user.login}' created on the fly.") if logger
|
logger.info("User '#{user.login}' created on the fly.") if logger
|
||||||
@@ -84,12 +101,8 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Return user's full name for display
|
# Return user's full name for display
|
||||||
def display_name
|
|
||||||
firstname + " " + lastname
|
|
||||||
end
|
|
||||||
|
|
||||||
def name
|
def name
|
||||||
display_name
|
"#{firstname} #{lastname}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def active?
|
def active?
|
||||||
@@ -108,20 +121,40 @@ class User < ActiveRecord::Base
|
|||||||
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)
|
||||||
@role_for_projects ||=
|
return nil unless project
|
||||||
begin
|
member = memberships.detect {|m| m.project_id == project.id}
|
||||||
roles = {}
|
member ? member.role : nil
|
||||||
self.memberships.each { |m| roles.store m.project_id, m.role_id }
|
end
|
||||||
roles
|
|
||||||
end
|
def authorized_to(project, action)
|
||||||
@role_for_projects[project_id]
|
return true if self.admin?
|
||||||
|
role = role_for_project(project)
|
||||||
|
role && Permission.allowed_to_role(action, role)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pref
|
def pref
|
||||||
self.preference ||= UserPreference.new(:user => self)
|
self.preference ||= UserPreference.new(:user => self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_or_create_rss_key
|
||||||
|
self.rss_key || Token.create(:user => self, :action => 'feeds')
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.find_by_rss_key(key)
|
||||||
|
token = Token.find_by_value(key)
|
||||||
|
token && token.user.active? ? token.user : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.find_by_autologin_key(key)
|
||||||
|
token = Token.find_by_action_and_value('autologin', key)
|
||||||
|
token && (token.created_on > Setting.autologin.to_i.day.ago) && token.user.active? ? token.user : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def <=>(user)
|
||||||
|
lastname == user.lastname ? firstname <=> user.firstname : lastname <=> user.lastname
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# Return password digest
|
# Return password digest
|
||||||
def self.hash_password(clear_password)
|
def self.hash_password(clear_password)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
class UserPreference < ActiveRecord::Base
|
class UserPreference < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
serialize :others, Hash
|
serialize :others
|
||||||
|
|
||||||
attr_protected :others
|
attr_protected :others
|
||||||
|
|
||||||
@@ -26,11 +26,15 @@ class UserPreference < ActiveRecord::Base
|
|||||||
self.others ||= {}
|
self.others ||= {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def before_save
|
||||||
|
self.others ||= {}
|
||||||
|
end
|
||||||
|
|
||||||
def [](attr_name)
|
def [](attr_name)
|
||||||
if attribute_present? attr_name
|
if attribute_present? attr_name
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
others[attr_name]
|
others ? others[attr_name] : nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -38,7 +42,8 @@ class UserPreference < ActiveRecord::Base
|
|||||||
if attribute_present? attr_name
|
if attribute_present? attr_name
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
others.store attr_name, value
|
self.others ||= {}
|
||||||
|
self.others.store attr_name, value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+30
-1
@@ -23,7 +23,36 @@ class Version < ActiveRecord::Base
|
|||||||
|
|
||||||
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
|
validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date, :allow_nil => true
|
||||||
|
|
||||||
|
def start_date
|
||||||
|
effective_date
|
||||||
|
end
|
||||||
|
|
||||||
|
def due_date
|
||||||
|
effective_date
|
||||||
|
end
|
||||||
|
|
||||||
|
def completed?
|
||||||
|
effective_date && effective_date <= Date.today
|
||||||
|
end
|
||||||
|
|
||||||
|
def wiki_page
|
||||||
|
if project.wiki && !wiki_page_title.blank?
|
||||||
|
@wiki_page ||= project.wiki.find_page(wiki_page_title)
|
||||||
|
end
|
||||||
|
@wiki_page
|
||||||
|
end
|
||||||
|
|
||||||
|
# Versions are sorted by effective_date
|
||||||
|
# Those with no effective_date are at the end, sorted by name
|
||||||
|
def <=>(version)
|
||||||
|
if self.effective_date
|
||||||
|
version.effective_date ? (self.effective_date <=> version.effective_date) : -1
|
||||||
|
else
|
||||||
|
version.effective_date ? 1 : (self.name <=> version.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_integrity
|
def check_integrity
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# 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 Watcher < ActiveRecord::Base
|
||||||
|
belongs_to :watchable, :polymorphic => true
|
||||||
|
belongs_to :user
|
||||||
|
|
||||||
|
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
|
||||||
|
end
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# redMine - project management software
|
||||||
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class Wiki < ActiveRecord::Base
|
||||||
|
belongs_to :project
|
||||||
|
has_many :pages, :class_name => 'WikiPage', :dependent => :destroy
|
||||||
|
|
||||||
|
validates_presence_of :start_page
|
||||||
|
validates_format_of :start_page, :with => /^[^,\.\/\?\;\|]*$/
|
||||||
|
|
||||||
|
# find the page with the given title
|
||||||
|
# if page doesn't exist, return a new page
|
||||||
|
def find_or_new_page(title)
|
||||||
|
title = Wiki.titleize(title || start_page)
|
||||||
|
find_page(title) || WikiPage.new(:wiki => self, :title => title)
|
||||||
|
end
|
||||||
|
|
||||||
|
# find the page with the given title
|
||||||
|
def find_page(title)
|
||||||
|
title = start_page if title.blank?
|
||||||
|
pages.find_by_title(Wiki.titleize(title))
|
||||||
|
end
|
||||||
|
|
||||||
|
# turn a string into a valid page title
|
||||||
|
def self.titleize(title)
|
||||||
|
# replace spaces with _ and remove unwanted caracters
|
||||||
|
title = title.gsub(/\s+/, '_').delete(',./?;|') if title
|
||||||
|
# upcase the first letter
|
||||||
|
title = title[0..0].upcase + title[1..-1] if title
|
||||||
|
title
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# redMine - project management software
|
||||||
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
require 'zlib'
|
||||||
|
|
||||||
|
class WikiContent < ActiveRecord::Base
|
||||||
|
set_locking_column :version
|
||||||
|
belongs_to :page, :class_name => 'WikiPage', :foreign_key => 'page_id'
|
||||||
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
|
validates_presence_of :text
|
||||||
|
|
||||||
|
acts_as_versioned
|
||||||
|
class Version
|
||||||
|
belongs_to :page, :class_name => 'WikiPage', :foreign_key => 'page_id'
|
||||||
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
|
attr_protected :data
|
||||||
|
|
||||||
|
def text=(plain)
|
||||||
|
case Setting.wiki_compression
|
||||||
|
when 'gzip'
|
||||||
|
begin
|
||||||
|
self.data = Zlib::Deflate.deflate(plain, Zlib::BEST_COMPRESSION)
|
||||||
|
self.compression = 'gzip'
|
||||||
|
rescue
|
||||||
|
self.data = plain
|
||||||
|
self.compression = ''
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.data = plain
|
||||||
|
self.compression = ''
|
||||||
|
end
|
||||||
|
plain
|
||||||
|
end
|
||||||
|
|
||||||
|
def text
|
||||||
|
@text ||= case compression
|
||||||
|
when 'gzip'
|
||||||
|
Zlib::Inflate.inflate(data)
|
||||||
|
else
|
||||||
|
# uncompressed data
|
||||||
|
data
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
# 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 'diff'
|
||||||
|
|
||||||
|
class WikiPage < ActiveRecord::Base
|
||||||
|
belongs_to :wiki
|
||||||
|
has_one :content, :class_name => 'WikiContent', :foreign_key => 'page_id', :dependent => :destroy
|
||||||
|
has_many :attachments, :as => :container, :dependent => :destroy
|
||||||
|
|
||||||
|
validates_presence_of :title
|
||||||
|
validates_format_of :title, :with => /^[^,\.\/\?\;\|\s]*$/
|
||||||
|
validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false
|
||||||
|
validates_associated :content
|
||||||
|
|
||||||
|
def before_save
|
||||||
|
self.title = Wiki.titleize(title)
|
||||||
|
end
|
||||||
|
|
||||||
|
def pretty_title
|
||||||
|
WikiPage.pretty_title(title)
|
||||||
|
end
|
||||||
|
|
||||||
|
def content_for_version(version=nil)
|
||||||
|
result = content.versions.find_by_version(version.to_i) if version
|
||||||
|
result ||= content
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def diff(version_to=nil, version_from=nil)
|
||||||
|
version_to = version_to ? version_to.to_i : self.content.version
|
||||||
|
version_from = version_from ? version_from.to_i : version_to - 1
|
||||||
|
version_to, version_from = version_from, version_to unless version_from < version_to
|
||||||
|
|
||||||
|
content_to = content.versions.find_by_version(version_to)
|
||||||
|
content_from = content.versions.find_by_version(version_from)
|
||||||
|
|
||||||
|
(content_to && content_from) ? WikiDiff.new(content_to, content_from) : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.pretty_title(str)
|
||||||
|
(str && str.is_a?(String)) ? str.tr('_', ' ') : str
|
||||||
|
end
|
||||||
|
|
||||||
|
def project
|
||||||
|
wiki.project
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class WikiDiff
|
||||||
|
attr_reader :diff, :words, :content_to, :content_from
|
||||||
|
|
||||||
|
def initialize(content_to, content_from)
|
||||||
|
@content_to = content_to
|
||||||
|
@content_from = content_from
|
||||||
|
@words = content_to.text.split(/(\s+)/)
|
||||||
|
@words = @words.select {|word| word != ' '}
|
||||||
|
words_from = content_from.text.split(/(\s+)/)
|
||||||
|
words_from = words_from.select {|word| word != ' '}
|
||||||
|
@diff = words_from.diff @words
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# 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 IssueSweeper < ActionController::Caching::Sweeper
|
||||||
|
observe Issue
|
||||||
|
|
||||||
|
def after_save(issue)
|
||||||
|
expire_cache_for(issue)
|
||||||
|
end
|
||||||
|
|
||||||
|
def after_destroy(issue)
|
||||||
|
expire_cache_for(issue)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def expire_cache_for(issue)
|
||||||
|
# fragments of the main project
|
||||||
|
expire_fragment(Regexp.new("projects/(calendar|gantt)/#{issue.project_id}\\."))
|
||||||
|
# fragments of the root project that include subprojects issues
|
||||||
|
unless issue.project.parent_id.nil?
|
||||||
|
expire_fragment(Regexp.new("projects/(calendar|gantt)/#{issue.project.parent_id}\\..*subprojects"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# 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 ProjectSweeper < ActionController::Caching::Sweeper
|
||||||
|
observe Project
|
||||||
|
|
||||||
|
def before_save(project)
|
||||||
|
if project.new_record?
|
||||||
|
expire_cache_for(project.parent) if project.parent
|
||||||
|
else
|
||||||
|
project_before_update = Project.find(project.id)
|
||||||
|
return if project_before_update.parent_id == project.parent_id && project_before_update.status == project.status
|
||||||
|
expire_cache_for(project.parent) if project.parent
|
||||||
|
expire_cache_for(project_before_update.parent) if project_before_update.parent
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def after_destroy(project)
|
||||||
|
expire_cache_for(project.parent) if project.parent
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def expire_cache_for(project)
|
||||||
|
expire_fragment(Regexp.new("projects/(calendar|gantt)/#{project.id}\\."))
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,18 +1,28 @@
|
|||||||
<center>
|
<center>
|
||||||
<div class="box login">
|
<div class="box login">
|
||||||
<h2><%= image_tag 'login' %> <%=l(:label_please_login)%></h2>
|
<h2 class="icon22 icon22-authent"><%=l(:label_please_login)%></h2>
|
||||||
|
|
||||||
|
<% form_tag({:action=> "login"}, :class => "tabular") do %>
|
||||||
|
|
||||||
<%= start_form_tag({:action=> "login"}, :class => "tabular") %>
|
|
||||||
<p><label for="login"><%=l(:field_login)%>:</label>
|
<p><label for="login"><%=l(:field_login)%>:</label>
|
||||||
<%= text_field_tag 'login', nil, :size => 25 %></p>
|
<%= text_field_tag 'login', nil, :size => 25 %></p>
|
||||||
|
|
||||||
<p><label for="password"><%=l(:field_password)%>:</label>
|
<p><label for="password"><%=l(:field_password)%>:</label>
|
||||||
<%= password_field_tag 'password', nil, :size => 25 %></p>
|
<%= password_field_tag 'password', nil, :size => 25 %></p>
|
||||||
|
|
||||||
<p><center><input type="submit" name="login" value="<%=l(:button_login)%> »" class="primary" /></center>
|
<% if Setting.autologin? %>
|
||||||
<%= end_form_tag %>
|
<p><label for="autologin"><%= check_box_tag 'autologin' %> <%= l(:label_stay_logged_in) %></label></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<p><input type="submit" name="login" value="<%=l(:button_login)%> »" class="primary" /></p>
|
||||||
|
<% end %>
|
||||||
|
<%= javascript_tag "Form.Element.focus('login');" %>
|
||||||
|
|
||||||
|
<% 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(" | ") %>
|
||||||
|
|
||||||
<br><% unless $RDM_SELF_REGISTRATION == false %><%= link_to l(:label_register), :action => 'register' %> |<% end %>
|
|
||||||
<%= link_to l(:label_password_lost), :action => 'lost_password' %></p>
|
|
||||||
</div>
|
</div>
|
||||||
</center>
|
</center>
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
<div class="box login">
|
<div class="box login">
|
||||||
<h2><%=l(:label_password_lost)%></h2>
|
<h2><%=l(:label_password_lost)%></h2>
|
||||||
|
|
||||||
<%= start_form_tag({:action=> "lost_password"}, :class => "tabular") %>
|
<% form_tag({:action=> "lost_password"}, :class => "tabular") do %>
|
||||||
|
|
||||||
<p><label for="mail"><%=l(:field_mail)%> <span class="required">*</span></label>
|
<p><label for="mail"><%=l(:field_mail)%> <span class="required">*</span></label>
|
||||||
<%= text_field_tag 'mail', nil, :size => 40 %></p>
|
<%= text_field_tag 'mail', nil, :size => 40 %></p>
|
||||||
|
|
||||||
<p><center><%= submit_tag l(:button_submit) %></center></p>
|
<p><center><%= submit_tag l(:button_submit) %></center></p>
|
||||||
|
|
||||||
<%= end_form_tag %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</center>
|
</center>
|
||||||
@@ -6,16 +6,17 @@
|
|||||||
|
|
||||||
<%= error_messages_for 'user' %>
|
<%= error_messages_for 'user' %>
|
||||||
|
|
||||||
<%= start_form_tag({:token => @token.value}, :class => "tabular") %>
|
<% form_tag({:token => @token.value}, :class => "tabular") do %>
|
||||||
|
|
||||||
<p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
|
<p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
|
||||||
<%= password_field_tag 'new_password', nil, :size => 25 %></p>
|
<%= password_field_tag 'new_password', nil, :size => 25 %><br />
|
||||||
|
<em><%= l(:text_length_between, 4, 12) %></em></p>
|
||||||
|
|
||||||
<p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
|
<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>
|
<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
|
||||||
|
|
||||||
<p><center><%= submit_tag l(:button_save) %></center></p>
|
<p><center><%= submit_tag l(:button_save) %></center></p>
|
||||||
<%= end_form_tag %>
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</center>
|
</center>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<h2><%=l(:label_register)%></h2>
|
<h2><%=l(:label_register)%></h2>
|
||||||
|
|
||||||
<%= start_form_tag({:action => 'register'}, :class => "tabular") %>
|
<% form_tag({:action => 'register'}, :class => "tabular") do %>
|
||||||
<%= error_messages_for 'user' %>
|
<%= error_messages_for 'user' %>
|
||||||
|
|
||||||
<div class="box">
|
<div class="box">
|
||||||
@@ -36,4 +36,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= submit_tag l(:button_submit) %>
|
<%= submit_tag l(:button_submit) %>
|
||||||
<%= end_form_tag %>
|
<% end %>
|
||||||
|
|
||||||
|
<% content_for :header_tags do %>
|
||||||
|
<%= javascript_include_tag 'calendar/calendar' %>
|
||||||
|
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
|
||||||
|
<%= javascript_include_tag 'calendar/calendar-setup' %>
|
||||||
|
<%= stylesheet_link_tag 'calendar' %>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<h2><%= @user.display_name %></h2>
|
<h2><%=h @user.name %></h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= mail_to @user.mail unless @user.pref.hide_mail %>
|
<%= mail_to @user.mail unless @user.pref.hide_mail %>
|
||||||
@@ -12,13 +12,15 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<% unless @memberships.empty? %>
|
||||||
<h3><%=l(:label_project_plural)%></h3>
|
<h3><%=l(:label_project_plural)%></h3>
|
||||||
<p>
|
<ul>
|
||||||
<% for membership in @user.memberships %>
|
<% for membership in @memberships %>
|
||||||
<%= membership.project.name %> (<%= membership.role.name %>, <%= format_date(membership.created_on) %>)
|
<li><%= link_to membership.project.name, :controller => 'projects', :action => 'show', :id => membership.project %>
|
||||||
<br />
|
(<%= membership.role.name %>, <%= format_date(membership.created_on) %>)</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3><%=l(:label_activity)%></h3>
|
<h3><%=l(:label_activity)%></h3>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user