From 399e8c3ed99a4a5c10ab6f49c16065ebc6ac39ad Mon Sep 17 00:00:00 2001 From: ulferts Date: Sat, 15 Feb 2020 00:53:51 +0100 Subject: [PATCH] rename according to zeitwerk --- .../openproject/_variables.scss.erb | 6 +- app/helpers/application_helper.rb | 2 +- app/models/design_color.rb | 6 +- app/models/work_package/exporter/pdf.rb | 4 +- .../work_package/pdf_export/attachments.rb | 2 +- app/models/work_package/pdf_export/common.rb | 4 +- .../work_package/pdf_export/to_pdf_helper.rb | 4 +- app/models/work_package/pdf_export/view.rb | 2 +- .../pdf_export/work_package_list_to_pdf.rb | 6 +- .../pdf_export/work_package_to_pdf.rb | 6 +- .../work_packages/shared/update_attributes.rb | 0 app/uploaders/fog_file_uploader.rb | 1 - app/views/common/_favicons.html.erb | 2 +- config/initializers/10-patches.rb | 11 ++ config/initializers/doorkeeper.rb | 7 +- config/initializers/reform.rb | 3 - config/initializers/zeitwerk.rb | 14 +- ...0120550_migrate_light_background_themes.rb | 2 +- lib/extended_http.rb | 52 ----- .../open_project/plugin/plugin_generator.rb | 2 +- lib/open_project.rb | 1 - lib/open_project/custom_styles/design.rb | 2 +- .../hooks/view_account_login_auth_provider.rb | 2 +- lib/open_project/patches/array.rb | 8 + lib/open_project/patches/carrierwave.rb | 2 +- .../patches/string.rb} | 43 +++-- .../formats/markdown/pandoc_wrapper.rb | 1 - .../formats/markdown/textile_converter.rb | 1 - lib/redmine/core_ext.rb | 30 --- lib/redmine/core_ext/string.rb | 36 ---- lib/redmine/diff/array_string_diff.rb | 179 ++++++++++++++++++ lib/redmine/diff/diffable.rb | 123 ++++++++++++ lib/redmine/version.rb | 33 ---- .../flexible_builder.rb | 0 .../flexible_strategy.rb | 16 +- .../lib/open_project/auth_plugins.rb | 4 +- .../lib/open_project/avatars/engine.rb | 4 +- ...b_export_card_configurations_controller.rb | 4 +- .../app/controllers/rb_stories_controller.rb | 2 +- .../{ => basic_data/backlogs}/role_seeder.rb | 0 .../backlogs}/setting_seeder.rb | 0 .../basic_data/backlogs/type_seeder.rb | 23 +++ modules/backlogs/app/seeders/type_seeder.rb | 25 --- .../backlogs/hooks/user_settings_hook.rb | 2 +- .../open_project/bim/patches/design_patch.rb | 6 +- .../{ => basic_data/boards}/role_seeder.rb | 0 .../{ => basic_data/costs}/type_seeder.rb | 0 .../costs/hooks/work_package_action_menu.rb | 2 +- .../hooks/work_packages_show_attributes.rb | 2 +- .../documents}/enumeration_seeder.rb | 2 +- .../{ => basic_data/documents}/role_seeder.rb | 0 .../lib/open_project/documents/engine.rb | 5 - ...ting_patch.rb => colon_separator_patch.rb} | 27 --- .../documents/patches/hash_separator_patch.rb | 31 ++- .../open_project/openid_connect/sso_logout.rb | 2 +- .../app/seeders/demo_data/overview_seeder.rb | 105 ++++++++++ .../overviews/app/seeders/overview_seeder.rb | 107 ----------- .../app/models/export_card_configuration.rb | 2 +- .../pdf_export/lib/open_project/pdf_export.rb | 2 +- .../lib/open_project/pdf_export/engine.rb | 2 +- .../lib/open_project/pdf_export/exceptions.rb | 2 +- .../pdf_export/export_card/card_element.rb | 4 +- .../pdf_export/export_card/column_element.rb | 2 +- .../export_card/document_generator.rb | 6 +- .../pdf_export/export_card/group_element.rb | 4 +- .../model_display/work_package_display.rb | 8 +- .../pdf_export/export_card/row_element.rb | 4 +- .../export_card/document_generator_spec.rb | 6 +- .../lib/open_project/recaptcha/recaptcha.rb | 5 - .../helpers => }/reporting_helper.rb | 0 .../reporting_engine/lib/reporting_widget.rb | 2 +- .../set_default_device_service.rb | 95 ---------- .../two_factor_authentication.rb | 5 - .../xls_export/hooks/cost_report_hook.rb | 3 +- .../xls_export/hooks/work_package_hook.rb | 4 +- .../lib/open_project/xls_export/xls_views.rb | 3 - ...entry_table.xls.rb => cost_entry_table.rb} | 0 spec/lib/open_project/design_spec.rb | 4 +- spec/lib/open_project/scm/manager_spec.rb | 2 +- spec/models/design_color_spec.rb | 2 +- spec/views/layouts/base.html.erb_spec.rb | 2 +- spec_legacy/unit/activity_spec.rb | 2 +- spec_legacy/unit/lib/redmine/plugin_spec.rb | 7 +- 83 files changed, 601 insertions(+), 543 deletions(-) delete mode 100644 app/services/work_packages/shared/update_attributes.rb delete mode 100644 lib/extended_http.rb create mode 100644 lib/open_project/patches/array.rb rename lib/{redmine/core_ext/string/conversions.rb => open_project/patches/string.rb} (62%) delete mode 100644 lib/redmine/core_ext.rb delete mode 100644 lib/redmine/core_ext/string.rb create mode 100644 lib/redmine/diff/array_string_diff.rb create mode 100644 lib/redmine/diff/diffable.rb delete mode 100644 lib/redmine/version.rb rename modules/auth_plugins/lib/{omniauth => omni_auth}/flexible_builder.rb (100%) rename modules/auth_plugins/lib/{omniauth => omni_auth}/flexible_strategy.rb (100%) rename modules/backlogs/app/seeders/{ => basic_data/backlogs}/role_seeder.rb (100%) rename modules/backlogs/app/seeders/{ => basic_data/backlogs}/setting_seeder.rb (100%) create mode 100644 modules/backlogs/app/seeders/basic_data/backlogs/type_seeder.rb delete mode 100644 modules/backlogs/app/seeders/type_seeder.rb rename modules/boards/app/seeders/{ => basic_data/boards}/role_seeder.rb (100%) rename modules/costs/app/seeders/{ => basic_data/costs}/type_seeder.rb (100%) rename modules/documents/app/seeders/{ => basic_data/documents}/enumeration_seeder.rb (97%) rename modules/documents/app/seeders/{ => basic_data/documents}/role_seeder.rb (100%) rename modules/documents/lib/open_project/documents/patches/{text_formatting_patch.rb => colon_separator_patch.rb} (74%) rename lib/redmine/core_ext/string/inflections.rb => modules/documents/lib/open_project/documents/patches/hash_separator_patch.rb (63%) create mode 100644 modules/overviews/app/seeders/demo_data/overview_seeder.rb delete mode 100644 modules/overviews/app/seeders/overview_seeder.rb delete mode 100644 modules/recaptcha/lib/open_project/recaptcha/recaptcha.rb rename modules/reporting_engine/lib/{reporting_engine/helpers => }/reporting_helper.rb (100%) delete mode 100644 modules/two_factor_authentication/app/services/two_factor_authentication/set_default_device_service.rb delete mode 100644 modules/two_factor_authentication/lib/open_project/two_factor_authentication/two_factor_authentication.rb rename modules/xls_export/lib/open_project/xls_export/xls_views/{cost_entry_table.xls.rb => cost_entry_table.rb} (100%) diff --git a/app/assets/stylesheets/openproject/_variables.scss.erb b/app/assets/stylesheets/openproject/_variables.scss.erb index 6a28a3ecce..904ef01060 100644 --- a/app/assets/stylesheets/openproject/_variables.scss.erb +++ b/app/assets/stylesheets/openproject/_variables.scss.erb @@ -11,12 +11,12 @@ primary-color-dark alternative-color This allows us to dynamically define CSS4 + Sass variables from a single map %> -<% ::OpenProject::Design.variables.each do |var, hexcode| %> +<% ::OpenProject::CustomStyles::Design.variables.each do |var, hexcode| %> $<%= var %>: <%= hexcode %>; <% end %> :root { -<% ::OpenProject::Design.variables.each do |var, definition| %> +<% ::OpenProject::CustomStyles::Design.variables.each do |var, definition| %> <% css4definition = definition.gsub(/\$([\w-]+)/, 'var(--\1)') %> --<%= var %>: <%= css4definition %>; <% end %> @@ -24,7 +24,7 @@ $<%= var %>: <%= hexcode %>; <%# Construct a sass map to lookup variables in the mixin below %> $variable-map: ( -<% ::OpenProject::Design.variables.each do |var, definition| %> +<% ::OpenProject::CustomStyles::Design.variables.each do |var, definition| %> <%= var %>: #{<%= definition %>}, <% end %> ); diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ddb0a42f7c..7d02ff0bbb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -301,7 +301,7 @@ module ApplicationHelper # Returns the theme, controller name, and action as css classes for the # HTML body. def body_css_classes - css = ['theme-' + OpenProject::Design.identifier.to_s] + css = ['theme-' + OpenProject::CustomStyles::Design.identifier.to_s] if params[:controller] && params[:action] css << 'controller-' + params[:controller] diff --git a/app/models/design_color.rb b/app/models/design_color.rb index f049ce70f0..6d417de759 100644 --- a/app/models/design_color.rb +++ b/app/models/design_color.rb @@ -47,19 +47,19 @@ class DesignColor < ActiveRecord::Base class << self def defaults - OpenProject::Design.resolved_variables + OpenProject::CustomStyles::Design.resolved_variables end def setables overwritten_values = self.overwritten - OpenProject::Design.customizable_variables.map do |varname| + OpenProject::CustomStyles::Design.customizable_variables.map do |varname| overwritten_value = overwritten_values.detect { |var| var.variable == varname } overwritten_value || new(variable: varname) end end def overwritten - overridable = OpenProject::Design.customizable_variables + overridable = OpenProject::CustomStyles::Design.customizable_variables all.to_a.select do |color| overridable.include?(color.variable) && self.defaults[color] != color.get_hexcode diff --git a/app/models/work_package/exporter/pdf.rb b/app/models/work_package/exporter/pdf.rb index 6ce7512505..5cabc474bf 100644 --- a/app/models/work_package/exporter/pdf.rb +++ b/app/models/work_package/exporter/pdf.rb @@ -31,7 +31,7 @@ class WorkPackage::Exporter::PDF < WorkPackage::Exporter::Base # Returns a PDF string of a list of work_packages def list - yield ::WorkPackage::PdfExport::WorkPackageListToPdf + yield ::WorkPackage::PDFExport::WorkPackageListToPdf .new(query, options) .render! @@ -39,7 +39,7 @@ class WorkPackage::Exporter::PDF < WorkPackage::Exporter::Base # Returns a PDF string of a single work_package def single - yield ::WorkPackage::PdfExport::WorkPackageToPdf + yield ::WorkPackage::PDFExport::WorkPackageToPdf .new(work_package) .render! end diff --git a/app/models/work_package/pdf_export/attachments.rb b/app/models/work_package/pdf_export/attachments.rb index c7f1e14e85..b23afecd21 100644 --- a/app/models/work_package/pdf_export/attachments.rb +++ b/app/models/work_package/pdf_export/attachments.rb @@ -28,7 +28,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -module WorkPackage::PdfExport::Attachments +module WorkPackage::PDFExport::Attachments ## # Creates cells for each attachment of the work package # diff --git a/app/models/work_package/pdf_export/common.rb b/app/models/work_package/pdf_export/common.rb index 893cf63225..1044c43eff 100644 --- a/app/models/work_package/pdf_export/common.rb +++ b/app/models/work_package/pdf_export/common.rb @@ -28,12 +28,12 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -module WorkPackage::PdfExport::Common +module WorkPackage::PDFExport::Common include Redmine::I18n include ActionView::Helpers::TextHelper include ActionView::Helpers::NumberHelper include CustomFieldsHelper - include WorkPackage::PdfExport::ToPdfHelper + include WorkPackage::PDFExport::ToPdfHelper include OpenProject::TextFormatting private diff --git a/app/models/work_package/pdf_export/to_pdf_helper.rb b/app/models/work_package/pdf_export/to_pdf_helper.rb index 15438d27b6..da68511210 100644 --- a/app/models/work_package/pdf_export/to_pdf_helper.rb +++ b/app/models/work_package/pdf_export/to_pdf_helper.rb @@ -27,8 +27,8 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -module WorkPackage::PdfExport::ToPdfHelper +module WorkPackage::PDFExport::ToPdfHelper def get_pdf(language) - ::WorkPackage::PdfExport::View.new(current_language) + ::WorkPackage::PDFExport::View.new(current_language) end end diff --git a/app/models/work_package/pdf_export/view.rb b/app/models/work_package/pdf_export/view.rb index c3f702c8fd..bf974f3f8c 100644 --- a/app/models/work_package/pdf_export/view.rb +++ b/app/models/work_package/pdf_export/view.rb @@ -27,7 +27,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -class WorkPackage::PdfExport::View +class WorkPackage::PDFExport::View include Prawn::View include Redmine::I18n diff --git a/app/models/work_package/pdf_export/work_package_list_to_pdf.rb b/app/models/work_package/pdf_export/work_package_list_to_pdf.rb index dcfbb103df..890f997c7e 100644 --- a/app/models/work_package/pdf_export/work_package_list_to_pdf.rb +++ b/app/models/work_package/pdf_export/work_package_list_to_pdf.rb @@ -28,9 +28,9 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -class WorkPackage::PdfExport::WorkPackageListToPdf < WorkPackage::Exporter::Base - include WorkPackage::PdfExport::Common - include WorkPackage::PdfExport::Attachments +class WorkPackage::PDFExport::WorkPackageListToPdf < WorkPackage::Exporter::Base + include WorkPackage::PDFExport::Common + include WorkPackage::PDFExport::Attachments attr_accessor :pdf, :options diff --git a/app/models/work_package/pdf_export/work_package_to_pdf.rb b/app/models/work_package/pdf_export/work_package_to_pdf.rb index ce1f712e0e..7d9b4b5ad9 100644 --- a/app/models/work_package/pdf_export/work_package_to_pdf.rb +++ b/app/models/work_package/pdf_export/work_package_to_pdf.rb @@ -28,9 +28,9 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -class WorkPackage::PdfExport::WorkPackageToPdf < WorkPackage::Exporter::Base - include WorkPackage::PdfExport::Common - include WorkPackage::PdfExport::Attachments +class WorkPackage::PDFExport::WorkPackageToPdf < WorkPackage::Exporter::Base + include WorkPackage::PDFExport::Common + include WorkPackage::PDFExport::Attachments attr_accessor :pdf diff --git a/app/services/work_packages/shared/update_attributes.rb b/app/services/work_packages/shared/update_attributes.rb deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/app/uploaders/fog_file_uploader.rb b/app/uploaders/fog_file_uploader.rb index 6a37378f87..0a6ff8487f 100644 --- a/app/uploaders/fog_file_uploader.rb +++ b/app/uploaders/fog_file_uploader.rb @@ -27,7 +27,6 @@ #++ require 'carrierwave/storage/fog' -require 'open_project/patches/carrierwave' class FogFileUploader < CarrierWave::Uploader::Base include FileUploader diff --git a/app/views/common/_favicons.html.erb b/app/views/common/_favicons.html.erb index 3f0bc045e8..2e3c5e1cb4 100644 --- a/app/views/common/_favicons.html.erb +++ b/app/views/common/_favicons.html.erb @@ -1,5 +1,5 @@ <% unless (EnterpriseToken.allows_to?(:define_custom_style) && CustomStyle.try(:current).present? && CustomStyle.current.favicon.present?) %> - <%= favicon_link_tag OpenProject::Design.favicon_asset_path %> + <%= favicon_link_tag OpenProject::CustomStyles::Design.favicon_asset_path %> <% end %> <% unless (EnterpriseToken.allows_to?(:define_custom_style) && CustomStyle.try(:current).present? && CustomStyle.current.touch_icon.present?) %> diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index 5df7ca861f..ea46d0a24e 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -150,3 +150,14 @@ end # Patch acts_as_list before any class includes the module require 'open_project/patches/acts_as_list' + +# Patch String to have some helper methods +require 'open_project/patches/string' + +# Patch Array to have some helper methods +require 'open_project/patches/array' + +# Patch carrierwave to support custom access key validity (to be removed once carrierwave is bumped to 2) +require 'open_project/patches/carrierwave' + +require 'open_project/patches/reform' diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb index 9220e94a34..5c6844dcbc 100644 --- a/config/initializers/doorkeeper.rb +++ b/config/initializers/doorkeeper.rb @@ -211,6 +211,11 @@ end OpenProject::Application.configure do |application| application.config.to_prepare do - # ::Doorkeeper::AuthorizationsController.layout "only_logo" + # Requiring some classes of Doorkeeper ourselves which for whatever reasons are + # no longer loaded for us now that we use zeitwerk + require 'doorkeeper/application_metal_controller' + require 'doorkeeper/application_controller' + require 'doorkeeper/tokens_controller' + require 'doorkeeper/authorizations_controller' end end diff --git a/config/initializers/reform.rb b/config/initializers/reform.rb index 8bd122a5f2..bc83a8e674 100644 --- a/config/initializers/reform.rb +++ b/config/initializers/reform.rb @@ -47,11 +47,8 @@ Reform::Form::ActiveModel::Validations::Validator.class_eval do end end - require 'reform/contract' -require 'open_project/patches/reform' - class Reform::Form::ActiveModel::Errors prepend OpenProject::Patches::Reform end diff --git a/config/initializers/zeitwerk.rb b/config/initializers/zeitwerk.rb index ddccf606f8..91558a4f20 100644 --- a/config/initializers/zeitwerk.rb +++ b/config/initializers/zeitwerk.rb @@ -6,15 +6,20 @@ module OpenProject class Inflector < Zeitwerk::GemInflector + # TODO: split up into a registry def camelize(basename, abspath) if basename =~ /\A(.*)_api\z/ super($1, abspath) + 'API' elsif basename =~ /\Aoauth_(.*)\z/ 'OAuth' + super($1, abspath) + elsif basename =~ /\A(.*)_oauth\z/ + super($1, abspath) + 'OAuth' elsif basename =~ /\A(.*)_sso\z/ super($1, abspath) + 'SSO' elsif basename =~ /\Aar_(.*)\z/ 'AR' + super($1, abspath) + elsif basename =~ /\Apdf_export\z/ + 'PDFExport' elsif abspath =~ /open_project\/version(\.rb)?\z/ "VERSION" else @@ -34,10 +39,15 @@ Rails.autoloaders.each do |autoloader| 'sso' => 'SSO', 'csv' => 'CSV', 'pdf' => 'PDF', - 'scm' => 'SCM' + 'scm' => 'SCM', + 'imap' => 'IMAP', + 'pop3' => 'POP3', + 'openid_connect' => 'OpenIDConnect' ) end # Instruct zeitwerk to ignore all the engine gems' lib initialization files Rails.autoloaders.main.ignore(Rails.root.join('modules/*/lib/openproject-*.rb')) -Rails.autoloaders.main.ignore(Bundler.bundle_path.join('**/lib/openproject-*.rb')) +Rails.autoloaders.main.ignore(Rails.root.join('lib/plugins')) +Rails.autoloaders.main.ignore(Rails.root.join('lib/generators')) +Rails.autoloaders.main.ignore(Bundler.bundle_path.join('**/*.rb')) diff --git a/db/migrate/20180830120550_migrate_light_background_themes.rb b/db/migrate/20180830120550_migrate_light_background_themes.rb index 8ff9c7c492..4e3dcb6747 100644 --- a/db/migrate/20180830120550_migrate_light_background_themes.rb +++ b/db/migrate/20180830120550_migrate_light_background_themes.rb @@ -55,7 +55,7 @@ class MigrateLightBackgroundThemes < ActiveRecord::Migration[5.1] main-menu-bg-hover-background main-menu-hover-font-color main-menu-border-color ).each do |variable_name| - return false unless OpenProject::Design.customizable_variables.include? variable_name + return false unless OpenProject::CustomStyles::Design.customizable_variables.include? variable_name end # Never ever overwrite variables that were already set. diff --git a/lib/extended_http.rb b/lib/extended_http.rb deleted file mode 100644 index df252a9b4c..0000000000 --- a/lib/extended_http.rb +++ /dev/null @@ -1,52 +0,0 @@ -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) 2012-2020 the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2017 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See docs/COPYRIGHT.rdoc for more details. -#++ - -module ExtendedHTTP - # Use this in response to an HTTP POST (or PUT), telling the client where the - # new resource is. Works just like redirect_to, but sends back a 303 (See - # Other) status code. Redirects should be used to tell the client to repeat - # the same request on a different resource, and see_other when we want the - # client to follow a POST (on this resource) with a GET (to the new resource). - # - # This is especially useful for successful create actions. - def see_other(options = {}) - if options.is_a?(Hash) - redirect_to options.merge(status: :see_other) - else - redirect_to options, status: :see_other - end - end - - # Use this in response to an HTTP PUT (or POST), telling the client that - # everything went well and the desired change was performed successfully. - # - # This is especially useful for successful update actions. - def no_content - render body: '', status: :no_content - end -end diff --git a/lib/generators/open_project/plugin/plugin_generator.rb b/lib/generators/open_project/plugin/plugin_generator.rb index f0fdb27e79..cb2006b926 100644 --- a/lib/generators/open_project/plugin/plugin_generator.rb +++ b/lib/generators/open_project/plugin/plugin_generator.rb @@ -28,7 +28,7 @@ require 'rails/generators' -class OpenProject::PluginGenerator < Rails::Generators::Base +class Generators::OpenProject::Plugin::PluginGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) argument :plugin_name, type: :string, default: 'openproject-new-plugin' diff --git a/lib/open_project.rb b/lib/open_project.rb index 8dc3800eb9..4f980a00bb 100644 --- a/lib/open_project.rb +++ b/lib/open_project.rb @@ -34,7 +34,6 @@ require 'redmine/search' require 'open_project/custom_field_format' require 'open_project/logging/log_delegator' require 'redmine/mime_type' -require 'redmine/core_ext' require 'open_project/custom_styles/design' require 'redmine/hook' require 'open_project/hooks' diff --git a/lib/open_project/custom_styles/design.rb b/lib/open_project/custom_styles/design.rb index d19a731672..085fdb79fa 100644 --- a/lib/open_project/custom_styles/design.rb +++ b/lib/open_project/custom_styles/design.rb @@ -27,7 +27,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -module OpenProject +module OpenProject::CustomStyles class Design DEFAULTS = { 'primary-color' => "#1A67A3", diff --git a/lib/open_project/hooks/view_account_login_auth_provider.rb b/lib/open_project/hooks/view_account_login_auth_provider.rb index 6bbce16332..9b7ca2b825 100644 --- a/lib/open_project/hooks/view_account_login_auth_provider.rb +++ b/lib/open_project/hooks/view_account_login_auth_provider.rb @@ -30,7 +30,7 @@ module OpenProject module Hooks ## # Hook called in the login forms which displays the different auth providers - class ViewAccountLoginAuthProviderHook < Redmine::Hook::ViewListener + class ViewAccountLoginAuthProvider < Redmine::Hook::ViewListener render_on :view_account_login_auth_provider, partial: 'hooks/login/auth_provider' end diff --git a/lib/open_project/patches/array.rb b/lib/open_project/patches/array.rb new file mode 100644 index 0000000000..86b13c6f2e --- /dev/null +++ b/lib/open_project/patches/array.rb @@ -0,0 +1,8 @@ +module OpenProject + module Patches + module Array + end + end +end + +Array.send(:include, Redmine::Diff::Diffable) diff --git a/lib/open_project/patches/carrierwave.rb b/lib/open_project/patches/carrierwave.rb index f80f74aeef..aec0c69f92 100644 --- a/lib/open_project/patches/carrierwave.rb +++ b/lib/open_project/patches/carrierwave.rb @@ -1,4 +1,4 @@ -require 'carrierwave' +require 'carrierwave/storage/fog' ## # Code copied straight from the CarrierWave source. diff --git a/lib/redmine/core_ext/string/conversions.rb b/lib/open_project/patches/string.rb similarity index 62% rename from lib/redmine/core_ext/string/conversions.rb rename to lib/open_project/patches/string.rb index 951e93a4ab..eff7c2b580 100644 --- a/lib/redmine/core_ext/string/conversions.rb +++ b/lib/open_project/patches/string.rb @@ -27,28 +27,33 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -module Redmine #:nodoc: - module CoreExtensions #:nodoc: +module OpenProject + module Patches module String #:nodoc: - # Custom string conversions - module Conversions - # Parses hours format and returns a float - def to_hours - s = dup - s.strip! - if s =~ %r{^(\d+([.,]\d+)?)h?$} - s = $1 - else - # 230: 2.5 - s.gsub!(%r{^(\d+):(\d+)$}) do $1.to_i + $2.to_i / 60.0 end - # 2h30, 2h, 30m => 2.5, 2, 0.5 - s.gsub!(%r{^((\d+)\s*(h|hours?))?\s*((\d+)\s*(m|min)?)?$}) { |m| ($1 || $4) ? ($2.to_i + $5.to_i / 60.0) : m[0] } - end - # 2,5 => 2.5 - s.gsub!(',', '.') - begin; Kernel.Float(s); rescue; nil; end + # Parses hours format and returns a float + def to_hours + s = dup + s.strip! + if s =~ %r{^(\d+([.,]\d+)?)h?$} + s = $1 + else + # 230: 2.5 + s.gsub!(%r{^(\d+):(\d+)$}) do $1.to_i + $2.to_i / 60.0 end + # 2h30, 2h, 30m => 2.5, 2, 0.5 + s.gsub!(%r{^((\d+)\s*(h|hours?))?\s*((\d+)\s*(m|min)?)?$}) { |m| ($1 || $4) ? ($2.to_i + $5.to_i / 60.0) : m[0] } end + # 2,5 => 2.5 + s.gsub!(',', '.') + begin; Kernel.Float(s); rescue; nil; end + end + + # TODO: Check if this can be deleted + def with_leading_slash + starts_with?('/') ? self : "/#{self}" end end end end + +String.send(:include, OpenProject::Patches::String) +String.send(:include, Redmine::Diff::Diffable) diff --git a/lib/open_project/text_formatting/formats/markdown/pandoc_wrapper.rb b/lib/open_project/text_formatting/formats/markdown/pandoc_wrapper.rb index 924b5b6b87..1ce784f0b2 100644 --- a/lib/open_project/text_formatting/formats/markdown/pandoc_wrapper.rb +++ b/lib/open_project/text_formatting/formats/markdown/pandoc_wrapper.rb @@ -33,7 +33,6 @@ require 'posix-spawn' module OpenProject::TextFormatting::Formats module Markdown class PandocWrapper - attr_reader :logger def initialize(logger = ::Logger.new(STDOUT)) diff --git a/lib/open_project/text_formatting/formats/markdown/textile_converter.rb b/lib/open_project/text_formatting/formats/markdown/textile_converter.rb index 0f3bafd673..a07d1eda42 100644 --- a/lib/open_project/text_formatting/formats/markdown/textile_converter.rb +++ b/lib/open_project/text_formatting/formats/markdown/textile_converter.rb @@ -53,7 +53,6 @@ # SOFTWARE. require 'ruby-progressbar' -require_relative 'pandoc_wrapper' module OpenProject::TextFormatting::Formats module Markdown diff --git a/lib/redmine/core_ext.rb b/lib/redmine/core_ext.rb deleted file mode 100644 index 10a605224f..0000000000 --- a/lib/redmine/core_ext.rb +++ /dev/null @@ -1,30 +0,0 @@ -#-- encoding: UTF-8 -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) 2012-2020 the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2017 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See docs/COPYRIGHT.rdoc for more details. -#++ - -Dir[File.dirname(__FILE__) + '/core_ext/*.rb'].each { |file| require(file) } diff --git a/lib/redmine/core_ext/string.rb b/lib/redmine/core_ext/string.rb deleted file mode 100644 index 21a05327df..0000000000 --- a/lib/redmine/core_ext/string.rb +++ /dev/null @@ -1,36 +0,0 @@ -#-- encoding: UTF-8 -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) 2012-2020 the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2017 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See docs/COPYRIGHT.rdoc for more details. -#++ - -require File.dirname(__FILE__) + '/string/conversions' -require File.dirname(__FILE__) + '/string/inflections' - -class String #:nodoc: - include Redmine::CoreExtensions::String::Conversions - include Redmine::CoreExtensions::String::Inflections -end diff --git a/lib/redmine/diff/array_string_diff.rb b/lib/redmine/diff/array_string_diff.rb new file mode 100644 index 0000000000..1cba92d115 --- /dev/null +++ b/lib/redmine/diff/array_string_diff.rb @@ -0,0 +1,179 @@ +# = Diff +# (({diff.rb})) - computes the differences between two arrays or +# strings. Copyright (C) 2001 Lars Christensen +# +# == Synopsis +# +# diff = Diff.new(a, b) +# b = a.patch(diff) +# +# == Class Diff +# === Class Methods +# --- Diff.new(a, b) +# --- a.diff(b) +# Creates a Diff object which represent the differences between +# ((|a|)) and ((|b|)). ((|a|)) and ((|b|)) can be either be arrays +# of any objects, strings, or object of any class that include +# module ((|Diffable|)) +# +# == Module Diffable +# The module ((|Diffable|)) is intended to be included in any class for +# which differences are to be computed. Diffable is included into String +# and Array when (({diff.rb})) is (({require}))'d. +# +# Classes including Diffable should implement (({[]})) to get element at +# integer indices, (({<<})) to append elements to the object and +# (({ClassName#new})) should accept 0 arguments to create a new empty +# object. +# +# === Instance Methods +# --- Diffable#patch(diff) +# Applies the differences from ((|diff|)) to the object ((|obj|)) +# and return the result. ((|obj|)) is not changed. ((|obj|)) and +# can be either an array or a string, but must match the object +# from which the ((|diff|)) was created. + +class Redmine::Diff::ArrayStringDiff + VERSION = 0.3 + + def self.lcs(a, b) + astart = 0 + bstart = 0 + afinish = a.length - 1 + bfinish = b.length - 1 + mvector = [] + + # First we prune off any common elements at the beginning + while astart <= afinish && bstart <= afinish && a[astart] == b[bstart] + mvector[astart] = bstart + astart += 1 + bstart += 1 + end + + # now the end + while astart <= afinish && bstart <= bfinish && a[afinish] == b[bfinish] + mvector[afinish] = bfinish + afinish -= 1 + bfinish -= 1 + end + + bmatches = b.reverse_hash(bstart..bfinish) + thresh = [] + links = [] + + (astart..afinish).each do |aindex| + aelem = a[aindex] + next unless bmatches.has_key? aelem + k = nil + bmatches[aelem].reverse_each { |bindex| + if k && (thresh[k] > bindex) && (thresh[k - 1] < bindex) + thresh[k] = bindex + else + k = thresh.replacenextlarger(bindex, k) + end + links[k] = [(k == 0) ? nil : links[k - 1], aindex, bindex] if k + } + end + + if !thresh.empty? + link = links[thresh.length - 1] + while link + mvector[link[1]] = link[2] + link = link[0] + end + end + + mvector + end + + def makediff(a, b) + mvector = self.class.lcs(a, b) + ai = bi = 0 + while ai < mvector.length + bline = mvector[ai] + if bline + while bi < bline + discardb(bi, b[bi]) + bi += 1 + end + match(ai, bi) + bi += 1 + else + discarda(ai, a[ai]) + end + ai += 1 + end + while ai < a.length + discarda(ai, a[ai]) + ai += 1 + end + while bi < b.length + discardb(bi, b[bi]) + bi += 1 + end + match(ai, bi) + 1 + end + + def compactdiffs + diffs = [] + @diffs.each do |df| + i = 0 + curdiff = [] + while i < df.length + whot = df[i][0] + s = @isstring ? df[i][2].chr : [df[i][2]] + p = df[i][1] + last = df[i][1] + i += 1 + while df[i] && df[i][0] == whot && df[i][1] == last + 1 + s << df[i][2] + last = df[i][1] + i += 1 + end + curdiff.push [whot, p, s] + end + diffs.push curdiff + end + diffs + end + + attr_reader :diffs, :difftype + + def initialize(diffs_or_a, b = nil, isstring = nil) + if b.nil? + @diffs = diffs_or_a + @isstring = isstring + else + @diffs = [] + @curdiffs = [] + makediff(diffs_or_a, b) + @difftype = diffs_or_a.class + end + end + + def match(_ai, _bi) + @diffs.push @curdiffs unless @curdiffs.empty? + @curdiffs = [] + end + + def discarda(i, elem) + @curdiffs.push ['-', i, elem] + end + + def discardb(i, elem) + @curdiffs.push ['+', i, elem] + end + + def compact + Diff.new(compactdiffs) + end + + def compact! + @diffs = compactdiffs + end + + def inspect + @diffs.inspect + end +end diff --git a/lib/redmine/diff/diffable.rb b/lib/redmine/diff/diffable.rb new file mode 100644 index 0000000000..30c6adeb49 --- /dev/null +++ b/lib/redmine/diff/diffable.rb @@ -0,0 +1,123 @@ +# = Diff +# (({diff.rb})) - computes the differences between two arrays or +# strings. Copyright (C) 2001 Lars Christensen +# +# == Synopsis +# +# diff = Diff.new(a, b) +# b = a.patch(diff) +# +# == Class Diff +# === Class Methods +# --- Diff.new(a, b) +# --- a.diff(b) +# Creates a Diff object which represent the differences between +# ((|a|)) and ((|b|)). ((|a|)) and ((|b|)) can be either be arrays +# of any objects, strings, or object of any class that include +# module ((|Diffable|)) +# +# == Module Diffable +# The module ((|Diffable|)) is intended to be included in any class for +# which differences are to be computed. Diffable is included into String +# and Array when (({diff.rb})) is (({require}))'d. +# +# Classes including Diffable should implement (({[]})) to get element at +# integer indices, (({<<})) to append elements to the object and +# (({ClassName#new})) should accept 0 arguments to create a new empty +# object. +# +# === Instance Methods +# --- Diffable#patch(diff) +# Applies the differences from ((|diff|)) to the object ((|obj|)) +# and return the result. ((|obj|)) is not changed. ((|obj|)) and +# can be either an array or a string, but must match the object +# from which the ((|diff|)) was created. + +module Redmine::Diff::Diffable + def diff(b) + Redmine::Diff::ArrayStringDiff.new(self, b) + end + + # Create a hash that maps elements of the array to arrays of indices + # where the elements are found. + + def reverse_hash(range = (0...length)) + revmap = {} + range.each do |i| + elem = self[i] + if revmap.has_key? elem + revmap[elem].push i + else + revmap[elem] = [i] + end + end + revmap + end + + def replacenextlarger(value, high = nil) + high ||= length + if self.empty? || value > self[-1] + push value + return high + end + # binary search for replacement point + low = 0 + while low < high + index = (high + low) / 2 + found = self[index] + return nil if value == found + if value > found + low = index + 1 + else + high = index + end + end + + self[low] = value + # $stderr << "replace #{value} : 0/#{low}/#{init_high} (#{steps} steps) (#{init_high-low} off )\n" + # $stderr.puts self.inspect + # gets + # p length - low + low + end + + def patch(diff) + newary = nil + if diff.difftype == String + newary = diff.difftype.new('') + else + newary = diff.difftype.new + end + ai = 0 + bi = 0 + diff.diffs.each do |d| + d.each { |mod| + case mod[0] + when '-' + while ai < mod[1] + newary << self[ai] + ai += 1 + bi += 1 + end + ai += 1 + when '+' + while bi < mod[1] + newary << self[ai] + ai += 1 + bi += 1 + end + newary << mod[2] + bi += 1 + else + raise 'Unknown diff action' + end + } + end + while ai < length + newary << self[ai] + ai += 1 + bi += 1 + end + newary + end +end diff --git a/lib/redmine/version.rb b/lib/redmine/version.rb deleted file mode 100644 index ee1fc1f867..0000000000 --- a/lib/redmine/version.rb +++ /dev/null @@ -1,33 +0,0 @@ -#-- encoding: UTF-8 -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) 2012-2020 the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2017 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See docs/COPYRIGHT.rdoc for more details. -#++ - -module Redmine - # THIS IS A REDMINE COMPATIBILITY INTERFACE - VERSION = OpenProject::VERSION -end diff --git a/modules/auth_plugins/lib/omniauth/flexible_builder.rb b/modules/auth_plugins/lib/omni_auth/flexible_builder.rb similarity index 100% rename from modules/auth_plugins/lib/omniauth/flexible_builder.rb rename to modules/auth_plugins/lib/omni_auth/flexible_builder.rb diff --git a/modules/auth_plugins/lib/omniauth/flexible_strategy.rb b/modules/auth_plugins/lib/omni_auth/flexible_strategy.rb similarity index 100% rename from modules/auth_plugins/lib/omniauth/flexible_strategy.rb rename to modules/auth_plugins/lib/omni_auth/flexible_strategy.rb index 6f3fc00b1c..03d770b97d 100644 --- a/modules/auth_plugins/lib/omniauth/flexible_strategy.rb +++ b/modules/auth_plugins/lib/omni_auth/flexible_strategy.rb @@ -30,14 +30,6 @@ require 'open_project/plugins/auth_plugin' module OmniAuth - module FlexibleStrategyClass - def new(app, *args, &block) - super(app, *args, &block).tap do |strategy| - strategy.extend FlexibleStrategy - end - end - end - module FlexibleStrategy def on_auth_path? possible_auth_path? && (match_provider! || false) && super @@ -97,4 +89,12 @@ module OmniAuth end end end + + module FlexibleStrategyClass + def new(app, *args, &block) + super(app, *args, &block).tap do |strategy| + strategy.extend FlexibleStrategy + end + end + end end diff --git a/modules/auth_plugins/lib/open_project/auth_plugins.rb b/modules/auth_plugins/lib/open_project/auth_plugins.rb index 78287c0ec2..c6c5ec570d 100644 --- a/modules/auth_plugins/lib/open_project/auth_plugins.rb +++ b/modules/auth_plugins/lib/open_project/auth_plugins.rb @@ -30,8 +30,8 @@ module OpenProject module AuthPlugins require 'open_project/plugins/auth_plugin' - require 'omniauth/flexible_builder' - require 'omniauth/flexible_strategy' + require 'omni_auth/flexible_builder' + require 'omni_auth/flexible_strategy' require 'open_project/auth_plugins/engine' end end diff --git a/modules/avatars/lib/open_project/avatars/engine.rb b/modules/avatars/lib/open_project/avatars/engine.rb index dee168b207..c2c82f680d 100644 --- a/modules/avatars/lib/open_project/avatars/engine.rb +++ b/modules/avatars/lib/open_project/avatars/engine.rb @@ -61,7 +61,9 @@ module OpenProject::Avatars # This is required to be an initializer, # since the helpers are included as soon as the ApplicationController # gets autoloaded, which is BEFORE config.to_prepare. - require_relative 'patches/avatar_helper_patch' + Rails.autoloaders.main.ignore(config.root.join('lib/open_project/avatars/patches/avatar_helper_patch.rb')) + + require_relative './patches/avatar_helper_patch' end patches %i[User] diff --git a/modules/backlogs/app/controllers/rb_export_card_configurations_controller.rb b/modules/backlogs/app/controllers/rb_export_card_configurations_controller.rb index 1ebc1017d0..2f7a55f148 100644 --- a/modules/backlogs/app/controllers/rb_export_card_configurations_controller.rb +++ b/modules/backlogs/app/controllers/rb_export_card_configurations_controller.rb @@ -27,7 +27,7 @@ #++ class RbExportCardConfigurationsController < RbApplicationController - include OpenProject::PdfExport::ExportCard + include OpenProject::PDFExport::ExportCard before_action :load_project_and_sprint @@ -38,7 +38,7 @@ class RbExportCardConfigurationsController < RbApplicationController def show config = ExportCardConfiguration.find(params[:id]) - cards_document = OpenProject::PdfExport::ExportCard::DocumentGenerator.new(config, @sprint.stories(@project)) + cards_document = OpenProject::PDFExport::ExportCard::DocumentGenerator.new(config, @sprint.stories(@project)) filename = "#{@project}-#{@sprint}-#{Time.now.strftime('%B-%d-%Y')}.pdf" respond_to do |format| diff --git a/modules/backlogs/app/controllers/rb_stories_controller.rb b/modules/backlogs/app/controllers/rb_stories_controller.rb index 2757610ed5..32d9f02522 100644 --- a/modules/backlogs/app/controllers/rb_stories_controller.rb +++ b/modules/backlogs/app/controllers/rb_stories_controller.rb @@ -27,7 +27,7 @@ #++ class RbStoriesController < RbApplicationController - include OpenProject::PdfExport::ExportCard + include OpenProject::PDFExport::ExportCard # This is a constant here because we will recruit it elsewhere to whitelist # attributes. This is necessary for now as we still directly use `attributes=` diff --git a/modules/backlogs/app/seeders/role_seeder.rb b/modules/backlogs/app/seeders/basic_data/backlogs/role_seeder.rb similarity index 100% rename from modules/backlogs/app/seeders/role_seeder.rb rename to modules/backlogs/app/seeders/basic_data/backlogs/role_seeder.rb diff --git a/modules/backlogs/app/seeders/setting_seeder.rb b/modules/backlogs/app/seeders/basic_data/backlogs/setting_seeder.rb similarity index 100% rename from modules/backlogs/app/seeders/setting_seeder.rb rename to modules/backlogs/app/seeders/basic_data/backlogs/setting_seeder.rb diff --git a/modules/backlogs/app/seeders/basic_data/backlogs/type_seeder.rb b/modules/backlogs/app/seeders/basic_data/backlogs/type_seeder.rb new file mode 100644 index 0000000000..23009f1258 --- /dev/null +++ b/modules/backlogs/app/seeders/basic_data/backlogs/type_seeder.rb @@ -0,0 +1,23 @@ +module BasicData + module Backlogs + module TypeSeeder + def coded_visibility_table + super.merge backlogs_visibility_table + end + + ## + # Relies on type names in the core TypeSeeder being (in this order) + # task, milestone, phase, feature, epic, user_story, bug + # and 0 to 2 being mapped to + # hidden, default, visible + def backlogs_visibility_table + { + story_points: [0, 0, 0, 1, 2, 2, 1], + remaining_time: [1, 0, 0, 1, 1, 1, 1] + } + end + end + + BasicData::TypeSeeder.prepend BasicData::Backlogs::TypeSeeder + end +end diff --git a/modules/backlogs/app/seeders/type_seeder.rb b/modules/backlogs/app/seeders/type_seeder.rb deleted file mode 100644 index d3a5a1cac1..0000000000 --- a/modules/backlogs/app/seeders/type_seeder.rb +++ /dev/null @@ -1,25 +0,0 @@ -module StandardSeeder - module BasicData - module Backlogs - module TypeSeeder - def coded_visibility_table - super.merge backlogs_visibility_table - end - - ## - # Relies on type names in the core TypeSeeder being (in this order) - # task, milestone, phase, feature, epic, user_story, bug - # and 0 to 2 being mapped to - # hidden, default, visible - def backlogs_visibility_table - { - story_points: [0, 0, 0, 1, 2, 2, 1], - remaining_time: [1, 0, 0, 1, 1, 1, 1] - } - end - end - - StandardSeeder::BasicData::TypeSeeder.prepend StandardSeeder::BasicData::Backlogs::TypeSeeder - end - end -end diff --git a/modules/backlogs/lib/open_project/backlogs/hooks/user_settings_hook.rb b/modules/backlogs/lib/open_project/backlogs/hooks/user_settings_hook.rb index f1341c6cea..15a206034d 100644 --- a/modules/backlogs/lib/open_project/backlogs/hooks/user_settings_hook.rb +++ b/modules/backlogs/lib/open_project/backlogs/hooks/user_settings_hook.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -class OpenProject::Costs::Hooks::UserSettingsHook < Redmine::Hook::ViewListener +class OpenProject::Backlogs::Hooks::UserSettingsHook < Redmine::Hook::ViewListener # Updates the backlogs settings before saving the user # diff --git a/modules/bim/lib/open_project/bim/patches/design_patch.rb b/modules/bim/lib/open_project/bim/patches/design_patch.rb index a07753cdf9..9c3cf67aea 100644 --- a/modules/bim/lib/open_project/bim/patches/design_patch.rb +++ b/modules/bim/lib/open_project/bim/patches/design_patch.rb @@ -3,7 +3,7 @@ require 'open_project/custom_styles/design' module OpenProject::Bim module Patches module DesignPatch - DEFAULTS = OpenProject::Design::DEFAULTS.merge( + DEFAULTS = OpenProject::CustomStyles::Design::DEFAULTS.merge( { 'primary-color' => "#3270DB", 'primary-color-dark' => "#163473", @@ -22,5 +22,5 @@ module OpenProject::Bim end end -OpenProject::Design.send(:remove_const, 'DEFAULTS') -OpenProject::Design.const_set('DEFAULTS', OpenProject::Bim::Patches::DesignPatch::DEFAULTS) +OpenProject::CustomStyles::Design.send(:remove_const, 'DEFAULTS') +OpenProject::CustomStyles::Design.const_set('DEFAULTS', OpenProject::Bim::Patches::DesignPatch::DEFAULTS) diff --git a/modules/boards/app/seeders/role_seeder.rb b/modules/boards/app/seeders/basic_data/boards/role_seeder.rb similarity index 100% rename from modules/boards/app/seeders/role_seeder.rb rename to modules/boards/app/seeders/basic_data/boards/role_seeder.rb diff --git a/modules/costs/app/seeders/type_seeder.rb b/modules/costs/app/seeders/basic_data/costs/type_seeder.rb similarity index 100% rename from modules/costs/app/seeders/type_seeder.rb rename to modules/costs/app/seeders/basic_data/costs/type_seeder.rb diff --git a/modules/costs/lib/open_project/costs/hooks/work_package_action_menu.rb b/modules/costs/lib/open_project/costs/hooks/work_package_action_menu.rb index d3a391b232..cf93cab9fc 100644 --- a/modules/costs/lib/open_project/costs/hooks/work_package_action_menu.rb +++ b/modules/costs/lib/open_project/costs/hooks/work_package_action_menu.rb @@ -27,6 +27,6 @@ #++ # Hooks to attach to the OpenProject action menu. -class OpenProject::Costs::Hooks::WorkPackageActionMenuHook < Redmine::Hook::ViewListener +class OpenProject::Costs::Hooks::WorkPackageActionMenu < Redmine::Hook::ViewListener render_on :view_work_package_show_action_menu, partial: 'hooks/costs/view_work_package_show_action_menu' end diff --git a/modules/costs/lib/open_project/costs/hooks/work_packages_show_attributes.rb b/modules/costs/lib/open_project/costs/hooks/work_packages_show_attributes.rb index d08f9f2a52..71b62246ba 100644 --- a/modules/costs/lib/open_project/costs/hooks/work_packages_show_attributes.rb +++ b/modules/costs/lib/open_project/costs/hooks/work_packages_show_attributes.rb @@ -27,7 +27,7 @@ #++ module OpenProject::Costs::Hooks - class WorkPackagesShowHook < Redmine::Hook::ViewListener + class WorkPackagesShowAttributes < Redmine::Hook::ViewListener include ActionView::Context include WorkPackagesHelper diff --git a/modules/documents/app/seeders/enumeration_seeder.rb b/modules/documents/app/seeders/basic_data/documents/enumeration_seeder.rb similarity index 97% rename from modules/documents/app/seeders/enumeration_seeder.rb rename to modules/documents/app/seeders/basic_data/documents/enumeration_seeder.rb index ac98727200..c0f01b44ca 100644 --- a/modules/documents/app/seeders/enumeration_seeder.rb +++ b/modules/documents/app/seeders/basic_data/documents/enumeration_seeder.rb @@ -29,7 +29,7 @@ module BasicData module Documents - class EnumerationsSeeder < Seeder + class EnumerationSeeder < Seeder def seed_data! category_names.each do |name| DocumentCategory.create name: name diff --git a/modules/documents/app/seeders/role_seeder.rb b/modules/documents/app/seeders/basic_data/documents/role_seeder.rb similarity index 100% rename from modules/documents/app/seeders/role_seeder.rb rename to modules/documents/app/seeders/basic_data/documents/role_seeder.rb diff --git a/modules/documents/lib/open_project/documents/engine.rb b/modules/documents/lib/open_project/documents/engine.rb index 2c1910ea23..d9c7f4f055 100644 --- a/modules/documents/lib/open_project/documents/engine.rb +++ b/modules/documents/lib/open_project/documents/engine.rb @@ -91,11 +91,6 @@ module OpenProject::Documents require_dependency 'document_category' require_dependency 'document_category_custom_field' - # Have to apply this one by hand and not via op_engine patches method - # becauses the op_engine method does not allow for patching something - # in the lib/open_project directory. Bummer. - require_relative 'patches/text_formatting_patch' - require_dependency 'open_project/documents/patches/text_formatting_patch' ::OpenProject::Documents::Patches::ColonSeparatorPatch.mixin! ::OpenProject::Documents::Patches::HashSeparatorPatch.mixin! diff --git a/modules/documents/lib/open_project/documents/patches/text_formatting_patch.rb b/modules/documents/lib/open_project/documents/patches/colon_separator_patch.rb similarity index 74% rename from modules/documents/lib/open_project/documents/patches/text_formatting_patch.rb rename to modules/documents/lib/open_project/documents/patches/colon_separator_patch.rb index fbe3e02287..13c0f2b866 100644 --- a/modules/documents/lib/open_project/documents/patches/text_formatting_patch.rb +++ b/modules/documents/lib/open_project/documents/patches/colon_separator_patch.rb @@ -27,33 +27,6 @@ #++ module OpenProject::Documents::Patches - module HashSeparatorPatch - def self.mixin! - base = ::OpenProject::TextFormatting::Matchers::LinkHandlers::HashSeparator - base.prepend InstanceMethods - base.singleton_class.prepend ClassMethods - end - - module InstanceMethods - def render_document - if document = Document.visible.find_by_id(oid) - link_to document.title, - { only_path: context[:only_path], - controller: '/documents', - action: 'show', - id: document }, - class: 'document' - end - end - end - - module ClassMethods - def allowed_prefixes - super + %w[document] - end - end - end - module ColonSeparatorPatch def self.mixin! base = ::OpenProject::TextFormatting::Matchers::LinkHandlers::ColonSeparator diff --git a/lib/redmine/core_ext/string/inflections.rb b/modules/documents/lib/open_project/documents/patches/hash_separator_patch.rb similarity index 63% rename from lib/redmine/core_ext/string/inflections.rb rename to modules/documents/lib/open_project/documents/patches/hash_separator_patch.rb index 558e006e44..5b3190b82e 100644 --- a/lib/redmine/core_ext/string/inflections.rb +++ b/modules/documents/lib/open_project/documents/patches/hash_separator_patch.rb @@ -1,4 +1,3 @@ -#-- encoding: UTF-8 #-- copyright # OpenProject is an open source project management software. # Copyright (C) 2012-2020 the OpenProject GmbH @@ -27,15 +26,31 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -module Redmine #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - # Custom string inflections - module Inflections - def with_leading_slash - starts_with?('/') ? self : "/#{ self }" +module OpenProject::Documents::Patches + module HashSeparatorPatch + def self.mixin! + base = ::OpenProject::TextFormatting::Matchers::LinkHandlers::HashSeparator + base.prepend InstanceMethods + base.singleton_class.prepend ClassMethods + end + + module InstanceMethods + def render_document + if document = Document.visible.find_by_id(oid) + link_to document.title, + { only_path: context[:only_path], + controller: '/documents', + action: 'show', + id: document }, + class: 'document' end end end + + module ClassMethods + def allowed_prefixes + super + %w[document] + end + end end end diff --git a/modules/openid_connect/lib/open_project/openid_connect/sso_logout.rb b/modules/openid_connect/lib/open_project/openid_connect/sso_logout.rb index fe6956a05c..56e3c95324 100644 --- a/modules/openid_connect/lib/open_project/openid_connect/sso_logout.rb +++ b/modules/openid_connect/lib/open_project/openid_connect/sso_logout.rb @@ -1,6 +1,6 @@ module OpenProject module OpenIDConnect - module SSOLogout + module SsoLogout include ::OmniauthHelper def session_expired? diff --git a/modules/overviews/app/seeders/demo_data/overview_seeder.rb b/modules/overviews/app/seeders/demo_data/overview_seeder.rb new file mode 100644 index 0000000000..14640af764 --- /dev/null +++ b/modules/overviews/app/seeders/demo_data/overview_seeder.rb @@ -0,0 +1,105 @@ +module DemoData + class OverviewSeeder < Seeder + include ::DemoData::References + + def seed_data! + puts "*** Seeding Overview" + + Array(demo_data_for('projects')).each do |(_key, project_config)| + next unless overview_config(project_config) + + puts " -Creating overview for #{project_config[:name]}" + + overview = overview_from_config(project_config) + + overview_config(project_config)[:widgets].each do |widget_config| + build_widget(overview, widget_config) + end + + overview.save! + end + + add_permission + end + + def applicable? + Grids::Overview.count.zero? && demo_projects_exist? + end + + private + + def demo_projects_exist? + identifiers = Array(demo_data_for('projects')) + .map { |_key, project| project[:identifier] } + + identifiers + .all? { |ident| Project.where(identifier: ident).exists? } + end + + def build_widget(overview, widget_config) + create_attachments!(overview, widget_config) + + widget_options = widget_config[:options] + + text_with_references(overview, widget_options) + query_id_references(overview, widget_options) + + overview.widgets.build(widget_config.except(:attachments)) + end + + def create_attachments!(overview, attributes) + Array(attributes[:attachments]).each do |file_name| + attachment = overview.attachments.build + attachment.author = User.admin.first + attachment.file = File.new attachment_path(file_name) + + attachment.save! + end + end + + def attachment_path(file_name) + ::Overviews::Engine.root.join( + "config/locales/media/#{I18n.locale}/#{file_name}" + ) + end + + def project_from_config(config) + Project.find_by! identifier: config[:identifier] + end + + def overview_from_config(project_config) + params = overview_config(project_config) + .slice(:row_count, :column_count) + .merge(project: project_from_config(project_config)) + + Grids::Overview + .create(params) + end + + def overview_config(project_config) + project_config[:"project-overview"] + end + + def text_with_references(overview, widget_options) + if widget_options && widget_options[:text] + widget_options[:text] = with_references(widget_options[:text], overview.project) + widget_options[:text] = link_attachments(widget_options[:text], overview.attachments) + end + end + + def query_id_references(overview, widget_options) + if widget_options && widget_options[:queryId] + widget_options[:queryId] = with_references(widget_options[:queryId], overview.project) + end + end + + def add_permission + Role + .includes(:role_permissions) + .where(role_permissions: { permission: 'edit_project' }) + .each do |role| + role.add_permission!(:manage_overview) + end + end + end +end diff --git a/modules/overviews/app/seeders/overview_seeder.rb b/modules/overviews/app/seeders/overview_seeder.rb deleted file mode 100644 index 56ed834615..0000000000 --- a/modules/overviews/app/seeders/overview_seeder.rb +++ /dev/null @@ -1,107 +0,0 @@ -module DemoData - module Overviews - class OverviewSeeder < Seeder - include ::DemoData::References - - def seed_data! - puts "*** Seeding Overview" - - Array(demo_data_for('projects')).each do |(_key, project_config)| - next unless overview_config(project_config) - - puts " -Creating overview for #{project_config[:name]}" - - overview = overview_from_config(project_config) - - overview_config(project_config)[:widgets].each do |widget_config| - build_widget(overview, widget_config) - end - - overview.save! - end - - add_permission - end - - def applicable? - Grids::Overview.count.zero? && demo_projects_exist? - end - - private - - def demo_projects_exist? - identifiers = Array(demo_data_for('projects')) - .map { |_key, project| project[:identifier] } - - identifiers - .all? { |ident| Project.where(identifier: ident).exists? } - end - - def build_widget(overview, widget_config) - create_attachments!(overview, widget_config) - - widget_options = widget_config[:options] - - text_with_references(overview, widget_options) - query_id_references(overview, widget_options) - - overview.widgets.build(widget_config.except(:attachments)) - end - - def create_attachments!(overview, attributes) - Array(attributes[:attachments]).each do |file_name| - attachment = overview.attachments.build - attachment.author = User.admin.first - attachment.file = File.new attachment_path(file_name) - - attachment.save! - end - end - - def attachment_path(file_name) - ::Overviews::Engine.root.join( - "config/locales/media/#{I18n.locale}/#{file_name}" - ) - end - - def project_from_config(config) - Project.find_by! identifier: config[:identifier] - end - - def overview_from_config(project_config) - params = overview_config(project_config) - .slice(:row_count, :column_count) - .merge(project: project_from_config(project_config)) - - Grids::Overview - .create(params) - end - - def overview_config(project_config) - project_config[:"project-overview"] - end - - def text_with_references(overview, widget_options) - if widget_options && widget_options[:text] - widget_options[:text] = with_references(widget_options[:text], overview.project) - widget_options[:text] = link_attachments(widget_options[:text], overview.attachments) - end - end - - def query_id_references(overview, widget_options) - if widget_options && widget_options[:queryId] - widget_options[:queryId] = with_references(widget_options[:queryId], overview.project) - end - end - - def add_permission - Role - .includes(:role_permissions) - .where(role_permissions: { permission: 'edit_project' }) - .each do |role| - role.add_permission!(:manage_overview) - end - end - end - end -end diff --git a/modules/pdf_export/app/models/export_card_configuration.rb b/modules/pdf_export/app/models/export_card_configuration.rb index a5048d35b0..df97086a65 100644 --- a/modules/pdf_export/app/models/export_card_configuration.rb +++ b/modules/pdf_export/app/models/export_card_configuration.rb @@ -96,7 +96,7 @@ class ExportCardConfiguration < ActiveRecord::Base end end - include OpenProject::PdfExport::Exceptions + include OpenProject::PDFExport::Exceptions validates :name, presence: true validates :rows, rows_yaml: true diff --git a/modules/pdf_export/lib/open_project/pdf_export.rb b/modules/pdf_export/lib/open_project/pdf_export.rb index c25515b30f..627da7353f 100644 --- a/modules/pdf_export/lib/open_project/pdf_export.rb +++ b/modules/pdf_export/lib/open_project/pdf_export.rb @@ -27,7 +27,7 @@ #++ module OpenProject - module PdfExport + module PDFExport require "open_project/pdf_export/engine" end end diff --git a/modules/pdf_export/lib/open_project/pdf_export/engine.rb b/modules/pdf_export/lib/open_project/pdf_export/engine.rb index ee8e893df7..20750d8477 100644 --- a/modules/pdf_export/lib/open_project/pdf_export/engine.rb +++ b/modules/pdf_export/lib/open_project/pdf_export/engine.rb @@ -28,7 +28,7 @@ require 'open_project/plugins' -module OpenProject::PdfExport +module OpenProject::PDFExport class Engine < ::Rails::Engine engine_name :openproject_pdf_export diff --git a/modules/pdf_export/lib/open_project/pdf_export/exceptions.rb b/modules/pdf_export/lib/open_project/pdf_export/exceptions.rb index bb184d1d4b..eac24ae853 100644 --- a/modules/pdf_export/lib/open_project/pdf_export/exceptions.rb +++ b/modules/pdf_export/lib/open_project/pdf_export/exceptions.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -module OpenProject::PdfExport::Exceptions +module OpenProject::PDFExport::Exceptions class BadlyFormedExportCardConfigurationError < StandardError end end diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/card_element.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/card_element.rb index cfc4686a30..3b16440e91 100644 --- a/modules/pdf_export/lib/open_project/pdf_export/export_card/card_element.rb +++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/card_element.rb @@ -26,9 +26,9 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -module OpenProject::PdfExport::ExportCard +module OpenProject::PDFExport::ExportCard class CardElement - include OpenProject::PdfExport::Exceptions + include OpenProject::PDFExport::Exceptions def initialize(pdf, orientation, groups_config, work_package) @pdf = pdf diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/column_element.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/column_element.rb index 4f3f6dfa5a..dc841dcacb 100644 --- a/modules/pdf_export/lib/open_project/pdf_export/export_card/column_element.rb +++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/column_element.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -module OpenProject::PdfExport::ExportCard +module OpenProject::PDFExport::ExportCard class ColumnElement def initialize(pdf, property_name, config, orientation, work_package) @pdf = pdf diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/document_generator.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/document_generator.rb index 0249b9d919..db487b399f 100644 --- a/modules/pdf_export/lib/open_project/pdf_export/export_card/document_generator.rb +++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/document_generator.rb @@ -28,7 +28,7 @@ require 'prawn' -module OpenProject::PdfExport::ExportCard +module OpenProject::PDFExport::ExportCard require "open_project/pdf_export/export_card/model_display/work_package_display" class DocumentGenerator @@ -58,7 +58,7 @@ module OpenProject::PdfExport::ExportCard :bottom_margin => 0, :page_size => page_size) - view = ::WorkPackage::PdfExport::View.new(I18n.locale) + view = ::WorkPackage::PDFExport::View.new(I18n.locale) view.register_fonts! @pdf @pdf.set_font @pdf.font('NotoSans') @@ -106,7 +106,7 @@ module OpenProject::PdfExport::ExportCard def patch_models # Note: Can't seem to patch the models when initializing for reasons which I don't understand - WorkPackage.send(:include, WorkPackageDisplay) + WorkPackage.send(:include, OpenProject::PDFExport::ExportCard::ModelDisplay::WorkPackageDisplay) end end end diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/group_element.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/group_element.rb index 099e6e2a13..b093472829 100644 --- a/modules/pdf_export/lib/open_project/pdf_export/export_card/group_element.rb +++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/group_element.rb @@ -27,9 +27,9 @@ #++ -module OpenProject::PdfExport::ExportCard +module OpenProject::PDFExport::ExportCard class GroupElement - include OpenProject::PdfExport::Exceptions + include OpenProject::PDFExport::Exceptions def initialize(pdf, orientation, config, work_package) @pdf = pdf diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/model_display/work_package_display.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/model_display/work_package_display.rb index e24d137fad..c5a6298bb6 100644 --- a/modules/pdf_export/lib/open_project/pdf_export/export_card/model_display/work_package_display.rb +++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/model_display/work_package_display.rb @@ -1,5 +1,7 @@ -module WorkPackageDisplay - def display_id - "#{(kind.is_standard) ? "" : "#{kind.name}"} ##{id}" +module OpenProject::PDFExport::ExportCard::ModelDisplay + module WorkPackageDisplay + def display_id + "#{kind.is_standard ? "" : "#{kind.name}"} ##{id}" + end end end diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/row_element.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/row_element.rb index 30db659d1a..8dae90b4a4 100644 --- a/modules/pdf_export/lib/open_project/pdf_export/export_card/row_element.rb +++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/row_element.rb @@ -26,9 +26,9 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -module OpenProject::PdfExport::ExportCard +module OpenProject::PDFExport::ExportCard class RowElement - include OpenProject::PdfExport::Exceptions + include OpenProject::PDFExport::Exceptions def initialize(pdf, orientation, config, work_package) @pdf = pdf diff --git a/modules/pdf_export/spec/export_card/document_generator_spec.rb b/modules/pdf_export/spec/export_card/document_generator_spec.rb index ae488a42f3..3a64374d13 100644 --- a/modules/pdf_export/spec/export_card/document_generator_spec.rb +++ b/modules/pdf_export/spec/export_card/document_generator_spec.rb @@ -28,7 +28,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -describe OpenProject::PdfExport::ExportCard::DocumentGenerator do +describe OpenProject::PDFExport::ExportCard::DocumentGenerator do let(:config) { ExportCardConfiguration.new({ name: "Default", description: "This is a description", @@ -51,7 +51,7 @@ describe OpenProject::PdfExport::ExportCard::DocumentGenerator do describe "Single work package rendering" do before(:each) do work_packages = [work_package1] - @generator = OpenProject::PdfExport::ExportCard::DocumentGenerator.new(config, work_packages) + @generator = OpenProject::PDFExport::ExportCard::DocumentGenerator.new(config, work_packages) end it 'shows work package subject' do @@ -73,7 +73,7 @@ describe OpenProject::PdfExport::ExportCard::DocumentGenerator do describe "Multiple work package rendering" do before(:each) do work_packages = [work_package1, work_package2] - @generator = OpenProject::PdfExport::ExportCard::DocumentGenerator.new(config, work_packages) + @generator = OpenProject::PDFExport::ExportCard::DocumentGenerator.new(config, work_packages) end it 'shows work package subject' do diff --git a/modules/recaptcha/lib/open_project/recaptcha/recaptcha.rb b/modules/recaptcha/lib/open_project/recaptcha/recaptcha.rb deleted file mode 100644 index 2b71a7a23b..0000000000 --- a/modules/recaptcha/lib/open_project/recaptcha/recaptcha.rb +++ /dev/null @@ -1,5 +0,0 @@ -module OpenProject - module Recaptcha - require "open_project/recaptcha/engine" - end -end diff --git a/modules/reporting_engine/lib/reporting_engine/helpers/reporting_helper.rb b/modules/reporting_engine/lib/reporting_helper.rb similarity index 100% rename from modules/reporting_engine/lib/reporting_engine/helpers/reporting_helper.rb rename to modules/reporting_engine/lib/reporting_helper.rb diff --git a/modules/reporting_engine/lib/reporting_widget.rb b/modules/reporting_engine/lib/reporting_widget.rb index cfcab7454e..9c55817806 100644 --- a/modules/reporting_engine/lib/reporting_widget.rb +++ b/modules/reporting_engine/lib/reporting_widget.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -require_dependency 'reporting_engine/helpers/reporting_helper' +require_dependency 'reporting_helper' class ReportingWidget < ActionView::Base include ActionView::Helpers::TagHelper diff --git a/modules/two_factor_authentication/app/services/two_factor_authentication/set_default_device_service.rb b/modules/two_factor_authentication/app/services/two_factor_authentication/set_default_device_service.rb deleted file mode 100644 index aeb8263443..0000000000 --- a/modules/two_factor_authentication/app/services/two_factor_authentication/set_default_device_service.rb +++ /dev/null @@ -1,95 +0,0 @@ -module TwoFactorAuthentication - class TokenService - attr_reader :user, :device, :strategy, :channel - - ## - # Create a token service for the given user. - def initialize(user:, use_device: nil, use_channel: nil) - @user = user - @device = use_device || user.otp_devices.get_default - @channel = use_channel || device.try(:channel) - - matching_strategy = get_matching_strategy - if matching_strategy - @strategy = matching_strategy.new(user: @user, device: @device) - end - end - - ## - # Determines whether a token should be entered by the user. - def requires_token? - # If 2FA is enforced, always required - return true if manager.enforced? - - # Otherwise, only enabled if active and a device is present for the user - return manager.enabled? && device.present? - end - - ## - # Request a token through the active strategy - # IF the instance is set up to have optional 2FA - def request - # Validate that we can request the token for this user - # and get the matching strategy we will use - verify_device_and_strategy - - # Produce the token with the given strategy (e.g., sending an sms) - strategy.transmit - - ServiceResult.new(success: true, result: strategy.transmit_success_message) - rescue => e - Rails.logger.error "[2FA plugin] Error during token request to user##{user.id}: #{e}" - - result = ServiceResult.new(success: false) - result.errors.add(:base, e.message) - - result - end - - ## - # Validate a token that was input by the user - def verify(input_token) - # Validate that we can request the token for this user - # and get the matching strategy we will use - verify_device_and_strategy - - # Produce the token with the given strategy (e.g., sending an sms) - result = strategy.verify input_token - - ServiceResult.new(success: result) - rescue => e - Rails.logger.error "[2FA plugin] Error during token validation for user##{user.id}: #{e}" - - result = ServiceResult.new(success: false) - result.errors.add(:base, e.message) - - result - end - - private - - ## - # Get the matching strategy from the desired channel, if set. - def get_matching_strategy - if @channel - manager.find_matching_strategy(@channel) - end - end - - ## - # Perform service checks for the request and validate endpoints of this service - def verify_device_and_strategy - raise I18n.t('two_factor_authentication.error_2fa_disabled') unless manager.enabled? - - # Ensure the user's default device for OTP exists - raise I18n.t('two_factor_authentication.error_no_device') if device.nil? - - # Ensure a matching registered strategy for the device's channel exists - raise I18n.t('two_factor_authentication.error_no_matching_strategy') if strategy.nil? - end - - def manager - ::OpenProject::TwoFactorAuthentication::TokenStrategyManager - end - end -end \ No newline at end of file diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/two_factor_authentication.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/two_factor_authentication.rb deleted file mode 100644 index 2891863acf..0000000000 --- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/two_factor_authentication.rb +++ /dev/null @@ -1,5 +0,0 @@ -module OpenProject - module TwoFactorAuthentication - require "open_project/two_factor_authentication/engine" - end -end diff --git a/modules/xls_export/lib/open_project/xls_export/hooks/cost_report_hook.rb b/modules/xls_export/lib/open_project/xls_export/hooks/cost_report_hook.rb index 2177cb0eb6..59a6569eb0 100644 --- a/modules/xls_export/lib/open_project/xls_export/hooks/cost_report_hook.rb +++ b/modules/xls_export/lib/open_project/xls_export/hooks/cost_report_hook.rb @@ -1,5 +1,4 @@ -# Hooks to attach to the Redmine Issues. -module XlsReport +module OpenProject::XlsExport::Hooks class CostReportHook < Redmine::Hook::ViewListener render_on :view_cost_report_toolbar, partial: 'hooks/xls_report/view_cost_report_toolbar' end diff --git a/modules/xls_export/lib/open_project/xls_export/hooks/work_package_hook.rb b/modules/xls_export/lib/open_project/xls_export/hooks/work_package_hook.rb index eec13ebc4f..34451aa5fd 100644 --- a/modules/xls_export/lib/open_project/xls_export/hooks/work_package_hook.rb +++ b/modules/xls_export/lib/open_project/xls_export/hooks/work_package_hook.rb @@ -1,5 +1,5 @@ -module PrintableIssues - class IssueHook < Redmine::Hook::ViewListener +module OpenProject::XlsExport::Hooks + class WorkPackageHook < Redmine::Hook::ViewListener def link_to_xls(context, label, options = {}) url = { project_id: context[:project], diff --git a/modules/xls_export/lib/open_project/xls_export/xls_views.rb b/modules/xls_export/lib/open_project/xls_export/xls_views.rb index 56a3451755..f236017177 100644 --- a/modules/xls_export/lib/open_project/xls_export/xls_views.rb +++ b/modules/xls_export/lib/open_project/xls_export/xls_views.rb @@ -90,6 +90,3 @@ class OpenProject::XlsExport::XlsViews end end end - -# Load subclasses -require_relative './xls_views/cost_entry_table.xls' diff --git a/modules/xls_export/lib/open_project/xls_export/xls_views/cost_entry_table.xls.rb b/modules/xls_export/lib/open_project/xls_export/xls_views/cost_entry_table.rb similarity index 100% rename from modules/xls_export/lib/open_project/xls_export/xls_views/cost_entry_table.xls.rb rename to modules/xls_export/lib/open_project/xls_export/xls_views/cost_entry_table.rb diff --git a/spec/lib/open_project/design_spec.rb b/spec/lib/open_project/design_spec.rb index a07df9a6cf..84e7096e18 100644 --- a/spec/lib/open_project/design_spec.rb +++ b/spec/lib/open_project/design_spec.rb @@ -28,7 +28,7 @@ require 'spec_helper' -describe OpenProject::Design do +describe OpenProject::CustomStyles::Design do it 'detects variable names in strings' do expect('$bla' =~ described_class::VARIABLE_NAME_RGX).to be_truthy expect('$bla-asdf' =~ described_class::VARIABLE_NAME_RGX).to be_truthy @@ -43,7 +43,7 @@ describe OpenProject::Design do context 'default variables set' do before do - stub_const("OpenProject::Design::DEFAULTS", + stub_const("OpenProject::CustomStyles::Design::DEFAULTS", 'variable_1' => 'one', 'variable_2' => 'two', 'variable_1_2' => 'foo $variable_1 bar $variable_2') diff --git a/spec/lib/open_project/scm/manager_spec.rb b/spec/lib/open_project/scm/manager_spec.rb index a58c828411..876dec73f3 100644 --- a/spec/lib/open_project/scm/manager_spec.rb +++ b/spec/lib/open_project/scm/manager_spec.rb @@ -44,7 +44,7 @@ describe OpenProject::SCM::Manager do end it 'is a valid const' do - expect(OpenProject::SCM::Manager.registered[:test_scm]).to eq(Repository::TestSCM) + expect(OpenProject::SCM::Manager.registered[:test_scm]).to eq(Repository::TestScm) end context 'scm is not known' do diff --git a/spec/models/design_color_spec.rb b/spec/models/design_color_spec.rb index 4e4f1e6a5a..1f845c7a83 100644 --- a/spec/models/design_color_spec.rb +++ b/spec/models/design_color_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' RSpec.describe DesignColor, type: :model do - let(:default_primary) { ::OpenProject::Design.variables['primary-color'] } + let(:default_primary) { ::OpenProject::CustomStyles::Design.variables['primary-color'] } let(:primary_color) { FactoryBot.create :"design_color_primary-color" } describe "#defaults" do diff --git a/spec/views/layouts/base.html.erb_spec.rb b/spec/views/layouts/base.html.erb_spec.rb index 949c478e63..0b8a70772e 100644 --- a/spec/views/layouts/base.html.erb_spec.rb +++ b/spec/views/layouts/base.html.erb_spec.rb @@ -135,7 +135,7 @@ describe 'layouts/base', type: :view do it 'renders main favicon' do expect(rendered).to have_selector( - "link[type='image/x-icon'][href*='#{OpenProject::Design.favicon_asset_path}']", + "link[type='image/x-icon'][href*='#{OpenProject::CustomStyles::Design.favicon_asset_path}']", visible: false ) end diff --git a/spec_legacy/unit/activity_spec.rb b/spec_legacy/unit/activity_spec.rb index ff6ea926ae..24d2532d70 100644 --- a/spec_legacy/unit/activity_spec.rb +++ b/spec_legacy/unit/activity_spec.rb @@ -28,7 +28,7 @@ #++ require_relative '../legacy_spec_helper' -describe Activity, type: :model do +describe Redmine::Activity, type: :model do fixtures :all before do diff --git a/spec_legacy/unit/lib/redmine/plugin_spec.rb b/spec_legacy/unit/lib/redmine/plugin_spec.rb index bfdb7c677a..ec950418af 100644 --- a/spec_legacy/unit/lib/redmine/plugin_spec.rb +++ b/spec_legacy/unit/lib/redmine/plugin_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is an open source project management software. # Copyright (C) 2012-2020 the OpenProject GmbH @@ -26,7 +27,7 @@ # # See docs/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../../../legacy_spec_helper' describe Redmine::Plugin do before do @@ -65,7 +66,7 @@ describe Redmine::Plugin do it 'should requires openproject' do test = self - version = Redmine::VERSION.to_semver + version = OpenProject::VERSION.to_semver @klass.register :foo do test.assert requires_openproject('>= 0.1') @@ -82,7 +83,7 @@ describe Redmine::Plugin do requires_openproject('< 0.9', '>= 98.0.0') end - test.assert requires_openproject("~> #{Redmine::VERSION.to_semver.gsub(/\d+\z/, '0')}") + test.assert requires_openproject("~> #{OpenProject::VERSION.to_semver.gsub(/\d+\z/, '0')}") end end