From db149a72684c8792324b7db081fe15c99746595b Mon Sep 17 00:00:00 2001 From: viehlieb Date: Tue, 31 Jan 2023 15:26:28 +0100 Subject: [PATCH] use filetypes for manual uploading bnn, odin, foodsoft file --- app/controllers/articles_controller.rb | 3 ++- app/views/articles/upload.html.haml | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index 4161e66a..a33d378a 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -148,10 +148,11 @@ class ArticlesController < ApplicationController # Update articles from a spreadsheet def parse_upload uploaded_file = params[:articles]['file'] or raise I18n.t('articles.controller.parse_upload.no_file') + type = params[:articles]['type'] options = { filename: uploaded_file.original_filename } options[:outlist_absent] = (params[:articles]['outlist_absent'] == '1') options[:convert_units] = (params[:articles]['convert_units'] == '1') - @updated_article_pairs, @outlisted_articles, @new_articles = @supplier.sync_from_file uploaded_file.tempfile, options + @updated_article_pairs, @outlisted_articles, @new_articles = @supplier.sync_from_file uploaded_file.tempfile, type, options if @updated_article_pairs.empty? && @outlisted_articles.empty? && @new_articles.empty? redirect_to supplier_articles_path(@supplier), :notice => I18n.t('articles.controller.parse_upload.notice') end diff --git a/app/views/articles/upload.html.haml b/app/views/articles/upload.html.haml index 8f91d790..1b67ca1d 100644 --- a/app/views/articles/upload.html.haml +++ b/app/views/articles/upload.html.haml @@ -71,9 +71,14 @@ = form_for :articles, :url => parse_upload_supplier_articles_path(@supplier), :html => { multipart: true, class: "form-horizontal" } do |f| + .control-group - %label(for="articles_file")= t '.file_label' + %label(for="articles_file") + %strong= t '.file_label' = f.file_field "file" + %label(for="articles_file") + %strong="select the file type you are about to upload" + =f.collection_select :type, ["bnn","foodsoft","odin"], :to_s, :to_s .control-group %label(for="articles_outlist_absent")