mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
Better error messages
This commit is contained in:
parent
c2bd1b0d81
commit
511a4a23b6
3 changed files with 4 additions and 6 deletions
|
|
@ -62,8 +62,8 @@ class DataController < ApplicationController
|
||||||
flash[:notice] = t 'data.import.projects_count', count: count
|
flash[:notice] = t 'data.import.projects_count', count: count
|
||||||
when 'todos'
|
when 'todos'
|
||||||
count = Todo.import path_and_file, params, current_user
|
count = Todo.import path_and_file, params, current_user
|
||||||
if not count
|
if ! count
|
||||||
flash[:error] = t('data.import.errors.invalid_destination')
|
flash[:error] = t('data.import.errors.no_context')
|
||||||
else
|
else
|
||||||
flash[:notice] = t 'data.import.todos_count', count: count
|
flash[:notice] = t 'data.import.todos_count', count: count
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -353,10 +353,7 @@ class Todo < ApplicationRecord
|
||||||
|
|
||||||
def self.import(filename, params, user)
|
def self.import(filename, params, user)
|
||||||
default_context = user.contexts.order('id').first
|
default_context = user.contexts.order('id').first
|
||||||
if default_context.nil?
|
return false if default_context.nil?
|
||||||
logger.error "No available contexts in import"
|
|
||||||
return FALSE
|
|
||||||
end
|
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
CSV.foreach(filename, headers: true) do |row|
|
CSV.foreach(filename, headers: true) do |row|
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,7 @@ en:
|
||||||
invalid_csv: "Invalid CSV: could not read headers: %{e}"
|
invalid_csv: "Invalid CSV: could not read headers: %{e}"
|
||||||
save_error: "Could not save uploaded CSV (%{path_and_file}). Can Tracks write\
|
save_error: "Could not save uploaded CSV (%{path_and_file}). Can Tracks write\
|
||||||
\ to the upload directory? %{e}"
|
\ to the upload directory? %{e}"
|
||||||
|
no_context: No default context could be found
|
||||||
map_title: Map fields to be imported
|
map_title: Map fields to be imported
|
||||||
header: Importing data
|
header: Importing data
|
||||||
submit: Import
|
submit: Import
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue