From 20e9771457336cb333ed550de8649b7f87a2827e Mon Sep 17 00:00:00 2001 From: Kabiru Mwenja Date: Fri, 12 Jun 2026 14:46:22 +0300 Subject: [PATCH] Code-maintenance: remove unreachable WorkPackageCostlogController (#23704) Remove unreachable WorkPackageCostlogController The controller has no route in the application and is referenced nowhere, so it can never be dispatched. The similarly named cost-report redirect flow is served elsewhere, leaving this as dead code. --- .../work_package_costlog_controller.rb | 90 ------------------- 1 file changed, 90 deletions(-) delete mode 100644 modules/reporting/app/controllers/work_package_costlog_controller.rb diff --git a/modules/reporting/app/controllers/work_package_costlog_controller.rb b/modules/reporting/app/controllers/work_package_costlog_controller.rb deleted file mode 100644 index 954a5bf322f..00000000000 --- a/modules/reporting/app/controllers/work_package_costlog_controller.rb +++ /dev/null @@ -1,90 +0,0 @@ -#-- 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. -#++ - -class WorkPackageCostlogController < ApplicationController - menu_item :work_packages - - before_action :find_objects - before_action :authorize - before_action :redirect_when_outside_project - - def index - filters = { operators: {}, values: {} } - - if @work_package - work_package_ids = @work_package.self_and_descendants.pluck(:id) - - filters[:operators][:work_package_id] = "=" - filters[:values][:work_package_id] = work_package_ids - end - - filters[:operators][:project_id] = "=" - filters[:values][:project_id] = [@project.id.to_s] - - respond_to do |format| - format.html do - session[CostQuery.name.underscore.to_sym] = { filters:, groups: { rows: [], columns: [] } } - redirect_to_cost_reports - end - format.all do - redirect_to_cost_reports - end - end - end - - private - - ## - # only single work packages are handled here - # redirect to cost reports for anything else - def redirect_when_outside_project - if @project.nil? - redirect_to_cost_reports - end - end - - ## - # We need to find potentially three objects - # 1. Work package from :work_package_id and its #project - # 2. Cost Type from param - def find_objects - @work_package = WorkPackage.visible.find_by(id: params[:work_package_id]) - - if params[:cost_type_id].present? - @cost_type = CostType.find(params[:cost_type_id]) - end - end - - def redirect_to_cost_reports - if @cost_type - redirect_to controller: "/cost_reports", action: "index", project_id: @project, unit: @cost_type.id - else - redirect_to controller: "/cost_reports", action: "index", project_id: @project - end - end -end