rename according to zeitwerk

pull/8045/head
ulferts 5 years ago
parent cd049721d5
commit 399e8c3ed9
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 6
      app/assets/stylesheets/openproject/_variables.scss.erb
  2. 2
      app/helpers/application_helper.rb
  3. 6
      app/models/design_color.rb
  4. 4
      app/models/work_package/exporter/pdf.rb
  5. 2
      app/models/work_package/pdf_export/attachments.rb
  6. 4
      app/models/work_package/pdf_export/common.rb
  7. 4
      app/models/work_package/pdf_export/to_pdf_helper.rb
  8. 2
      app/models/work_package/pdf_export/view.rb
  9. 6
      app/models/work_package/pdf_export/work_package_list_to_pdf.rb
  10. 6
      app/models/work_package/pdf_export/work_package_to_pdf.rb
  11. 0
      app/services/work_packages/shared/update_attributes.rb
  12. 1
      app/uploaders/fog_file_uploader.rb
  13. 2
      app/views/common/_favicons.html.erb
  14. 11
      config/initializers/10-patches.rb
  15. 7
      config/initializers/doorkeeper.rb
  16. 3
      config/initializers/reform.rb
  17. 14
      config/initializers/zeitwerk.rb
  18. 2
      db/migrate/20180830120550_migrate_light_background_themes.rb
  19. 52
      lib/extended_http.rb
  20. 2
      lib/generators/open_project/plugin/plugin_generator.rb
  21. 1
      lib/open_project.rb
  22. 2
      lib/open_project/custom_styles/design.rb
  23. 2
      lib/open_project/hooks/view_account_login_auth_provider.rb
  24. 8
      lib/open_project/patches/array.rb
  25. 2
      lib/open_project/patches/carrierwave.rb
  26. 13
      lib/open_project/patches/string.rb
  27. 1
      lib/open_project/text_formatting/formats/markdown/pandoc_wrapper.rb
  28. 1
      lib/open_project/text_formatting/formats/markdown/textile_converter.rb
  29. 30
      lib/redmine/core_ext.rb
  30. 36
      lib/redmine/core_ext/string.rb
  31. 179
      lib/redmine/diff/array_string_diff.rb
  32. 123
      lib/redmine/diff/diffable.rb
  33. 33
      lib/redmine/version.rb
  34. 0
      modules/auth_plugins/lib/omni_auth/flexible_builder.rb
  35. 16
      modules/auth_plugins/lib/omni_auth/flexible_strategy.rb
  36. 4
      modules/auth_plugins/lib/open_project/auth_plugins.rb
  37. 4
      modules/avatars/lib/open_project/avatars/engine.rb
  38. 4
      modules/backlogs/app/controllers/rb_export_card_configurations_controller.rb
  39. 2
      modules/backlogs/app/controllers/rb_stories_controller.rb
  40. 0
      modules/backlogs/app/seeders/basic_data/backlogs/role_seeder.rb
  41. 0
      modules/backlogs/app/seeders/basic_data/backlogs/setting_seeder.rb
  42. 23
      modules/backlogs/app/seeders/basic_data/backlogs/type_seeder.rb
  43. 25
      modules/backlogs/app/seeders/type_seeder.rb
  44. 2
      modules/backlogs/lib/open_project/backlogs/hooks/user_settings_hook.rb
  45. 6
      modules/bim/lib/open_project/bim/patches/design_patch.rb
  46. 0
      modules/boards/app/seeders/basic_data/boards/role_seeder.rb
  47. 0
      modules/costs/app/seeders/basic_data/costs/type_seeder.rb
  48. 2
      modules/costs/lib/open_project/costs/hooks/work_package_action_menu.rb
  49. 2
      modules/costs/lib/open_project/costs/hooks/work_packages_show_attributes.rb
  50. 2
      modules/documents/app/seeders/basic_data/documents/enumeration_seeder.rb
  51. 0
      modules/documents/app/seeders/basic_data/documents/role_seeder.rb
  52. 5
      modules/documents/lib/open_project/documents/engine.rb
  53. 27
      modules/documents/lib/open_project/documents/patches/colon_separator_patch.rb
  54. 31
      modules/documents/lib/open_project/documents/patches/hash_separator_patch.rb
  55. 2
      modules/openid_connect/lib/open_project/openid_connect/sso_logout.rb
  56. 105
      modules/overviews/app/seeders/demo_data/overview_seeder.rb
  57. 107
      modules/overviews/app/seeders/overview_seeder.rb
  58. 2
      modules/pdf_export/app/models/export_card_configuration.rb
  59. 2
      modules/pdf_export/lib/open_project/pdf_export.rb
  60. 2
      modules/pdf_export/lib/open_project/pdf_export/engine.rb
  61. 2
      modules/pdf_export/lib/open_project/pdf_export/exceptions.rb
  62. 4
      modules/pdf_export/lib/open_project/pdf_export/export_card/card_element.rb
  63. 2
      modules/pdf_export/lib/open_project/pdf_export/export_card/column_element.rb
  64. 6
      modules/pdf_export/lib/open_project/pdf_export/export_card/document_generator.rb
  65. 4
      modules/pdf_export/lib/open_project/pdf_export/export_card/group_element.rb
  66. 4
      modules/pdf_export/lib/open_project/pdf_export/export_card/model_display/work_package_display.rb
  67. 4
      modules/pdf_export/lib/open_project/pdf_export/export_card/row_element.rb
  68. 6
      modules/pdf_export/spec/export_card/document_generator_spec.rb
  69. 5
      modules/recaptcha/lib/open_project/recaptcha/recaptcha.rb
  70. 0
      modules/reporting_engine/lib/reporting_helper.rb
  71. 2
      modules/reporting_engine/lib/reporting_widget.rb
  72. 95
      modules/two_factor_authentication/app/services/two_factor_authentication/set_default_device_service.rb
  73. 5
      modules/two_factor_authentication/lib/open_project/two_factor_authentication/two_factor_authentication.rb
  74. 3
      modules/xls_export/lib/open_project/xls_export/hooks/cost_report_hook.rb
  75. 4
      modules/xls_export/lib/open_project/xls_export/hooks/work_package_hook.rb
  76. 3
      modules/xls_export/lib/open_project/xls_export/xls_views.rb
  77. 0
      modules/xls_export/lib/open_project/xls_export/xls_views/cost_entry_table.rb
  78. 4
      spec/lib/open_project/design_spec.rb
  79. 2
      spec/lib/open_project/scm/manager_spec.rb
  80. 2
      spec/models/design_color_spec.rb
  81. 2
      spec/views/layouts/base.html.erb_spec.rb
  82. 2
      spec_legacy/unit/activity_spec.rb
  83. 7
      spec_legacy/unit/lib/redmine/plugin_spec.rb

@ -11,12 +11,12 @@ primary-color-dark
alternative-color alternative-color
This allows us to dynamically define CSS4 + Sass variables from a single map 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 %>; $<%= var %>: <%= hexcode %>;
<% end %> <% end %>
:root { :root {
<% ::OpenProject::Design.variables.each do |var, definition| %> <% ::OpenProject::CustomStyles::Design.variables.each do |var, definition| %>
<% css4definition = definition.gsub(/\$([\w-]+)/, 'var(--\1)') %> <% css4definition = definition.gsub(/\$([\w-]+)/, 'var(--\1)') %>
--<%= var %>: <%= css4definition %>; --<%= var %>: <%= css4definition %>;
<% end %> <% end %>
@ -24,7 +24,7 @@ $<%= var %>: <%= hexcode %>;
<%# Construct a sass map to lookup variables in the mixin below %> <%# Construct a sass map to lookup variables in the mixin below %>
$variable-map: ( $variable-map: (
<% ::OpenProject::Design.variables.each do |var, definition| %> <% ::OpenProject::CustomStyles::Design.variables.each do |var, definition| %>
<%= var %>: #{<%= definition %>}, <%= var %>: #{<%= definition %>},
<% end %> <% end %>
); );

@ -301,7 +301,7 @@ module ApplicationHelper
# Returns the theme, controller name, and action as css classes for the # Returns the theme, controller name, and action as css classes for the
# HTML body. # HTML body.
def body_css_classes def body_css_classes
css = ['theme-' + OpenProject::Design.identifier.to_s] css = ['theme-' + OpenProject::CustomStyles::Design.identifier.to_s]
if params[:controller] && params[:action] if params[:controller] && params[:action]
css << 'controller-' + params[:controller] css << 'controller-' + params[:controller]

@ -47,19 +47,19 @@ class DesignColor < ActiveRecord::Base
class << self class << self
def defaults def defaults
OpenProject::Design.resolved_variables OpenProject::CustomStyles::Design.resolved_variables
end end
def setables def setables
overwritten_values = self.overwritten 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 = overwritten_values.detect { |var| var.variable == varname }
overwritten_value || new(variable: varname) overwritten_value || new(variable: varname)
end end
end end
def overwritten def overwritten
overridable = OpenProject::Design.customizable_variables overridable = OpenProject::CustomStyles::Design.customizable_variables
all.to_a.select do |color| all.to_a.select do |color|
overridable.include?(color.variable) && self.defaults[color] != color.get_hexcode overridable.include?(color.variable) && self.defaults[color] != color.get_hexcode

@ -31,7 +31,7 @@
class WorkPackage::Exporter::PDF < WorkPackage::Exporter::Base class WorkPackage::Exporter::PDF < WorkPackage::Exporter::Base
# Returns a PDF string of a list of work_packages # Returns a PDF string of a list of work_packages
def list def list
yield ::WorkPackage::PdfExport::WorkPackageListToPdf yield ::WorkPackage::PDFExport::WorkPackageListToPdf
.new(query, .new(query,
options) options)
.render! .render!
@ -39,7 +39,7 @@ class WorkPackage::Exporter::PDF < WorkPackage::Exporter::Base
# Returns a PDF string of a single work_package # Returns a PDF string of a single work_package
def single def single
yield ::WorkPackage::PdfExport::WorkPackageToPdf yield ::WorkPackage::PDFExport::WorkPackageToPdf
.new(work_package) .new(work_package)
.render! .render!
end end

@ -28,7 +28,7 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
module WorkPackage::PdfExport::Attachments module WorkPackage::PDFExport::Attachments
## ##
# Creates cells for each attachment of the work package # Creates cells for each attachment of the work package
# #

@ -28,12 +28,12 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
module WorkPackage::PdfExport::Common module WorkPackage::PDFExport::Common
include Redmine::I18n include Redmine::I18n
include ActionView::Helpers::TextHelper include ActionView::Helpers::TextHelper
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
include CustomFieldsHelper include CustomFieldsHelper
include WorkPackage::PdfExport::ToPdfHelper include WorkPackage::PDFExport::ToPdfHelper
include OpenProject::TextFormatting include OpenProject::TextFormatting
private private

@ -27,8 +27,8 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
module WorkPackage::PdfExport::ToPdfHelper module WorkPackage::PDFExport::ToPdfHelper
def get_pdf(language) def get_pdf(language)
::WorkPackage::PdfExport::View.new(current_language) ::WorkPackage::PDFExport::View.new(current_language)
end end
end end

@ -27,7 +27,7 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
class WorkPackage::PdfExport::View class WorkPackage::PDFExport::View
include Prawn::View include Prawn::View
include Redmine::I18n include Redmine::I18n

@ -28,9 +28,9 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
class WorkPackage::PdfExport::WorkPackageListToPdf < WorkPackage::Exporter::Base class WorkPackage::PDFExport::WorkPackageListToPdf < WorkPackage::Exporter::Base
include WorkPackage::PdfExport::Common include WorkPackage::PDFExport::Common
include WorkPackage::PdfExport::Attachments include WorkPackage::PDFExport::Attachments
attr_accessor :pdf, attr_accessor :pdf,
:options :options

@ -28,9 +28,9 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
class WorkPackage::PdfExport::WorkPackageToPdf < WorkPackage::Exporter::Base class WorkPackage::PDFExport::WorkPackageToPdf < WorkPackage::Exporter::Base
include WorkPackage::PdfExport::Common include WorkPackage::PDFExport::Common
include WorkPackage::PdfExport::Attachments include WorkPackage::PDFExport::Attachments
attr_accessor :pdf attr_accessor :pdf

@ -27,7 +27,6 @@
#++ #++
require 'carrierwave/storage/fog' require 'carrierwave/storage/fog'
require 'open_project/patches/carrierwave'
class FogFileUploader < CarrierWave::Uploader::Base class FogFileUploader < CarrierWave::Uploader::Base
include FileUploader include FileUploader

@ -1,5 +1,5 @@
<% unless (EnterpriseToken.allows_to?(:define_custom_style) && CustomStyle.try(:current).present? && CustomStyle.current.favicon.present?) %> <% 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 %> <% end %>
<% unless (EnterpriseToken.allows_to?(:define_custom_style) && CustomStyle.try(:current).present? && CustomStyle.current.touch_icon.present?) %> <% unless (EnterpriseToken.allows_to?(:define_custom_style) && CustomStyle.try(:current).present? && CustomStyle.current.touch_icon.present?) %>

@ -150,3 +150,14 @@ end
# Patch acts_as_list before any class includes the module # Patch acts_as_list before any class includes the module
require 'open_project/patches/acts_as_list' 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'

@ -211,6 +211,11 @@ end
OpenProject::Application.configure do |application| OpenProject::Application.configure do |application|
application.config.to_prepare do 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
end end

@ -47,11 +47,8 @@ Reform::Form::ActiveModel::Validations::Validator.class_eval do
end end
end end
require 'reform/contract' require 'reform/contract'
require 'open_project/patches/reform'
class Reform::Form::ActiveModel::Errors class Reform::Form::ActiveModel::Errors
prepend OpenProject::Patches::Reform prepend OpenProject::Patches::Reform
end end

@ -6,15 +6,20 @@
module OpenProject module OpenProject
class Inflector < Zeitwerk::GemInflector class Inflector < Zeitwerk::GemInflector
# TODO: split up into a registry
def camelize(basename, abspath) def camelize(basename, abspath)
if basename =~ /\A(.*)_api\z/ if basename =~ /\A(.*)_api\z/
super($1, abspath) + 'API' super($1, abspath) + 'API'
elsif basename =~ /\Aoauth_(.*)\z/ elsif basename =~ /\Aoauth_(.*)\z/
'OAuth' + super($1, abspath) 'OAuth' + super($1, abspath)
elsif basename =~ /\A(.*)_oauth\z/
super($1, abspath) + 'OAuth'
elsif basename =~ /\A(.*)_sso\z/ elsif basename =~ /\A(.*)_sso\z/
super($1, abspath) + 'SSO' super($1, abspath) + 'SSO'
elsif basename =~ /\Aar_(.*)\z/ elsif basename =~ /\Aar_(.*)\z/
'AR' + super($1, abspath) 'AR' + super($1, abspath)
elsif basename =~ /\Apdf_export\z/
'PDFExport'
elsif abspath =~ /open_project\/version(\.rb)?\z/ elsif abspath =~ /open_project\/version(\.rb)?\z/
"VERSION" "VERSION"
else else
@ -34,10 +39,15 @@ Rails.autoloaders.each do |autoloader|
'sso' => 'SSO', 'sso' => 'SSO',
'csv' => 'CSV', 'csv' => 'CSV',
'pdf' => 'PDF', 'pdf' => 'PDF',
'scm' => 'SCM' 'scm' => 'SCM',
'imap' => 'IMAP',
'pop3' => 'POP3',
'openid_connect' => 'OpenIDConnect'
) )
end end
# Instruct zeitwerk to ignore all the engine gems' lib initialization files # 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(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'))

@ -55,7 +55,7 @@ class MigrateLightBackgroundThemes < ActiveRecord::Migration[5.1]
main-menu-bg-hover-background main-menu-bg-hover-background
main-menu-hover-font-color main-menu-hover-font-color
main-menu-border-color ).each do |variable_name| 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 end
# Never ever overwrite variables that were already set. # Never ever overwrite variables that were already set.

@ -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

@ -28,7 +28,7 @@
require 'rails/generators' require 'rails/generators'
class OpenProject::PluginGenerator < Rails::Generators::Base class Generators::OpenProject::Plugin::PluginGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__) source_root File.expand_path('../templates', __FILE__)
argument :plugin_name, type: :string, default: 'openproject-new-plugin' argument :plugin_name, type: :string, default: 'openproject-new-plugin'

@ -34,7 +34,6 @@ require 'redmine/search'
require 'open_project/custom_field_format' require 'open_project/custom_field_format'
require 'open_project/logging/log_delegator' require 'open_project/logging/log_delegator'
require 'redmine/mime_type' require 'redmine/mime_type'
require 'redmine/core_ext'
require 'open_project/custom_styles/design' require 'open_project/custom_styles/design'
require 'redmine/hook' require 'redmine/hook'
require 'open_project/hooks' require 'open_project/hooks'

