feat(imports): add strong params

This commit is contained in:
Luis Castro 2019-08-06 16:07:04 +02:00 committed by Eric Schultz
parent 70b1095083
commit 41d578815a
2 changed files with 15 additions and 11 deletions

View file

@ -10,13 +10,19 @@ module Nonprofits
def create def create
render_json do render_json do
InsertImport.delay.from_csv_safe( InsertImport.delay.from_csv_safe(
nonprofit_id: params[:nonprofit_id], nonprofit_id: import_params[:nonprofit_id],
user_id: current_user.id, user_id: current_user.id,
user_email: current_user.email, user_email: current_user.email,
file_uri: params[:file_uri], file_uri: import_params[:file_uri],
header_matches: params[:header_matches] header_matches: import_params[:header_matches]
) )
end end
end end
private
def import_params
params.permit(:nonprofit_id, :file_uri, :header_matches)
end
end end
end end

View file

@ -2,14 +2,12 @@
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
class Import < ApplicationRecord class Import < ApplicationRecord
# TODO # :user_id, :user,
# attr_accessible \ # :email, # email of the user who ma
# :user_id, :user, # :nonprofit_id, :nonprofit,
# :email, # email of the user who ma # :row_count,
# :nonprofit_id, :nonprofit, # :imported_count,
# :row_count, # :date
# :imported_count,
# :date
has_many :supporters has_many :supporters
belongs_to :nonprofit belongs_to :nonprofit