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
Allow overriding status if not same user
Oliver Günther73b689c6b233
diff --git a/app/components/admin/quarantined_attachments/row_component.rb b/app/components/admin/quarantined_attachments/row_component.rbindex 2ebb8999149..fec101fa34f 100644--- a/app/components/admin/quarantined_attachments/row_component.rb+++ b/app/components/admin/quarantined_attachments/row_component.rb@@ -56,13 +56,31 @@ module Adminenddef button_links- [delete_link]+ [+ override_link,+ delete_link+ ].compact+ end++ def override_link+ return if User.current == attachment.author++ helpers.link_to(+ helpers.op_icon('icon icon-unlocked'),+ { controller: '/admin/attachments/quarantined_attachments', action: :override, id: model },+ title: I18n.t('antivirus_scan.quarantined_attachments.override'),+ method: :patch,+ data: { confirm: I18n.t(:text_are_you_sure), disable_with: I18n.t(:label_loading) },+ )enddef delete_link+ return if User.current == attachment.author+helpers.link_to(helpers.op_icon('icon icon-delete'),{ controller: '/admin/attachments/quarantined_attachments', action: :destroy, id: model },+ title: I18n.t('antivirus_scan.quarantined_attachments.delete'),method: :delete,data: { confirm: I18n.t(:text_are_you_sure), disable_with: I18n.t(:label_loading) },)diff --git a/app/controllers/admin/attachments/quarantined_attachments_controller.rb b/app/controllers/admin/attachments/quarantined_attachments_controller.rbindex 74ba9f5c177..f2d4286e408 100644--- a/app/controllers/admin/attachments/quarantined_attachments_controller.rb+++ b/app/controllers/admin/attachments/quarantined_attachments_controller.rb@@ -33,18 +33,33 @@ module Adminbefore_action :require_adminbefore_action :find_quarantined_attachments+ before_action :find_attachment, only: %i[override destroy]+ before_action :prevent_same_user, only: %i[override destroy]+menu_item :attachment_quarantinedef index; end+ def override+ @attachment.status_scanned!++ create_journal(@attachment.container,+ current_user,+ I18n.t('antivirus_scan.overridden_by_admin',+ user: current_user.name,+ filename: @attachment.filename))++ flash[:notice] = t(:notice_successful_update)+ redirect_to action: :index+ end+def destroy- attachment = @attachments.find(params[:id])- container = attachment.container+ container = @attachment.container+ @attachment.destroy!- attachment.destroy!- ::Journals::CreateService- .new(container, User.system)- .call(notes: I18n.t('antivirus_scan.deleted_by_admin', filename: attachment.filename))+ create_journal(container,+ User.system,+ I18n.t('antivirus_scan.deleted_by_admin', filename: @attachment.filename))flash[:notice] = t(:notice_successful_delete)redirect_to action: :index@@ -56,6 +71,12 @@ module Adminprivate+ def create_journal(container, user, notes)+ ::Journals::CreateService+ .new(container, user)+ .call(notes:)+ end+def find_quarantined_attachments@attachments = Attachment.status_quarantineddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex b5735ae8e2d..786801f9cff 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -103,12 +103,16 @@ en:antivirus_scan:not_processed_yet_message: "Downloading is blocked, as file was not scanned for viruses yet. Please try again later."- quarantined_message: "A virus was detected in file %{filename}. It has been quarantined and is not available for download."- deleted_message: "A virus was detected in file %{filename}. The file has been deleted."- deleted_by_admin: "The quarantined file %{filename} has been deleted by an administrator."+ quarantined_message: "A virus was detected in file '%{filename}'. It has been quarantined and is not available for download."+ deleted_message: "A virus was detected in file '%{filename}'. The file has been deleted."+ deleted_by_admin: "The quarantined file '%{filename}' has been deleted by an administrator."+ overridden_by_admin: "The quarantine for file '%{filename}' has been removed by %{user}. The file can now be acccessed."quarantined_attachments:container: "Container"+ override: "Override the virus scan and allow downloading the file"+ delete: "Delete the quarantined file"title: "Quarantined attachments"+ error_cannot_act_self: "Cannot perform actions on your own uploaded files."attribute_help_texts:note_public: "Any text and images you add to this field is publicly visible to all logged in users!"diff --git a/config/routes.rb b/config/routes.rbindex 7e04fe0ae02..5fbea4a1025 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -444,7 +444,13 @@ Rails.application.routes.draw doend- resources :quarantined_attachments, controller: '/admin/attachments/quarantined_attachments', only: %i[index destroy]+ resources :quarantined_attachments,+ controller: '/admin/attachments/quarantined_attachments',+ only: %i[index destroy] do+ member do+ patch :override+ end+ endresource :backups, controller: '/admin/backups', only: %i[show] docollection do