@ -27,7 +27,7 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
module OpenProject module OpenProject::CustomStyles
class Design class Design
DEFAULTS = { DEFAULTS = {
'primary-color' => "#1A67A3", 'primary-color' => "#1A67A3",

@ -30,7 +30,7 @@ module OpenProject
module Hooks module Hooks
## ##
# Hook called in the login forms which displays the different auth providers # 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, render_on :view_account_login_auth_provider,
partial: 'hooks/login/auth_provider' partial: 'hooks/login/auth_provider'
end end

@ -0,0 +1,8 @@
module OpenProject
module Patches
module Array
end
end
end
Array.send(:include, Redmine::Diff::Diffable)

@ -1,4 +1,4 @@
require 'carrierwave' require 'carrierwave/storage/fog'
## ##
# Code copied straight from the CarrierWave source. # Code copied straight from the CarrierWave source.

@ -27,11 +27,9 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
module Redmine #:nodoc: module OpenProject
module CoreExtensions #:nodoc: module Patches
module String #:nodoc: module String #:nodoc:
# Custom string conversions
module Conversions
# Parses hours format and returns a float # Parses hours format and returns a float
def to_hours def to_hours
s = dup s = dup
@ -48,7 +46,14 @@ module Redmine #:nodoc:
s.gsub!(',', '.') s.gsub!(',', '.')
begin; Kernel.Float(s); rescue; nil; end begin; Kernel.Float(s); rescue; nil; end
end end
# TODO: Check if this can be deleted
def with_leading_slash
starts_with?('/') ? self : "/#{self}"
end end
end end
end end
end end
String.send(:include, OpenProject::Patches::String)
String.send(:include, Redmine::Diff::Diffable)

@ -33,7 +33,6 @@ require 'posix-spawn'
module OpenProject::TextFormatting::Formats module OpenProject::TextFormatting::Formats
module Markdown module Markdown
class PandocWrapper class PandocWrapper
attr_reader :logger attr_reader :logger
def initialize(logger = ::Logger.new(STDOUT)) def initialize(logger = ::Logger.new(STDOUT))

@ -53,7 +53,6 @@
# SOFTWARE. # SOFTWARE.
require 'ruby-progressbar' require 'ruby-progressbar'
require_relative 'pandoc_wrapper'
module OpenProject::TextFormatting::Formats module OpenProject::TextFormatting::Formats
module Markdown module Markdown

@ -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) }

