remove attachment unsuccessfully saved warning method

Attachments are now always uploaded up front, uncontainered, and after a successful upload and save of the intended container, assigned to the container.
pull/8085/head
ulferts 5 years ago
parent 2bc34e5006
commit 4dad6a4485
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 8
      app/controllers/application_controller.rb
  2. 2
      app/controllers/wiki_controller.rb
  3. 15
      modules/costs/app/controllers/cost_objects_controller.rb
  4. 5
      modules/documents/app/controllers/documents_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|

@ -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

@ -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

@ -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|

Loading…
Cancel
Save