You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

admin_controller.rb 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006- Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. class AdminController < ApplicationController
  19. layout 'admin'
  20. self.main_menu = false
  21. menu_item :projects, :only => :projects
  22. menu_item :plugins, :only => :plugins
  23. menu_item :info, :only => :info
  24. before_action :require_admin
  25. helper :queries
  26. include QueriesHelper
  27. helper :projects_queries
  28. helper :projects
  29. def index
  30. @no_configuration_data = Redmine::DefaultData::Loader::no_data?
  31. end
  32. def projects
  33. retrieve_query(ProjectQuery, false, :defaults => @default_columns_names)
  34. @query.admin_projects = 1
  35. scope = @query.results_scope
  36. @entry_count = scope.count
  37. @entry_pages = Paginator.new @entry_count, per_page_option, params['page']
  38. @projects = scope.limit(@entry_pages.per_page).offset(@entry_pages.offset).to_a
  39. render :action => "projects", :layout => false if request.xhr?
  40. end
  41. def plugins
  42. @plugins = Redmine::Plugin.all
  43. end
  44. # Loads the default configuration
  45. # (roles, trackers, statuses, workflow, enumerations)
  46. def default_configuration
  47. if request.post?
  48. begin
  49. Redmine::DefaultData::Loader::load(params[:lang])
  50. flash[:notice] = l(:notice_default_data_loaded)
  51. rescue => e
  52. flash[:error] = l(:error_can_t_load_default_data, ERB::Util.h(e.message))
  53. end
  54. end
  55. redirect_to admin_path
  56. end
  57. def test_email
  58. begin
  59. Mailer.deliver_test_email(User.current)
  60. flash[:notice] = l(:notice_email_sent, ERB::Util.h(User.current.mail))
  61. rescue => e
  62. flash[:error] = l(:notice_email_error, ERB::Util.h(Redmine::CodesetUtil.replace_invalid_utf8(e.message.dup)))
  63. end
  64. redirect_to settings_path(:tab => 'notifications')
  65. end
  66. def info
  67. @checklist = [
  68. [:text_default_administrator_account_changed, User.default_admin_account_changed?],
  69. [:text_file_repository_writable, File.writable?(Attachment.storage_path)],
  70. [:text_all_migrations_have_been_run, !ActiveRecord::Base.connection.migration_context.needs_migration?],
  71. [:text_minimagick_available, Object.const_defined?(:MiniMagick)],
  72. [:text_convert_available, Redmine::Thumbnail.convert_available?],
  73. [:text_gs_available, Redmine::Thumbnail.gs_available?]
  74. ]
  75. @checklist << [:text_default_active_job_queue_changed, Rails.application.config.active_job.queue_adapter != :async] if Rails.env.production?
  76. end
  77. end