##// END OF EJS Templates
code clean up AdminController....
Toshi MARUYAMA -
r5430:6da0d5d366c6
parent child
Show More
@@ -1,86 +1,84
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 AdminController < ApplicationController
19 19 layout 'admin'
20
21 20 before_filter :require_admin
22
23 21 helper :sort
24 22 include SortHelper
25 23
26 24 def index
27 25 @no_configuration_data = Redmine::DefaultData::Loader::no_data?
28 26 end
29 27
30 28 def projects
31 29 @status = params[:status] ? params[:status].to_i : 1
32 30 c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
33
34 31 unless params[:name].blank?
35 32 name = "%#{params[:name].strip.downcase}%"
36 33 c << ["LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?", name, name]
37 34 end
38
39 35 @projects = Project.find :all, :order => 'lft',
40 36 :conditions => c.conditions
41 37
42 38 render :action => "projects", :layout => false if request.xhr?
43 39 end
44
40
45 41 def plugins
46 42 @plugins = Redmine::Plugin.all
47 43 end
48
44
49 45 # Loads the default configuration
50 46 # (roles, trackers, statuses, workflow, enumerations)
51 47 def default_configuration
52 48 if request.post?
53 49 begin
54 50 Redmine::DefaultData::Loader::load(params[:lang])
55 51 flash[:notice] = l(:notice_default_data_loaded)
56 52 rescue Exception => e
57 53 flash[:error] = l(:error_can_t_load_default_data, e.message)
58 54 end
59 55 end
60 56 redirect_to :action => 'index'
61 57 end
62
58
63 59 def test_email
64 60 raise_delivery_errors = ActionMailer::Base.raise_delivery_errors
65 61 # Force ActionMailer to raise delivery errors so we can catch it
66 62 ActionMailer::Base.raise_delivery_errors = true
67 63 begin
68 64 @test = Mailer.deliver_test(User.current)
69 65 flash[:notice] = l(:notice_email_sent, User.current.mail)
70 66 rescue Exception => e
71 67 flash[:error] = l(:notice_email_error, e.message)
72 68 end
73 69 ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
74 70 redirect_to :controller => 'settings', :action => 'edit', :tab => 'notifications'
75 71 end
76
72
77 73 def info
78 74 @db_adapter_name = ActiveRecord::Base.connection.adapter_name
79 75 @checklist = [
80 [:text_default_administrator_account_changed, User.find(:first, :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?],
76 [:text_default_administrator_account_changed,
77 User.find(:first,
78 :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?],
81 79 [:text_file_repository_writable, File.writable?(Attachment.storage_path)],
82 [:text_plugin_assets_writable, File.writable?(Engines.public_directory)],
83 [:text_rmagick_available, Object.const_defined?(:Magick)]
80 [:text_plugin_assets_writable, File.writable?(Engines.public_directory)],
81 [:text_rmagick_available, Object.const_defined?(:Magick)]
84 82 ]
85 end
83 end
86 84 end
General Comments 0
You need to be logged in to leave comments. Login now