@ -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

@ -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

@ -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

@ -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

@ -30,14 +30,6 @@
require 'open_project/plugins/auth_plugin' require 'open_project/plugins/auth_plugin'
module OmniAuth module OmniAuth
module FlexibleStrategyClass
def new(app, *args, &block)
super(app, *args, &block).tap do |strategy|
strategy.extend FlexibleStrategy
end
end
end
module FlexibleStrategy module FlexibleStrategy
def on_auth_path? def on_auth_path?
possible_auth_path? && (match_provider! || false) && super possible_auth_path? && (match_provider! || false) && super
@ -97,4 +89,12 @@ module OmniAuth
end end
end end
end end
module FlexibleStrategyClass
def new(app, *args, &block)
super(app, *args, &block).tap do |strategy|
strategy.extend FlexibleStrategy
end
end
end
end end

@ -30,8 +30,8 @@
module OpenProject module OpenProject
module AuthPlugins module AuthPlugins
require 'open_project/plugins/auth_plugin' require 'open_project/plugins/auth_plugin'
require 'omniauth/flexible_builder' require 'omni_auth/flexible_builder'
require 'omniauth/flexible_strategy' require 'omni_auth/flexible_strategy'
require 'open_project/auth_plugins/engine' require 'open_project/auth_plugins/engine'
end end
end end

@ -61,7 +61,9 @@ module OpenProject::Avatars
# This is required to be an initializer, # This is required to be an initializer,
# since the helpers are included as soon as the ApplicationController # since the helpers are included as soon as the ApplicationController
# gets autoloaded, which is BEFORE config.to_prepare. # 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 end
patches %i[User] patches %i[User]

@ -27,7 +27,7 @@
#++ #++
class RbExportCardConfigurationsController < RbApplicationController class RbExportCardConfigurationsController < RbApplicationController
include OpenProject::PdfExport::ExportCard include OpenProject::PDFExport::ExportCard
before_action :load_project_and_sprint before_action :load_project_and_sprint
@ -38,7 +38,7 @@ class RbExportCardConfigurationsController < RbApplicationController
def show def show
config = ExportCardConfiguration.find(params[:id]) 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" filename = "#{@project}-#{@sprint}-#{Time.now.strftime('%B-%d-%Y')}.pdf"
respond_to do |format| respond_to do |format|

@ -27,7 +27,7 @@
#++ #++
class RbStoriesController < RbApplicationController class RbStoriesController < RbApplicationController
include OpenProject::PdfExport::ExportCard include OpenProject::PDFExport::ExportCard
# This is a constant here because we will recruit it elsewhere to whitelist # 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=` # attributes. This is necessary for now as we still directly use `attributes=`

