From 63cf1dea7eae392d0893a028e527dd7453b385bf Mon Sep 17 00:00:00 2001 From: Klaus Zanders Date: Tue, 2 Jun 2026 11:13:02 +0200 Subject: [PATCH] Implement stub controller for Resource Allocations --- .../resource_allocations_controller.rb | 53 +++++++++++++++++++ modules/resource_management/config/routes.rb | 4 ++ .../resource_management/engine.rb | 8 +-- 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 modules/resource_management/app/controllers/resource_management/resource_allocations_controller.rb diff --git a/modules/resource_management/app/controllers/resource_management/resource_allocations_controller.rb b/modules/resource_management/app/controllers/resource_management/resource_allocations_controller.rb new file mode 100644 index 00000000000..91be1ffe29c --- /dev/null +++ b/modules/resource_management/app/controllers/resource_management/resource_allocations_controller.rb @@ -0,0 +1,53 @@ +# 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 ResourceAllocationsController < BaseController + include OpTurbo::ComponentStream + + menu_item :resource_management + + before_action :find_project_by_project_id + before_action :authorize + + # The modals and the ResourceAllocations::* contracts/services are wired up + # in follow-up work. For now these are stubs so the routes and the + # `allocate_user_resources` permission have something to bind to. + + def new; end + + def edit; end + + def create; end + + def update; end + + def destroy; end + end +end diff --git a/modules/resource_management/config/routes.rb b/modules/resource_management/config/routes.rb index 808c848deb5..a96e319be63 100644 --- a/modules/resource_management/config/routes.rb +++ b/modules/resource_management/config/routes.rb @@ -62,5 +62,9 @@ Rails.application.routes.draw do get "menu" => "resource_management/menus#show" end end + + resources :resource_allocations, + controller: "resource_management/resource_allocations", + only: %i[new create edit update destroy] 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 index 6e8f5320735..d3021104fa6 100644 --- a/modules/resource_management/lib/open_project/resource_management/engine.rb +++ b/modules/resource_management/lib/open_project/resource_management/engine.rb @@ -72,12 +72,12 @@ module OpenProject::ResourceManagement dependencies: %i[view_resource_planners] # `allocate_user_resources` gates create/update/delete on - # ResourceAllocation records. No controller actions yet — the - # ResourceAllocations::*Contract classes consume this directly via - # `allowed_in_project?`. The `contract_actions` map keeps the + # ResourceAllocation records, both via the controller actions below and + # directly in the ResourceAllocations::*Contract classes (which consume + # it through `allowed_in_project?`). The `contract_actions` map keeps the # permission discoverable for API contracts. permission :allocate_user_resources, - {}, + { "resource_management/resource_allocations": %i[new create edit update destroy] }, permissible_on: :project, dependencies: %i[view_resource_planners], contract_actions: { resource_allocation: %i[create update destroy] }