@@ -1,82 +1,82 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2012 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2012 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class AuthSourcesController < ApplicationController |
|
18 | class AuthSourcesController < ApplicationController | |
19 | layout 'admin' |
|
19 | layout 'admin' | |
20 | menu_item :ldap_authentication |
|
20 | menu_item :ldap_authentication | |
21 |
|
21 | |||
22 | before_filter :require_admin |
|
22 | before_filter :require_admin | |
23 | before_filter :find_auth_source, :only => [:edit, :update, :test_connection, :destroy] |
|
23 | before_filter :find_auth_source, :only => [:edit, :update, :test_connection, :destroy] | |
24 |
|
24 | |||
25 | def index |
|
25 | def index | |
26 |
@auth_source_pages, @auth_sources = paginate AuthSource, :per_page => |
|
26 | @auth_source_pages, @auth_sources = paginate AuthSource, :per_page => 25 | |
27 | end |
|
27 | end | |
28 |
|
28 | |||
29 | def new |
|
29 | def new | |
30 | klass_name = params[:type] || 'AuthSourceLdap' |
|
30 | klass_name = params[:type] || 'AuthSourceLdap' | |
31 | @auth_source = AuthSource.new_subclass_instance(klass_name, params[:auth_source]) |
|
31 | @auth_source = AuthSource.new_subclass_instance(klass_name, params[:auth_source]) | |
32 | render_404 unless @auth_source |
|
32 | render_404 unless @auth_source | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def create |
|
35 | def create | |
36 | @auth_source = AuthSource.new_subclass_instance(params[:type], params[:auth_source]) |
|
36 | @auth_source = AuthSource.new_subclass_instance(params[:type], params[:auth_source]) | |
37 | if @auth_source.save |
|
37 | if @auth_source.save | |
38 | flash[:notice] = l(:notice_successful_create) |
|
38 | flash[:notice] = l(:notice_successful_create) | |
39 | redirect_to auth_sources_path |
|
39 | redirect_to auth_sources_path | |
40 | else |
|
40 | else | |
41 | render :action => 'new' |
|
41 | render :action => 'new' | |
42 | end |
|
42 | end | |
43 | end |
|
43 | end | |
44 |
|
44 | |||
45 | def edit |
|
45 | def edit | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | def update |
|
48 | def update | |
49 | if @auth_source.update_attributes(params[:auth_source]) |
|
49 | if @auth_source.update_attributes(params[:auth_source]) | |
50 | flash[:notice] = l(:notice_successful_update) |
|
50 | flash[:notice] = l(:notice_successful_update) | |
51 | redirect_to auth_sources_path |
|
51 | redirect_to auth_sources_path | |
52 | else |
|
52 | else | |
53 | render :action => 'edit' |
|
53 | render :action => 'edit' | |
54 | end |
|
54 | end | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | def test_connection |
|
57 | def test_connection | |
58 | begin |
|
58 | begin | |
59 | @auth_source.test_connection |
|
59 | @auth_source.test_connection | |
60 | flash[:notice] = l(:notice_successful_connection) |
|
60 | flash[:notice] = l(:notice_successful_connection) | |
61 | rescue Exception => e |
|
61 | rescue Exception => e | |
62 | flash[:error] = l(:error_unable_to_connect, e.message) |
|
62 | flash[:error] = l(:error_unable_to_connect, e.message) | |
63 | end |
|
63 | end | |
64 | redirect_to auth_sources_path |
|
64 | redirect_to auth_sources_path | |
65 | end |
|
65 | end | |
66 |
|
66 | |||
67 | def destroy |
|
67 | def destroy | |
68 | unless @auth_source.users.exists? |
|
68 | unless @auth_source.users.exists? | |
69 | @auth_source.destroy |
|
69 | @auth_source.destroy | |
70 | flash[:notice] = l(:notice_successful_delete) |
|
70 | flash[:notice] = l(:notice_successful_delete) | |
71 | end |
|
71 | end | |
72 | redirect_to auth_sources_path |
|
72 | redirect_to auth_sources_path | |
73 | end |
|
73 | end | |
74 |
|
74 | |||
75 | private |
|
75 | private | |
76 |
|
76 | |||
77 | def find_auth_source |
|
77 | def find_auth_source | |
78 | @auth_source = AuthSource.find(params[:id]) |
|
78 | @auth_source = AuthSource.find(params[:id]) | |
79 | rescue ActiveRecord::RecordNotFound |
|
79 | rescue ActiveRecord::RecordNotFound | |
80 | render_404 |
|
80 | render_404 | |
81 | end |
|
81 | end | |
82 | end |
|
82 | end |
@@ -1,101 +1,101 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2012 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2012 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class TrackersController < ApplicationController |
|
18 | class TrackersController < ApplicationController | |
19 | layout 'admin' |
|
19 | layout 'admin' | |
20 |
|
20 | |||
21 | before_filter :require_admin, :except => :index |
|
21 | before_filter :require_admin, :except => :index | |
22 | before_filter :require_admin_or_api_request, :only => :index |
|
22 | before_filter :require_admin_or_api_request, :only => :index | |
23 | accept_api_auth :index |
|
23 | accept_api_auth :index | |
24 |
|
24 | |||
25 | def index |
|
25 | def index | |
26 | respond_to do |format| |
|
26 | respond_to do |format| | |
27 | format.html { |
|
27 | format.html { | |
28 |
@tracker_pages, @trackers = paginate Tracker.sorted, :per_page => |
|
28 | @tracker_pages, @trackers = paginate Tracker.sorted, :per_page => 25 | |
29 | render :action => "index", :layout => false if request.xhr? |
|
29 | render :action => "index", :layout => false if request.xhr? | |
30 | } |
|
30 | } | |
31 | format.api { |
|
31 | format.api { | |
32 | @trackers = Tracker.sorted.all |
|
32 | @trackers = Tracker.sorted.all | |
33 | } |
|
33 | } | |
34 | end |
|
34 | end | |
35 | end |
|
35 | end | |
36 |
|
36 | |||
37 | def new |
|
37 | def new | |
38 | @tracker ||= Tracker.new(params[:tracker]) |
|
38 | @tracker ||= Tracker.new(params[:tracker]) | |
39 | @trackers = Tracker.sorted.all |
|
39 | @trackers = Tracker.sorted.all | |
40 | @projects = Project.all |
|
40 | @projects = Project.all | |
41 | end |
|
41 | end | |
42 |
|
42 | |||
43 | def create |
|
43 | def create | |
44 | @tracker = Tracker.new(params[:tracker]) |
|
44 | @tracker = Tracker.new(params[:tracker]) | |
45 | if @tracker.save |
|
45 | if @tracker.save | |
46 | # workflow copy |
|
46 | # workflow copy | |
47 | if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from])) |
|
47 | if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from])) | |
48 | @tracker.workflow_rules.copy(copy_from) |
|
48 | @tracker.workflow_rules.copy(copy_from) | |
49 | end |
|
49 | end | |
50 | flash[:notice] = l(:notice_successful_create) |
|
50 | flash[:notice] = l(:notice_successful_create) | |
51 | redirect_to trackers_path |
|
51 | redirect_to trackers_path | |
52 | return |
|
52 | return | |
53 | end |
|
53 | end | |
54 | new |
|
54 | new | |
55 | render :action => 'new' |
|
55 | render :action => 'new' | |
56 | end |
|
56 | end | |
57 |
|
57 | |||
58 | def edit |
|
58 | def edit | |
59 | @tracker ||= Tracker.find(params[:id]) |
|
59 | @tracker ||= Tracker.find(params[:id]) | |
60 | @projects = Project.all |
|
60 | @projects = Project.all | |
61 | end |
|
61 | end | |
62 |
|
62 | |||
63 | def update |
|
63 | def update | |
64 | @tracker = Tracker.find(params[:id]) |
|
64 | @tracker = Tracker.find(params[:id]) | |
65 | if @tracker.update_attributes(params[:tracker]) |
|
65 | if @tracker.update_attributes(params[:tracker]) | |
66 | flash[:notice] = l(:notice_successful_update) |
|
66 | flash[:notice] = l(:notice_successful_update) | |
67 | redirect_to trackers_path |
|
67 | redirect_to trackers_path | |
68 | return |
|
68 | return | |
69 | end |
|
69 | end | |
70 | edit |
|
70 | edit | |
71 | render :action => 'edit' |
|
71 | render :action => 'edit' | |
72 | end |
|
72 | end | |
73 |
|
73 | |||
74 | def destroy |
|
74 | def destroy | |
75 | @tracker = Tracker.find(params[:id]) |
|
75 | @tracker = Tracker.find(params[:id]) | |
76 | unless @tracker.issues.empty? |
|
76 | unless @tracker.issues.empty? | |
77 | flash[:error] = l(:error_can_not_delete_tracker) |
|
77 | flash[:error] = l(:error_can_not_delete_tracker) | |
78 | else |
|
78 | else | |
79 | @tracker.destroy |
|
79 | @tracker.destroy | |
80 | end |
|
80 | end | |
81 | redirect_to trackers_path |
|
81 | redirect_to trackers_path | |
82 | end |
|
82 | end | |
83 |
|
83 | |||
84 | def fields |
|
84 | def fields | |
85 | if request.post? && params[:trackers] |
|
85 | if request.post? && params[:trackers] | |
86 | params[:trackers].each do |tracker_id, tracker_params| |
|
86 | params[:trackers].each do |tracker_id, tracker_params| | |
87 | tracker = Tracker.find_by_id(tracker_id) |
|
87 | tracker = Tracker.find_by_id(tracker_id) | |
88 | if tracker |
|
88 | if tracker | |
89 | tracker.core_fields = tracker_params[:core_fields] |
|
89 | tracker.core_fields = tracker_params[:core_fields] | |
90 | tracker.custom_field_ids = tracker_params[:custom_field_ids] |
|
90 | tracker.custom_field_ids = tracker_params[:custom_field_ids] | |
91 | tracker.save |
|
91 | tracker.save | |
92 | end |
|
92 | end | |
93 | end |
|
93 | end | |
94 | flash[:notice] = l(:notice_successful_update) |
|
94 | flash[:notice] = l(:notice_successful_update) | |
95 | redirect_to fields_trackers_path |
|
95 | redirect_to fields_trackers_path | |
96 | return |
|
96 | return | |
97 | end |
|
97 | end | |
98 | @trackers = Tracker.sorted.all |
|
98 | @trackers = Tracker.sorted.all | |
99 | @custom_fields = IssueCustomField.all.sort |
|
99 | @custom_fields = IssueCustomField.all.sort | |
100 | end |
|
100 | end | |
101 | end |
|
101 | end |
General Comments 0
You need to be logged in to leave comments.
Login now