diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index c7a28c6e..1f259446 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -137,7 +137,7 @@ class ArticlesController < ApplicationController # Update articles from a spreadsheet def parse_upload - uploaded_file = params[:articles]['file'] + uploaded_file = params[:articles]['file'] or raise I18n.t('articles.controller.parse_upload.no_file') options = {filename: uploaded_file.original_filename} options[:outlist_absent] = (params[:articles]['outlist_absent'] == '1') options[:convert_units] = (params[:articles]['convert_units'] == '1') @@ -174,7 +174,12 @@ class ArticlesController < ApplicationController has_error = false Article.transaction do # delete articles - @outlisted_articles.each(&:mark_as_deleted) + begin + @outlisted_articles.each(&:mark_as_deleted) + rescue + # raises an exception when used in current order + has_error = true + end # Update articles @updated_articles.map{|a| a.save or has_error=true } # Add new articles diff --git a/config/locales/en.yml b/config/locales/en.yml index 560eddbd..efbc19b2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -358,6 +358,7 @@ en: error_update: 'An error occured when updating article ''%{article}'': %{msg}' parse_upload: notice: Articles are already up to date. + no_file: Please select a file to upload sync: notice: Articles are already up to date. shared_alert: "%{supplier} is not linked to an external database"