@@ -1,88 +1,87 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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 AdminController < ApplicationController |
|
18 | class AdminController < ApplicationController | |
19 | layout 'admin' |
|
19 | layout 'admin' | |
20 | self.main_menu = false |
|
20 | self.main_menu = false | |
21 | menu_item :projects, :only => :projects |
|
21 | menu_item :projects, :only => :projects | |
22 | menu_item :plugins, :only => :plugins |
|
22 | menu_item :plugins, :only => :plugins | |
23 | menu_item :info, :only => :info |
|
23 | menu_item :info, :only => :info | |
24 |
|
24 | |||
25 | before_action :require_admin |
|
25 | before_action :require_admin | |
26 | helper :sort |
|
26 | helper :sort | |
27 | include SortHelper |
|
27 | include SortHelper | |
28 |
|
28 | |||
29 | def index |
|
29 | def index | |
30 | @no_configuration_data = Redmine::DefaultData::Loader::no_data? |
|
30 | @no_configuration_data = Redmine::DefaultData::Loader::no_data? | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def projects |
|
33 | def projects | |
34 | @status = params[:status] || 1 |
|
34 | @status = params[:status] || 1 | |
35 |
|
35 | |||
36 | scope = Project.status(@status).sorted |
|
36 | scope = Project.status(@status).sorted | |
37 | scope = scope.like(params[:name]) if params[:name].present? |
|
37 | scope = scope.like(params[:name]) if params[:name].present? | |
38 |
|
38 | |||
39 | @project_count = scope.count |
|
39 | @project_count = scope.count | |
40 | @project_pages = Paginator.new @project_count, per_page_option, params['page'] |
|
40 | @project_pages = Paginator.new @project_count, per_page_option, params['page'] | |
41 | @projects = scope.limit(@project_pages.per_page).offset(@project_pages.offset).to_a |
|
41 | @projects = scope.limit(@project_pages.per_page).offset(@project_pages.offset).to_a | |
42 |
|
42 | |||
43 | render :action => "projects", :layout => false if request.xhr? |
|
43 | render :action => "projects", :layout => false if request.xhr? | |
44 | end |
|
44 | end | |
45 |
|
45 | |||
46 | def plugins |
|
46 | def plugins | |
47 | @plugins = Redmine::Plugin.all |
|
47 | @plugins = Redmine::Plugin.all | |
48 | end |
|
48 | end | |
49 |
|
49 | |||
50 | # Loads the default configuration |
|
50 | # Loads the default configuration | |
51 | # (roles, trackers, statuses, workflow, enumerations) |
|
51 | # (roles, trackers, statuses, workflow, enumerations) | |
52 | def default_configuration |
|
52 | def default_configuration | |
53 | if request.post? |
|
53 | if request.post? | |
54 | begin |
|
54 | begin | |
55 | Redmine::DefaultData::Loader::load(params[:lang]) |
|
55 | Redmine::DefaultData::Loader::load(params[:lang]) | |
56 | flash[:notice] = l(:notice_default_data_loaded) |
|
56 | flash[:notice] = l(:notice_default_data_loaded) | |
57 | rescue Exception => e |
|
57 | rescue Exception => e | |
58 | flash[:error] = l(:error_can_t_load_default_data, ERB::Util.h(e.message)) |
|
58 | flash[:error] = l(:error_can_t_load_default_data, ERB::Util.h(e.message)) | |
59 | end |
|
59 | end | |
60 | end |
|
60 | end | |
61 | redirect_to admin_path |
|
61 | redirect_to admin_path | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | def test_email |
|
64 | def test_email | |
65 | raise_delivery_errors = ActionMailer::Base.raise_delivery_errors |
|
65 | raise_delivery_errors = ActionMailer::Base.raise_delivery_errors | |
66 | # Force ActionMailer to raise delivery errors so we can catch it |
|
66 | # Force ActionMailer to raise delivery errors so we can catch it | |
67 | ActionMailer::Base.raise_delivery_errors = true |
|
67 | ActionMailer::Base.raise_delivery_errors = true | |
68 | begin |
|
68 | begin | |
69 | @test = Mailer.test_email(User.current).deliver |
|
69 | @test = Mailer.test_email(User.current).deliver | |
70 | flash[:notice] = l(:notice_email_sent, ERB::Util.h(User.current.mail)) |
|
70 | flash[:notice] = l(:notice_email_sent, ERB::Util.h(User.current.mail)) | |
71 | rescue Exception => e |
|
71 | rescue Exception => e | |
72 | flash[:error] = l(:notice_email_error, ERB::Util.h(Redmine::CodesetUtil.replace_invalid_utf8(e.message.dup))) |
|
72 | flash[:error] = l(:notice_email_error, ERB::Util.h(Redmine::CodesetUtil.replace_invalid_utf8(e.message.dup))) | |
73 | end |
|
73 | end | |
74 | ActionMailer::Base.raise_delivery_errors = raise_delivery_errors |
|
74 | ActionMailer::Base.raise_delivery_errors = raise_delivery_errors | |
75 | redirect_to settings_path(:tab => 'notifications') |
|
75 | redirect_to settings_path(:tab => 'notifications') | |
76 | end |
|
76 | end | |
77 |
|
77 | |||
78 | def info |
|
78 | def info | |
79 | @db_adapter_name = ActiveRecord::Base.connection.adapter_name |
|
|||
80 | @checklist = [ |
|
79 | @checklist = [ | |
81 | [:text_default_administrator_account_changed, User.default_admin_account_changed?], |
|
80 | [:text_default_administrator_account_changed, User.default_admin_account_changed?], | |
82 | [:text_file_repository_writable, File.writable?(Attachment.storage_path)], |
|
81 | [:text_file_repository_writable, File.writable?(Attachment.storage_path)], | |
83 | ["#{l :text_plugin_assets_writable} (./public/plugin_assets)", File.writable?(Redmine::Plugin.public_directory)], |
|
82 | ["#{l :text_plugin_assets_writable} (./public/plugin_assets)", File.writable?(Redmine::Plugin.public_directory)], | |
84 | [:text_rmagick_available, Object.const_defined?(:Magick)], |
|
83 | [:text_rmagick_available, Object.const_defined?(:Magick)], | |
85 | [:text_convert_available, Redmine::Thumbnail.convert_available?] |
|
84 | [:text_convert_available, Redmine::Thumbnail.convert_available?] | |
86 | ] |
|
85 | ] | |
87 | end |
|
86 | end | |
88 | end |
|
87 | end |
General Comments 0
You need to be logged in to leave comments.
Login now