From ecc0b0972b270cf340c06926717cc706f8b7b4fe Mon Sep 17 00:00:00 2001 From: Klaus Zanders Date: Tue, 28 Apr 2026 12:04:13 +0200 Subject: [PATCH] Resource Management Engine Boilerplate --- Gemfile.lock | 7 ++ Gemfile.modules | 1 + .../resource_management/base_controller.rb | 34 +++++++ .../resource_planners_controller.rb | 47 ++++++++++ .../resource_planners/index.html.erb | 3 + .../resource_management/config/locales/en.yml | 20 +++++ modules/resource_management/config/routes.rb | 47 ++++++++++ .../lib/open_project/resource_management.rb | 35 ++++++++ .../resource_management/engine.rb | 90 +++++++++++++++++++ .../lib/openproject-resource_management.rb | 31 +++++++ .../openproject-resource_management.gemspec | 42 +++++++++ 11 files changed, 357 insertions(+) create mode 100644 modules/resource_management/app/controllers/resource_management/base_controller.rb create mode 100644 modules/resource_management/app/controllers/resource_management/resource_planners_controller.rb create mode 100644 modules/resource_management/app/views/resource_management/resource_planners/index.html.erb create mode 100644 modules/resource_management/config/locales/en.yml create mode 100644 modules/resource_management/config/routes.rb create mode 100644 modules/resource_management/lib/open_project/resource_management.rb create mode 100644 modules/resource_management/lib/open_project/resource_management/engine.rb create mode 100644 modules/resource_management/lib/openproject-resource_management.rb create mode 100644 modules/resource_management/openproject-resource_management.gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 73046f9e47a..f8735f9b56a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -198,6 +198,11 @@ PATH openproject-reporting (1.0.0) costs +PATH + remote: modules/resource_management + specs: + openproject-resource_management (1.0.0) + PATH remote: modules/storages specs: @@ -1690,6 +1695,7 @@ DEPENDENCIES openproject-primer_view_components (~> 0.84.5) openproject-recaptcha! openproject-reporting! + openproject-resource_management! openproject-storages! openproject-team_planner! openproject-token (~> 8.8.2) @@ -2072,6 +2078,7 @@ CHECKSUMS openproject-primer_view_components (0.84.5) sha256=307ad2135cfb283b2d1da354e545bd3e3f1dda43158f020c89ff4641e441fe86 openproject-recaptcha (1.0.0) openproject-reporting (1.0.0) + openproject-resource_management (1.0.0) openproject-storages (1.0.0) openproject-team_planner (1.0.0) openproject-token (8.8.2) sha256=081cbff7269d92a82fa1d63e9e09c87b70d47d7aefadcbb80d1e7368bc2cf096 diff --git a/Gemfile.modules b/Gemfile.modules index a548efe06a1..985db5b0882 100644 --- a/Gemfile.modules +++ b/Gemfile.modules @@ -39,6 +39,7 @@ group :opf_plugins do gem 'openproject-team_planner', path: 'modules/team_planner' gem 'openproject-gantt', path: 'modules/gantt' gem 'openproject-calendar', path: 'modules/calendar' + gem 'openproject-resource_management', path: 'modules/resource_management' gem 'openproject-storages', path: 'modules/storages' gem 'openproject-wikis', path: 'modules/wikis' gem 'openproject-documents', path: 'modules/documents' diff --git a/modules/resource_management/app/controllers/resource_management/base_controller.rb b/modules/resource_management/app/controllers/resource_management/base_controller.rb new file mode 100644 index 00000000000..752348f4717 --- /dev/null +++ b/modules/resource_management/app/controllers/resource_management/base_controller.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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 ::ResourceManagement + class BaseController < ::ApplicationController + end +end diff --git a/modules/resource_management/app/controllers/resource_management/resource_planners_controller.rb b/modules/resource_management/app/controllers/resource_management/resource_planners_controller.rb new file mode 100644 index 00000000000..adbf360b61c --- /dev/null +++ b/modules/resource_management/app/controllers/resource_management/resource_planners_controller.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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 ::ResourceManagement + class ResourcePlannersController < BaseController + before_action :find_project_by_project_id + + # TODO: Temporary + no_authorization_required!(*%i[index show overview new edit create update destroy toggle_public]) + + def index; end + def show; end + def new; end + def edit; end + def create; end + def update; end + def toggle_public; end + def destroy; end + end +end diff --git a/modules/resource_management/app/views/resource_management/resource_planners/index.html.erb b/modules/resource_management/app/views/resource_management/resource_planners/index.html.erb new file mode 100644 index 00000000000..aac48d86bea --- /dev/null +++ b/modules/resource_management/app/views/resource_management/resource_planners/index.html.erb @@ -0,0 +1,3 @@ +
+  <%= @project.pretty_inspect %>
+
diff --git a/modules/resource_management/config/locales/en.yml b/modules/resource_management/config/locales/en.yml new file mode 100644 index 00000000000..4c84e863464 --- /dev/null +++ b/modules/resource_management/config/locales/en.yml @@ -0,0 +1,20 @@ +en: + plugin_openproject_resource_management: + name: "OpenProject Resource Management" + description: "Provides resource management and capacity planning." + + project_module_resource_management: "Resource management" + permission_view_resource_planners: "View resource planners" + permission_view_resource_planners_explanation: > + Allows users to access resource planners. It allows them to create and + manage their own resource planners and view public resource planners. It + does not allow users to view resource planners created by other users that + are not shared publicly. + permission_manage_public_resource_planners: "Manage public resource planners" + permission_manage_public_resource_planners_explanation: > + Allows users to create and manage public resource planners. It allows them + to view, create, manage and publish their own resource planners. It does not + allow users to view resource planners created by other users that are not + shared publicly. + + label_resource_management: "Resource planning" diff --git a/modules/resource_management/config/routes.rb b/modules/resource_management/config/routes.rb new file mode 100644 index 00000000000..b6de1345cd9 --- /dev/null +++ b/modules/resource_management/config/routes.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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. +#++ + +Rails.application.routes.draw do + # resources :resource_management, + # controller: "resource_management/resource_management", + # only: %i[] do + # collection do + # get "/", to: "resource_management/resource_management#overview", as: :overview + # end + # end + + scope "projects/:project_id", as: "project" do + resources :resource_planners, controller: "resource_management/resource_planners", as: :resource_planner do + member do + post :toggle_public + end + end + end +end diff --git a/modules/resource_management/lib/open_project/resource_management.rb b/modules/resource_management/lib/open_project/resource_management.rb new file mode 100644 index 00000000000..149c311f69a --- /dev/null +++ b/modules/resource_management/lib/open_project/resource_management.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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 ResourceManagement + require "open_project/resource_management/engine" + end +end diff --git a/modules/resource_management/lib/open_project/resource_management/engine.rb b/modules/resource_management/lib/open_project/resource_management/engine.rb new file mode 100644 index 00000000000..ae7de5453d6 --- /dev/null +++ b/modules/resource_management/lib/open_project/resource_management/engine.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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. +#++ + +require "open_project/plugins" + +module OpenProject::ResourceManagement + class Engine < ::Rails::Engine + engine_name :openproject_resource_management + + include OpenProject::Plugins::ActsAsOpEngine + + initializer "openproject-resource_management.feature_decisions" do + OpenProject::FeatureDecisions.add :resource_management + end + + register "openproject-resource_management", + author_url: "https://www.openproject.org", + bundled: true, + settings: {} do + project_module :resource_management do + permission :view_resource_planners, + { "resource_management/resource_planners": %i[index show overview] }, + permissible_on: :project + + permission :manage_public_resource_planners, + { "resource_management/resource_planners": %i[index show new create edit update destroy] }, + permissible_on: :project, + dependencies: %i[view_resource_planners] + end + + # TODO: Add those menus when global overview will be implemented + # should_render_global_menu_item = Proc.new do + # (User.current.logged? || !Setting.login_required?) && + # User.current.allowed_in_any_project?(:view_resources) && + # OpenProject::FeatureDecisions.resource_management_active? + # end + + # menu :global_menu, + # :resource_management, + # { controller: "/resource_management/resource_management", action: :overview }, + # caption: :label_resource_management, + # after: :calendar_view, + # icon: "people", + # if: should_render_global_menu_item + + # menu :top_menu, + # :resource_management, + # { controller: "/resource_management/resource_management", action: :overview }, + # context: :modules, + # caption: :label_resource_management, + # after: :calendar_view, + # icon: "people", + # if: should_render_global_menu_item + + menu :project_menu, + :resource_management, + { controller: "/resource_management/resource_planners", action: :index }, + caption: :label_resource_management, + after: :work_packages, + icon: "people" + end + end +end diff --git a/modules/resource_management/lib/openproject-resource_management.rb b/modules/resource_management/lib/openproject-resource_management.rb new file mode 100644 index 00000000000..db4a95b2302 --- /dev/null +++ b/modules/resource_management/lib/openproject-resource_management.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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. +#++ + +require "open_project/resource_management" diff --git a/modules/resource_management/openproject-resource_management.gemspec b/modules/resource_management/openproject-resource_management.gemspec new file mode 100644 index 00000000000..fbbb45d8ed2 --- /dev/null +++ b/modules/resource_management/openproject-resource_management.gemspec @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 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. +#++ + +Gem::Specification.new do |s| + s.name = "openproject-resource_management" + s.version = "1.0.0" + s.authors = "OpenProject GmbH" + s.email = "info@openproject.com" + s.summary = "OpenProject Resource Management" + s.description = "Provides resource management and capacity planning abilities." + s.license = "GPLv3" + + s.files = Dir["{app,config,db,lib}/**/*"] + s.metadata["rubygems_mfa_required"] = "true" +end