Add CSV validator to mass action

This commit is contained in:
Karl Erik Õunapuu 2020-11-04 16:30:54 +02:00
parent 4566b39435
commit 4e18545105
No known key found for this signature in database
GPG key ID: C9DD647298A34764
2 changed files with 27 additions and 5 deletions

View file

@ -10,10 +10,14 @@ module Admin
# POST /admin/mass_actions
def create
res = MassAction.process(params[:mass_action], params[:entry_list].path)
backlog = "#{params[:mass_action]} completed for #{res[:ok]}.\n" \
"Failed: objects: #{res[:fail]}"
notice = if res
"#{params[:mass_action]} completed for #{res[:ok]}.\n" \
"Failed: objects: #{res[:fail]}"
else
"Dataset integrity validation failed for #{params[:mass_action]}"
end
redirect_to(admin_mass_actions_path, notice: backlog)
redirect_to(admin_mass_actions_path, notice: notice)
end
end
end