##// END OF EJS Templates
Refactor: Merged AuthSourcesController#list and #index...
Eric Davis -
r3322:c5f30fde2872
parent child
Show More
@@ -1,84 +1,79
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class AuthSourcesController < ApplicationController
19 19 layout 'admin'
20 20
21 21 before_filter :require_admin
22 22
23 def index
24 list
25 render :action => 'list' unless request.xhr?
26 end
27
28 23 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
29 24 verify :method => :post, :only => [ :destroy, :create, :update ],
30 25 :redirect_to => { :action => :list }
31 26
32 def list
27 def index
33 28 @auth_source_pages, @auth_sources = paginate :auth_sources, :per_page => 10
34 render :action => "list", :layout => false if request.xhr?
29 render :action => "index", :layout => false if request.xhr?
35 30 end
36 31
37 32 def new
38 33 @auth_source = AuthSourceLdap.new
39 34 end
40 35
41 36 def create
42 37 @auth_source = AuthSourceLdap.new(params[:auth_source])
43 38 if @auth_source.save
44 39 flash[:notice] = l(:notice_successful_create)
45 redirect_to :action => 'list'
40 redirect_to :action => 'index'
46 41 else
47 42 render :action => 'new'
48 43 end
49 44 end
50 45
51 46 def edit
52 47 @auth_source = AuthSource.find(params[:id])
53 48 end
54 49
55 50 def update
56 51 @auth_source = AuthSource.find(params[:id])
57 52 if @auth_source.update_attributes(params[:auth_source])
58 53 flash[:notice] = l(:notice_successful_update)
59 redirect_to :action => 'list'
54 redirect_to :action => 'index'
60 55 else
61 56 render :action => 'edit'
62 57 end
63 58 end
64 59
65 60 def test_connection
66 61 @auth_method = AuthSource.find(params[:id])
67 62 begin
68 63 @auth_method.test_connection
69 64 flash[:notice] = l(:notice_successful_connection)
70 65 rescue => text
71 66 flash[:error] = "Unable to connect (#{text})"
72 67 end
73 redirect_to :action => 'list'
68 redirect_to :action => 'index'
74 69 end
75 70
76 71 def destroy
77 72 @auth_source = AuthSource.find(params[:id])
78 73 unless @auth_source.users.find(:first)
79 74 @auth_source.destroy
80 75 flash[:notice] = l(:notice_successful_delete)
81 76 end
82 redirect_to :action => 'list'
77 redirect_to :action => 'index'
83 78 end
84 79 end
1 NO CONTENT: file renamed from app/views/auth_sources/list.rhtml to app/views/auth_sources/index.html.erb
@@ -1,27 +1,27
1 1 <% form_tag({:action => 'edit', :tab => 'authentication'}) do %>
2 2
3 3 <div class="box tabular settings">
4 4 <p><%= setting_check_box :login_required %></p>
5 5
6 6 <p><%= setting_select :autologin, [1, 7, 30, 365].collect{|days| [l('datetime.distance_in_words.x_days', :count => days), days.to_s]}, :blank => :label_disabled %></p>
7 7
8 8 <p><%= setting_select :self_registration, [[l(:label_disabled), "0"],
9 9 [l(:label_registration_activation_by_email), "1"],
10 10 [l(:label_registration_manual_activation), "2"],
11 11 [l(:label_registration_automatic_activation), "3"]] %></p>
12 12
13 13 <p><%= setting_text_field :password_min_length, :size => 6 %></p>
14 14
15 15 <p><%= setting_check_box :lost_password, :label => :label_password_lost %></p>
16 16
17 17 <p><%= setting_check_box :openid, :disabled => !Object.const_defined?(:OpenID) %></p>
18 18
19 19 <p><%= setting_check_box :rest_api_enabled %></p>
20 20 </div>
21 21
22 22 <div style="float:right;">
23 <%= link_to l(:label_ldap_authentication), :controller => 'auth_sources', :action => 'list' %>
23 <%= link_to l(:label_ldap_authentication), :controller => 'auth_sources', :action => 'index' %>
24 24 </div>
25 25
26 26 <%= submit_tag l(:button_save) %>
27 27 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now