mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Merge branch 'fix/cleanup_initializers' into dev
This commit is contained in:
@@ -43,11 +43,11 @@ module Project::Activity
|
||||
|
||||
def latest_project_activity
|
||||
@latest_project_activity ||=
|
||||
Constants::ProjectActivity.registered.map { |params|
|
||||
build_latest_project_activity_for(on: params[:on],
|
||||
chain: params[:chain],
|
||||
Constants::ProjectActivity.registered.map do |params|
|
||||
build_latest_project_activity_for(on: params[:on].constantize,
|
||||
chain: Array(params[:chain]).map(&:constantize),
|
||||
attribute: params[:attribute])
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def with_latest_activity
|
||||
|
||||
@@ -28,27 +28,9 @@
|
||||
# See docs/COPYRIGHT.rdoc for more details.
|
||||
#++
|
||||
|
||||
require "reform/form/active_model/validations"
|
||||
# Do not place any patches within this file. Add a file to lib/open_project/patches
|
||||
|
||||
Reform::Form.class_eval do
|
||||
include Reform::Form::ActiveModel::Validations
|
||||
end
|
||||
|
||||
Reform::Contract.class_eval do
|
||||
include Reform::Form::ActiveModel::Validations
|
||||
end
|
||||
|
||||
Reform::Form::ActiveModel::Validations::Validator.class_eval do
|
||||
##
|
||||
# use activerecord as the base scope instead of 'activemodel' to be compatible
|
||||
# to the messages we have already stored
|
||||
def self.i18n_scope
|
||||
:activerecord
|
||||
end
|
||||
end
|
||||
|
||||
require 'reform/contract'
|
||||
|
||||
class Reform::Form::ActiveModel::Errors
|
||||
prepend OpenProject::Patches::Reform
|
||||
# Whatever ruby file is placed in lib/open_project/patches is required
|
||||
Dir.glob(File.expand_path("../../../lib/open_project/patches/*.rb", __FILE__)).each do |path|
|
||||
require path
|
||||
end
|
||||
@@ -40,25 +40,23 @@ Redmine::Activity.map do |activity|
|
||||
default: false
|
||||
end
|
||||
|
||||
# TODO: replace by string based references to avoid stale
|
||||
# objects when reloading in dev mode.
|
||||
Project.register_latest_project_activity on: WorkPackage,
|
||||
Project.register_latest_project_activity on: 'WorkPackage',
|
||||
attribute: :updated_at
|
||||
|
||||
Project.register_latest_project_activity on: News,
|
||||
Project.register_latest_project_activity on: 'News',
|
||||
attribute: :updated_at
|
||||
|
||||
Project.register_latest_project_activity on: Changeset,
|
||||
chain: Repository,
|
||||
Project.register_latest_project_activity on: 'Changeset',
|
||||
chain: 'Repository',
|
||||
attribute: :committed_on
|
||||
|
||||
Project.register_latest_project_activity on: WikiContent,
|
||||
chain: [Wiki, WikiPage],
|
||||
Project.register_latest_project_activity on: 'WikiContent',
|
||||
chain: %w(Wiki WikiPage),
|
||||
attribute: :updated_on
|
||||
|
||||
Project.register_latest_project_activity on: Message,
|
||||
chain: Forum,
|
||||
Project.register_latest_project_activity on: 'Message',
|
||||
chain: 'Forum',
|
||||
attribute: :updated_on
|
||||
|
||||
Project.register_latest_project_activity on: TimeEntry,
|
||||
Project.register_latest_project_activity on: 'TimeEntry',
|
||||
attribute: :updated_on
|
||||
|
||||
@@ -24,6 +24,5 @@ OpenProject::Application.configure do
|
||||
work_packages.js
|
||||
vendor/ckeditor/ckeditor.*js
|
||||
vendor/enjoyhint.js
|
||||
bundles/openproject-legacy-app.js
|
||||
)
|
||||
end
|
||||
|
||||
@@ -46,7 +46,6 @@ OkComputer::CheckCollection.new('full').tap do |collection|
|
||||
OkComputer::Registry.default_collection.register 'full', collection
|
||||
end
|
||||
|
||||
|
||||
# Check if authentication required
|
||||
authentication_password = OpenProject::Configuration.health_checks_authentication_password
|
||||
if authentication_password.present?
|
||||
|
||||
@@ -57,7 +57,8 @@ Redmine::MenuManager.map :top_menu do |menu|
|
||||
(User.current.logged? || !Setting.login_required?) &&
|
||||
User.current.allowed_to?(:view_time_entries, nil, global: true)
|
||||
}
|
||||
menu.push :help, OpenProject::Static::Links.help_link,
|
||||
menu.push :help,
|
||||
OpenProject::Static::Links.help_link,
|
||||
last: true,
|
||||
caption: '',
|
||||
icon: 'icon5 icon-help',
|
||||
|
||||
@@ -56,5 +56,6 @@ end
|
||||
Rails.autoloaders.main.ignore(Rails.root.join('modules/*/lib/openproject-*.rb'))
|
||||
Rails.autoloaders.main.ignore(Rails.root.join('vendor/plugins/*/lib/openproject-*.rb'))
|
||||
Rails.autoloaders.main.ignore(Rails.root.join('lib/plugins'))
|
||||
Rails.autoloaders.main.ignore(Rails.root.join('lib/open_project/patches'))
|
||||
Rails.autoloaders.main.ignore(Rails.root.join('lib/generators'))
|
||||
Rails.autoloaders.main.ignore(Bundler.bundle_path.join('**/*.rb'))
|
||||
|
||||
+1
-30
@@ -1,5 +1,3 @@
|
||||
#-- encoding: UTF-8
|
||||
|
||||
#-- copyright
|
||||
# OpenProject is an open source project management software.
|
||||
# Copyright (C) 2012-2020 the OpenProject GmbH
|
||||
@@ -28,19 +26,6 @@
|
||||
# See docs/COPYRIGHT.rdoc for more details.
|
||||
#++
|
||||
|
||||
require 'active_record'
|
||||
|
||||
module ActiveRecord
|
||||
class Base
|
||||
include Redmine::I18n
|
||||
|
||||
def self.human_attribute_name(attr, options = {})
|
||||
attr = attr.to_s.gsub(/_id\z/, '')
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module ActionView
|
||||
module Helpers
|
||||
module Tags
|
||||
@@ -138,8 +123,6 @@ module ActionView
|
||||
end
|
||||
end
|
||||
|
||||
ActionView::Base.send :include, ActionView::Helpers::AccessibleErrors
|
||||
|
||||
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
|
||||
if html_tag.include?('<label')
|
||||
html_tag.to_s
|
||||
@@ -148,16 +131,4 @@ ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
|
||||
end
|
||||
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'
|
||||
ActionView::Base.send :include, ActionView::Helpers::AccessibleErrors
|
||||
+2
-2
@@ -28,7 +28,7 @@
|
||||
# See docs/COPYRIGHT.rdoc for more details.
|
||||
#++
|
||||
|
||||
module OpenProject::ActionViewHelpersAssetTagHelperPatch
|
||||
module OpenProject::Patches::ActionViewHelpersAssetTagHelperPatch
|
||||
def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
|
||||
return if (type == :atom) && Setting.table_exists? && !Setting.feeds_enabled?
|
||||
|
||||
@@ -36,4 +36,4 @@ module OpenProject::ActionViewHelpersAssetTagHelperPatch
|
||||
end
|
||||
end
|
||||
|
||||
ActionView::Helpers::AssetTagHelper.prepend(OpenProject::ActionViewHelpersAssetTagHelperPatch)
|
||||
ActionView::Helpers::AssetTagHelper.prepend(OpenProject::Patches::ActionViewHelpersAssetTagHelperPatch)
|
||||
@@ -26,14 +26,13 @@
|
||||
# See docs/COPYRIGHT.rdoc for more details.
|
||||
#++
|
||||
|
||||
if Rails.env.development?
|
||||
ActiveSupport::Dependencies.explicitly_unloadable_constants << 'API'
|
||||
module ActiveRecord
|
||||
class Base
|
||||
include Redmine::I18n
|
||||
|
||||
api_files = Dir[Rails.root.join('lib', 'api', '**', '*.rb')]
|
||||
api_reloader = ActiveSupport::FileUpdateChecker.new(api_files) do
|
||||
Rails.application.reload_routes!
|
||||
end
|
||||
ActiveSupport::Reloader.to_prepare do
|
||||
api_reloader.execute_if_updated
|
||||
def self.human_attribute_name(attr, options = {})
|
||||
attr = attr.to_s.gsub(/_id\z/, '')
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1 @@
|
||||
module OpenProject
|
||||
module Patches
|
||||
module Array
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Array.send(:include, Redmine::Diff::Diffable)
|
||||
|
||||
@@ -52,3 +52,28 @@ module OpenProject
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require "reform/form/active_model/validations"
|
||||
|
||||
Reform::Form.class_eval do
|
||||
include Reform::Form::ActiveModel::Validations
|
||||
end
|
||||
|
||||
Reform::Contract.class_eval do
|
||||
include Reform::Form::ActiveModel::Validations
|
||||
end
|
||||
|
||||
Reform::Form::ActiveModel::Validations::Validator.class_eval do
|
||||
##
|
||||
# use activerecord as the base scope instead of 'activemodel' to be compatible
|
||||
# to the messages we have already stored
|
||||
def self.i18n_scope
|
||||
:activerecord
|
||||
end
|
||||
end
|
||||
|
||||
require 'reform/contract'
|
||||
|
||||
class Reform::Form::ActiveModel::Errors
|
||||
prepend OpenProject::Patches::Reform
|
||||
end
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@
|
||||
|
||||
require 'representable'
|
||||
|
||||
module OpenProject::RepresentablePatch
|
||||
module OpenProject::Patches::Representable
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
def self.as_strategy=(strategy)
|
||||
@@ -50,6 +50,6 @@ module OpenProject::RepresentablePatch
|
||||
end
|
||||
end
|
||||
|
||||
unless Representable::Decorator.included_modules.include?(OpenProject::RepresentablePatch)
|
||||
Representable::Decorator.send(:include, OpenProject::RepresentablePatch)
|
||||
unless Representable::Decorator.included_modules.include?(OpenProject::Patches::Representable)
|
||||
Representable::Decorator.send(:include, OpenProject::Patches::Representable)
|
||||
end
|
||||
@@ -351,7 +351,7 @@ module OpenProject::Costs
|
||||
end
|
||||
|
||||
initializer 'costs.register_latest_project_activity' do
|
||||
Project.register_latest_project_activity on: ::CostObject,
|
||||
Project.register_latest_project_activity on: 'CostObject',
|
||||
attribute: :updated_on
|
||||
end
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ module OpenProject::Meeting
|
||||
end
|
||||
|
||||
initializer 'meeting.register_latest_project_activity' do
|
||||
Project.register_latest_project_activity on: ::Meeting,
|
||||
Project.register_latest_project_activity on: 'Meeting',
|
||||
attribute: :updated_at
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user