Skip to content

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

remove attachment unsuccessfully saved warning method

ulferts4dad6a4485eb
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 639e1251b81..8d3490477eb 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -523,14 +523,6 @@ class ApplicationController < ActionController::Base
end
end
- # Renders a warning flash if obj has unsaved attachments
- def render_attachment_warning_if_needed(obj)
- unsaved_attachments = obj.attachments.select(&:new_record?)
- if unsaved_attachments.any?
- flash[:warning] = l(:warning_attachments_not_saved, unsaved_attachments.size)
- end
- end
-
# Converts the errors on an ActiveRecord object into a common JSON format
def object_errors_to_json(object)
object.errors.map do |attribute, error|
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 7bfc43f74a9..c8ef35d7093 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -115,7 +115,6 @@ class WikiController < ApplicationController
@page.attach_files(permitted_params.attachments.to_h)
if @page.save
- render_attachment_warning_if_needed(@page)
call_hook(:controller_wiki_edit_after_save, params: params, page: @page)
flash[:notice] = l(:notice_successful_create)
redirect_to_show
@@ -192,7 +191,6 @@ class WikiController < ApplicationController
@content.add_journal User.current, params['content']['comments']
if @page.save_with_content
- render_attachment_warning_if_needed(@page)
call_hook(:controller_wiki_edit_after_save, params: params, page: @page)
flash[:notice] = l(:notice_successful_update)
redirect_to_show
diff --git a/modules/costs/app/controllers/cost_objects_controller.rb b/modules/costs/app/controllers/cost_objects_controller.rb
index 153c44ef3b1..4c3c76f39e6 100644
--- a/modules/costs/app/controllers/cost_objects_controller.rb
+++ b/modules/costs/app/controllers/cost_objects_controller.rb
@@ -126,22 +126,19 @@ class CostObjectsController < ApplicationController
@cost_object.project_id = @project.id
# fixed_date must be set before material_budget_items and labor_budget_items
- if params[:cost_object] && params[:cost_object][:fixed_date]
- @cost_object.fixed_date = params[:cost_object].delete(:fixed_date)
- else
- @cost_object.fixed_date = Date.today
- end
+ @cost_object.fixed_date = if params[:cost_object] && params[:cost_object][:fixed_date]
+ params[:cost_object].delete(:fixed_date)
+ else
+ Date.today
+ end
@cost_object.attributes = permitted_params.cost_object
@cost_object.attach_files(permitted_params.attachments.to_h)
if @cost_object.save
- render_attachment_warning_if_needed(@cost_object)
-
flash[:notice] = t(:notice_successful_create)
redirect_to(params[:continue] ? { action: 'new' } :
{ action: 'show', id: @cost_object })
- return
else
render action: 'new', layout: !request.xhr?
end
@@ -172,8 +169,6 @@ class CostObjectsController < ApplicationController
@cost_object.attach_files(permitted_params.attachments.to_h)
if @cost_object.save
- render_attachment_warning_if_needed(@cost_object)
-
flash[:notice] = t(:notice_successful_update)
redirect_to(params[:back_to] || { action: 'show', id: @cost_object })
else
diff --git a/modules/documents/app/controllers/documents_controller.rb b/modules/documents/app/controllers/documents_controller.rb
index 1e40e319ee8..18d412a7625 100644
--- a/modules/documents/app/controllers/documents_controller.rb
+++ b/modules/documents/app/controllers/documents_controller.rb
@@ -68,7 +68,6 @@ class DocumentsController < ApplicationController
@document.attach_files(permitted_params.attachments.to_h)
if @document.save
- render_attachment_warning_if_needed(@document)
flash[:notice] = l(:notice_successful_create)
redirect_to project_documents_path(@project)
else
@@ -85,7 +84,6 @@ class DocumentsController < ApplicationController
@document.attach_files(permitted_params.attachments.to_h)
if @document.save
- render_attachment_warning_if_needed(@document)
flash[:notice] = l(:notice_successful_update)
redirect_to action: 'show', id: @document
else
@@ -103,9 +101,8 @@ class DocumentsController < ApplicationController
attachments = @document.attachments.select(&:new_record?)
@document.save
- render_attachment_warning_if_needed(@document)
-
saved_attachments = attachments.select(&:persisted?)
+
if saved_attachments.present? && Setting.notified_events.include?('document_added')
users = saved_attachments.first.container.recipients
users.each do |user|