OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Remove "Update work package % Complete values" button in admin
Christophe Bliard1c5c4c82facb
diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rbindex e673ecd71b7..1c1a1a489b7 100644--- a/app/controllers/statuses_controller.rb+++ b/app/controllers/statuses_controller.rb@@ -83,15 +83,6 @@ class StatusesController < ApplicationControllerredirect_to action: "index"end- def update_work_package_done_ratio- if Status.update_work_package_done_ratios- flash[:notice] = I18n.t(:notice_work_package_done_ratios_updated)- else- flash[:error] = I18n.t(:error_work_package_done_ratios_not_updated)- end- redirect_to action: "index"- end-protecteddef default_breadcrumbdiff --git a/app/models/status.rb b/app/models/status.rbindex 3b31e1ddcd8..01be255ac35 100644--- a/app/models/status.rb+++ b/app/models/status.rb@@ -60,19 +60,6 @@ class Status < ApplicationRecordwhere(is_default: true)end- # Update all the +Issues+ setting their done_ratio to the value of their +Status+- def self.update_work_package_done_ratios- if WorkPackage.use_status_for_done_ratio?- Status.where(["default_done_ratio >= 0"]).find_each do |status|- WorkPackage- .where(["status_id = ?", status.id])- .update_all(["done_ratio = ?", status.default_done_ratio])- end- end-- WorkPackage.use_status_for_done_ratio?- end-def self.order_by_positionorder(:position)enddiff --git a/app/views/statuses/index.html.erb b/app/views/statuses/index.html.erbindex 359efef2da8..f86e4a91d1e 100644--- a/app/views/statuses/index.html.erb+++ b/app/views/statuses/index.html.erb@@ -38,14 +38,6 @@ See COPYRIGHT and LICENSE files for more details.<span class="button--text"><%= t(:label_status) %></span><% end %></li>- <% if WorkPackage.use_status_for_done_ratio? %>- <li class="toolbar-item">- <%= link_to update_work_package_done_ratio_statuses_path, class: 'button', method: :post, data: { confirm: t(:text_are_you_sure) } do %>- <%= op_icon('button--icon icon-reload') %>- <span class="button--text"><%= t(:label_update_work_package_done_ratios) %></span>- <% end %>- </li>- <% end %><% end %><%= render ::Statuses::TableComponent.new(rows: @statuses) %>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 2f43a0172c3..c431c7d776d 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1617,7 +1617,6 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}error_pdf_export_too_many_columns: "Too many columns selected for the PDF export. Please reduce the number of columns."error_pdf_failed_to_export: "The PDF export could not be saved: %{error}"error_token_authenticity: "Unable to verify Cross-Site Request Forgery token. Did you try to submit data on multiple browsers or tabs? Please close all tabs and try again."- error_work_package_done_ratios_not_updated: "Work package % Complete values not updated."error_work_package_not_found_in_project: "The work package was not found or does not belong to this project"error_must_be_project_member: "must be project member"error_migrations_are_pending: "Your OpenProject installation has pending database migrations. You have likely missed running the migrations on your last upgrade. Please check the upgrade guide to properly upgrade your installation."@@ -2358,7 +2357,6 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}label_type_new: "New type"label_type_plural: "Types"label_ui: "User Interface"- label_update_work_package_done_ratios: "Update work package % Complete values"label_updated_time: "Updated %{value} ago"label_updated_time_at: "%{author} %{age}"label_updated_time_by: "Updated by %{author} %{age} ago"@@ -2675,7 +2673,6 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}notice_file_not_found: "The page you were trying to access doesn't exist or has been removed."notice_forced_logout: "You have been automatically logged out after %{ttl_time} minutes of inactivity."notice_internal_server_error: "An error occurred on the page you were trying to access. If you continue to experience problems please contact your %{app_title} administrator for assistance."- notice_work_package_done_ratios_updated: "% complete updated"notice_locking_conflict: "Information has been updated by at least one other user in the meantime."notice_locking_conflict_additional_information: "The update(s) came from %{users}."notice_locking_conflict_reload_page: "Please reload the page, review the changes and reapply your updates."diff --git a/config/routes.rb b/config/routes.rbindex 5aae3501cd2..8be1cebe7f7 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -121,11 +121,7 @@ Rails.application.routes.draw dopost "move/:id", action: "move", on: :collectionend- resources :statuses, except: :show do- collection do- post "update_work_package_done_ratio"- end- end+ resources :statuses, except: :showget "custom_style/:digest/logo/:filename" => "custom_styles#logo_download",as: "custom_style_logo",diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rbindex 08c305fe872..b4d271f588d 100644--- a/spec/controllers/statuses_controller_spec.rb+++ b/spec/controllers/statuses_controller_spec.rb@@ -252,28 +252,4 @@ RSpec.describe StatusesController doit_behaves_like "redirects to index page"endend-- describe "#update_work_package_done_ratio" do- context "with 'work_package_done_ratio' using 'field'",- with_settings: { work_package_done_ratio: "field" } do- before do- post :update_work_package_done_ratio- end-- it { is_expected.to set_flash[:error].to(I18n.t("error_work_package_done_ratios_not_updated")) }-- it_behaves_like "redirects to index page"- end-- context "with 'work_package_done_ratio' using 'status'",- with_settings: { work_package_done_ratio: "status" } do- before do- post :update_work_package_done_ratio- end-- it { is_expected.to set_flash[:notice].to(I18n.t("notice_work_package_done_ratios_updated")) }-- it_behaves_like "redirects to index page"- end- endenddiff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rbindex 40b68cd15e4..83b808dbdfa 100644--- a/spec/models/status_spec.rb+++ b/spec/models/status_spec.rb@@ -97,30 +97,6 @@ RSpec.describe Status doendend- describe ".update_done_ratios" do- let(:status) { create(:status, default_done_ratio: 50) }- let(:work_package) { create(:work_package, status:) }-- context "with Setting.work_package_done_ratio using the field", with_settings: { work_package_done_ratio: "field" } do- it "changes nothing" do- done_ratio_before = work_package.done_ratio- described_class.update_work_package_done_ratios-- expect(work_package.reload.done_ratio)- .to eql done_ratio_before- end- end-- context "with Setting.work_package_done_ratio using the status", with_settings: { work_package_done_ratio: "status" } do- it "updates all of the work package's % Complete values to match their status" do- described_class.update_work_package_done_ratios-- expect(work_package.reload.done_ratio)- .to eql status.default_done_ratio- end- end- end-describe "#destroy" doit "cannot be destroyed if the status is in use" dowork_package = create(:work_package)