@ -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

@ -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

@ -26,7 +26,7 @@
# See docs/COPYRIGHT.rdoc for more details. # 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 # Updates the backlogs settings before saving the user
# #

@ -3,7 +3,7 @@ require 'open_project/custom_styles/design'
module OpenProject::Bim module OpenProject::Bim
module Patches module Patches
module DesignPatch module DesignPatch
DEFAULTS = OpenProject::Design::DEFAULTS.merge( DEFAULTS = OpenProject::CustomStyles::Design::DEFAULTS.merge(
{ {
'primary-color' => "#3270DB", 'primary-color' => "#3270DB",
'primary-color-dark' => "#163473", 'primary-color-dark' => "#163473",
@ -22,5 +22,5 @@ module OpenProject::Bim
end end
end end
OpenProject::Design.send(:remove_const, 'DEFAULTS') OpenProject::CustomStyles::Design.send(:remove_const, 'DEFAULTS')
OpenProject::Design.const_set('DEFAULTS', OpenProject::Bim::Patches::DesignPatch::DEFAULTS) OpenProject::CustomStyles::Design.const_set('DEFAULTS', OpenProject::Bim::Patches::DesignPatch::DEFAULTS)

@ -27,6 +27,6 @@
#++ #++
# Hooks to attach to the OpenProject action menu. # 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' render_on :view_work_package_show_action_menu, partial: 'hooks/costs/view_work_package_show_action_menu'
end end

@ -27,7 +27,7 @@
#++ #++
module OpenProject::Costs::Hooks module OpenProject::Costs::Hooks
class WorkPackagesShowHook < Redmine::Hook::ViewListener class WorkPackagesShowAttributes < Redmine::Hook::ViewListener
include ActionView::Context include ActionView::Context
include WorkPackagesHelper include WorkPackagesHelper

@ -29,7 +29,7 @@
module BasicData module BasicData
module Documents module Documents
class EnumerationsSeeder < Seeder class EnumerationSeeder < Seeder
def seed_data! def seed_data!
category_names.each do |name| category_names.each do |name|
DocumentCategory.create name: name DocumentCategory.create name: name

@ -91,11 +91,6 @@ module OpenProject::Documents
require_dependency 'document_category' require_dependency 'document_category'
require_dependency 'document_category_custom_field' 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::ColonSeparatorPatch.mixin!
::OpenProject::Documents::Patches::HashSeparatorPatch.mixin! ::OpenProject::Documents::Patches::HashSeparatorPatch.mixin!

@ -27,33 +27,6 @@
#++ #++
module OpenProject::Documents::Patches 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 module ColonSeparatorPatch
def self.mixin! def self.mixin!
base = ::OpenProject::TextFormatting::Matchers::LinkHandlers::ColonSeparator base = ::OpenProject::TextFormatting::Matchers::LinkHandlers::ColonSeparator

@ -1,4 +1,3 @@
#-- encoding: UTF-8
#-- copyright #-- copyright
# OpenProject is an open source project management software. # OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH # Copyright (C) 2012-2020 the OpenProject GmbH
@ -27,14 +26,30 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
module Redmine #:nodoc: module OpenProject::Documents::Patches
module CoreExtensions #:nodoc: module HashSeparatorPatch
module String #:nodoc: def self.mixin!
# Custom string inflections base = ::OpenProject::TextFormatting::Matchers::LinkHandlers::HashSeparator
module Inflections base.prepend InstanceMethods
def with_leading_slash base.singleton_class.prepend ClassMethods
starts_with?('/') ? self : "/#{ self }"
end 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
end end

@ -1,6 +1,6 @@
module OpenProject module OpenProject
module OpenIDConnect module OpenIDConnect
module SSOLogout module SsoLogout
include ::OmniauthHelper include ::OmniauthHelper
def session_expired? def session_expired?

@ -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

@ -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

@ -96,7 +96,7 @@ class ExportCardConfiguration < ActiveRecord::Base
end end
end end
include OpenProject::PdfExport::Exceptions include OpenProject::PDFExport::Exceptions
validates :name, presence: true validates :name, presence: true
validates :rows, rows_yaml: true validates :rows, rows_yaml: true

@ -27,7 +27,7 @@
#++ #++
module OpenProject module OpenProject
module PdfExport module PDFExport
require "open_project/pdf_export/engine" require "open_project/pdf_export/engine"
end end
end end

@ -28,7 +28,7 @@
require 'open_project/plugins' require 'open_project/plugins'
module OpenProject::PdfExport module OpenProject::PDFExport
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
engine_name :openproject_pdf_export engine_name :openproject_pdf_export

@ -26,7 +26,7 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
module OpenProject::PdfExport::Exceptions module OpenProject::PDFExport::Exceptions
class BadlyFormedExportCardConfigurationError < StandardError class BadlyFormedExportCardConfigurationError < StandardError
end end
end end

@ -26,9 +26,9 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
module OpenProject::PdfExport::ExportCard module OpenProject::PDFExport::ExportCard
class CardElement class CardElement
include OpenProject::PdfExport::Exceptions include OpenProject::PDFExport::Exceptions
def initialize(pdf, orientation, groups_config, work_package) def initialize(pdf, orientation, groups_config, work_package)
@pdf = pdf @pdf = pdf

@ -26,7 +26,7 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
module OpenProject::PdfExport::ExportCard module OpenProject::PDFExport::ExportCard
class ColumnElement class ColumnElement
def initialize(pdf, property_name, config, orientation, work_package) def initialize(pdf, property_name, config, orientation, work_package)
@pdf = pdf @pdf = pdf

@ -28,7 +28,7 @@
require 'prawn' require 'prawn'
module OpenProject::PdfExport::ExportCard module OpenProject::PDFExport::ExportCard
require "open_project/pdf_export/export_card/model_display/work_package_display" require "open_project/pdf_export/export_card/model_display/work_package_display"
class DocumentGenerator class DocumentGenerator
@ -58,7 +58,7 @@ module OpenProject::PdfExport::ExportCard
:bottom_margin => 0, :bottom_margin => 0,
:page_size => page_size) :page_size => page_size)
view = ::WorkPackage::PdfExport::View.new(I18n.locale) view = ::WorkPackage::PDFExport::View.new(I18n.locale)
view.register_fonts! @pdf view.register_fonts! @pdf
@pdf.set_font @pdf.font('NotoSans') @pdf.set_font @pdf.font('NotoSans')
@ -106,7 +106,7 @@ module OpenProject::PdfExport::ExportCard
def patch_models def patch_models
# Note: Can't seem to patch the models when initializing for reasons which I don't understand # 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 end
end end

@ -27,9 +27,9 @@
#++ #++
module OpenProject::PdfExport::ExportCard module OpenProject::PDFExport::ExportCard
class GroupElement class GroupElement
include OpenProject::PdfExport::Exceptions include OpenProject::PDFExport::Exceptions
def initialize(pdf, orientation, config, work_package) def initialize(pdf, orientation, config, work_package)
@pdf = pdf @pdf = pdf

@ -1,5 +1,7 @@
module OpenProject::PDFExport::ExportCard::ModelDisplay
module WorkPackageDisplay module WorkPackageDisplay
def display_id def display_id
"#{(kind.is_standard) ? "" : "#{kind.name}"} ##{id}" "#{kind.is_standard ? "" : "#{kind.name}"} ##{id}"
end
end end
end end

@ -26,9 +26,9 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
module OpenProject::PdfExport::ExportCard module OpenProject::PDFExport::ExportCard
class RowElement class RowElement
include OpenProject::PdfExport::Exceptions include OpenProject::PDFExport::Exceptions
def initialize(pdf, orientation, config, work_package) def initialize(pdf, orientation, config, work_package)
@pdf = pdf @pdf = pdf

@ -28,7 +28,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') 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({ let(:config) { ExportCardConfiguration.new({
name: "Default", name: "Default",
description: "This is a description", description: "This is a description",
@ -51,7 +51,7 @@ describe OpenProject::PdfExport::ExportCard::DocumentGenerator do
describe "Single work package rendering" do describe "Single work package rendering" do
before(:each) do before(:each) do
work_packages = [work_package1] work_packages = [work_package1]
@generator = OpenProject::PdfExport::ExportCard::DocumentGenerator.new(config, work_packages) @generator = OpenProject::PDFExport::ExportCard::DocumentGenerator.new(config, work_packages)
end end
it 'shows work package subject' do it 'shows work package subject' do
@ -73,7 +73,7 @@ describe OpenProject::PdfExport::ExportCard::DocumentGenerator do
describe "Multiple work package rendering" do describe "Multiple work package rendering" do
before(:each) do before(:each) do
work_packages = [work_package1, work_package2] 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 end
it 'shows work package subject' do it 'shows work package subject' do

@ -1,5 +0,0 @@
module OpenProject
module Recaptcha
require "open_project/recaptcha/engine"
end
end

@ -26,7 +26,7 @@
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
require_dependency 'reporting_engine/helpers/reporting_helper' require_dependency 'reporting_helper'
class ReportingWidget < ActionView::Base class ReportingWidget < ActionView::Base
include ActionView::Helpers::TagHelper include ActionView::Helpers::TagHelper

@ -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

@ -1,5 +0,0 @@
module OpenProject
module TwoFactorAuthentication
require "open_project/two_factor_authentication/engine"
end
end

@ -1,5 +1,4 @@
# Hooks to attach to the Redmine Issues. module OpenProject::XlsExport::Hooks
module XlsReport
class CostReportHook < Redmine::Hook::ViewListener class CostReportHook < Redmine::Hook::ViewListener
render_on :view_cost_report_toolbar, partial: 'hooks/xls_report/view_cost_report_toolbar' render_on :view_cost_report_toolbar, partial: 'hooks/xls_report/view_cost_report_toolbar'
end end

@ -1,5 +1,5 @@
module PrintableIssues module OpenProject::XlsExport::Hooks
class IssueHook < Redmine::Hook::ViewListener class WorkPackageHook < Redmine::Hook::ViewListener
def link_to_xls(context, label, options = {}) def link_to_xls(context, label, options = {})
url = { url = {
project_id: context[:project], project_id: context[:project],

@ -90,6 +90,3 @@ class OpenProject::XlsExport::XlsViews
end end
end end
end end
# Load subclasses
require_relative './xls_views/cost_entry_table.xls'

@ -28,7 +28,7 @@
require 'spec_helper' require 'spec_helper'
describe OpenProject::Design do describe OpenProject::CustomStyles::Design do
it 'detects variable names in strings' do it 'detects variable names in strings' do
expect('$bla' =~ described_class::VARIABLE_NAME_RGX).to be_truthy expect('$bla' =~ described_class::VARIABLE_NAME_RGX).to be_truthy
expect('$bla-asdf' =~ 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 context 'default variables set' do
before do before do
stub_const("OpenProject::Design::DEFAULTS", stub_const("OpenProject::CustomStyles::Design::DEFAULTS",
'variable_1' => 'one', 'variable_1' => 'one',
'variable_2' => 'two', 'variable_2' => 'two',
'variable_1_2' => 'foo $variable_1 bar $variable_2') 'variable_1_2' => 'foo $variable_1 bar $variable_2')

@ -44,7 +44,7 @@ describe OpenProject::SCM::Manager do
end end
it 'is a valid const' do 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 end
context 'scm is not known' do context 'scm is not known' do

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe DesignColor, type: :model do 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" } let(:primary_color) { FactoryBot.create :"design_color_primary-color" }
describe "#defaults" do describe "#defaults" do

@ -135,7 +135,7 @@ describe 'layouts/base', type: :view do
it 'renders main favicon' do it 'renders main favicon' do
expect(rendered).to have_selector( 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 visible: false
) )
end end

@ -28,7 +28,7 @@
#++ #++
require_relative '../legacy_spec_helper' require_relative '../legacy_spec_helper'
describe Activity, type: :model do describe Redmine::Activity, type: :model do
fixtures :all fixtures :all
before do before do

@ -1,4 +1,5 @@
#-- encoding: UTF-8 #-- encoding: UTF-8
#-- copyright #-- copyright
# OpenProject is an open source project management software. # OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH # Copyright (C) 2012-2020 the OpenProject GmbH
@ -26,7 +27,7 @@
# #
# See docs/COPYRIGHT.rdoc for more details. # See docs/COPYRIGHT.rdoc for more details.
#++ #++
require 'legacy_spec_helper' require_relative '../../../legacy_spec_helper'
describe Redmine::Plugin do describe Redmine::Plugin do
before do before do
@ -65,7 +66,7 @@ describe Redmine::Plugin do
it 'should requires openproject' do it 'should requires openproject' do
test = self test = self
version = Redmine::VERSION.to_semver version = OpenProject::VERSION.to_semver
@klass.register :foo do @klass.register :foo do
test.assert requires_openproject('>= 0.1') test.assert requires_openproject('>= 0.1')
@ -82,7 +83,7 @@ describe Redmine::Plugin do
requires_openproject('< 0.9', '>= 98.0.0') requires_openproject('< 0.9', '>= 98.0.0')
end 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
end end

Loading…
Cancel
Save