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
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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|
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ en:
|
|||
invalid_csv: "Invalid CSV: could not read headers: %{e}"
|
||||
save_error: "Could not save uploaded CSV (%{path_and_file}). Can Tracks write\
|
||||
\ to the upload directory? %{e}"
|
||||
no_context: No default context could be found
|
||||
map_title: Map fields to be imported
|
||||
header: Importing data
|
||||
submit: Import
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue