avoid reference to Project in initializer

pull/10420/head
ulferts 3 years ago
parent 374e1c6cf3
commit aedfa6ba2c
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 10
      app/models/projects/activity.rb
  2. 41
      config/constants/open_project/project_activity.rb
  3. 43
      config/constants/project_activity.rb
  4. 12
      config/initializers/activity.rb
  5. 2
      modules/budgets/lib/budgets/engine.rb
  6. 2
      modules/costs/lib/costs/engine.rb
  7. 2
      modules/meeting/lib/open_project/meeting/engine.rb

@ -26,23 +26,15 @@
# See COPYRIGHT and LICENSE files for more details.
#++
require Rails.root.join('config/constants/project_activity')
module Projects::Activity
def self.included(base)
base.send :extend, ActivityScopes
end
module ActivityScopes
def register_latest_project_activity(on:, attribute:, chain: [])
Constants::ProjectActivity.register(on: on,
chain: chain,
attribute: attribute)
end
def latest_project_activity
@latest_project_activity ||=
Constants::ProjectActivity.registered.map do |params|
OpenProject::ProjectActivity.registered.map do |params|
build_latest_project_activity_for(on: params[:on].constantize,
chain: Array(params[:chain]).map(&:constantize),
attribute: params[:attribute])

@ -0,0 +1,41 @@
# OpenProject is an open source project management software.
# Copyright (C) 2010-2022 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-2013 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 COPYRIGHT and LICENSE files for more details.
module OpenProject
module ProjectActivity
class << self
def register(on:, attribute:, chain: [])
@registered ||= Set.new
@registered << { on: on,
chain: chain,
attribute: attribute }
end
attr_reader :registered
end
end
end

@ -1,43 +0,0 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2022 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-2013 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 COPYRIGHT and LICENSE files for more details.
#++
module Constants
module ProjectActivity
class << self
def register(on:, attribute:, chain: [])
@registered ||= Set.new
@registered << { on: on,
chain: chain,
attribute: attribute }
end
attr_reader :registered
end
end
end

@ -26,6 +26,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
require_relative '../constants/open_project/project_activity'
Rails.application.reloader.to_prepare do
OpenProject::Activity.map do |activity|
activity.register :work_packages, class_name: '::Activities::WorkPackageActivityProvider'
@ -38,21 +40,21 @@ Rails.application.reloader.to_prepare do
default: false
end
Project.register_latest_project_activity on: 'WorkPackage',
OpenProject::ProjectActivity.register on: 'WorkPackage',
attribute: :updated_at
Project.register_latest_project_activity on: 'News',
OpenProject::ProjectActivity.register on: 'News',
attribute: :updated_at
Project.register_latest_project_activity on: 'Changeset',
OpenProject::ProjectActivity.register on: 'Changeset',
chain: 'Repository',
attribute: :committed_on
Project.register_latest_project_activity on: 'WikiContent',
OpenProject::ProjectActivity.register on: 'WikiContent',
chain: %w(Wiki WikiPage),
attribute: :updated_at
Project.register_latest_project_activity on: 'Message',
OpenProject::ProjectActivity.register on: 'Message',
chain: 'Forum',
attribute: :updated_at
end

@ -48,7 +48,7 @@ module Budgets
end
config.to_prepare do
Project.register_latest_project_activity on: 'Budget',
OpenProject::ProjectActivity.register on: 'Budget',
attribute: :updated_at
# Add to the budget to the costs group

@ -249,7 +249,7 @@ module Costs
end
config.to_prepare do
Project.register_latest_project_activity on: 'TimeEntry',
OpenProject::ProjectActivity.register on: 'TimeEntry',
attribute: :updated_at
Costs::Patches::MembersPatch.mixin!

@ -81,7 +81,7 @@ module OpenProject::Meeting
end
config.to_prepare do
Project.register_latest_project_activity on: 'Meeting',
OpenProject::ProjectActivity.register on: 'Meeting',
attribute: :updated_at
PermittedParams.permit(:search, :meetings)

Loading…
Cancel
Save