Better error messages

This commit is contained in:
Jyri-Petteri Paloposki 2022-02-09 11:48:09 +02:00
parent c2bd1b0d81
commit 511a4a23b6
3 changed files with 4 additions and 6 deletions

View file

@ -62,8 +62,8 @@ class DataController < ApplicationController
flash[:notice] = t 'data.import.projects_count', count: count
when 'todos'
count = Todo.import path_and_file, params, current_user
if not count
flash[:error] = t('data.import.errors.invalid_destination')
if ! count
flash[:error] = t('data.import.errors.no_context')
else
flash[:notice] = t 'data.import.todos_count', count: count
end

View file

@ -353,10 +353,7 @@ class Todo < ApplicationRecord
def self.import(filename, params, user)
default_context = user.contexts.order('id').first
if default_context.nil?
logger.error "No available contexts in import"
return FALSE
end
return false if default_context.nil?
count = 0
CSV.foreach(filename, headers: true) do |row|